> For the complete documentation index, see [llms.txt](https://docs.moxha.dev/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.moxha.dev/documentation/paid-scripts/surround-spatial-audio/api/client/set.md).

# Set

These are setters

### Set Volume

```lua
exports['mx-surround']:setVolumeMax(soundId, volume, disableOverWrite)
```

#### Parameters

* > **soundId:** `string`
* > **volume:** `number`
* > **disableOverWrite?:** `boolean`
  >
  > * If true, volume will not be overwritten by sound profile

***

### Set Streamer Mode

```lua
exports['mx-surround']:setStreamerMode(bool)
```

#### Parameters

* > **bool:** `boolean`

***

### Set Type

```lua
exports['mx-surround']:setStereoMode(soundId, stereo)
```

#### Parameters

* > **soundId:** `string`
* > **stereo:** `boolean`
  >
  > * If this is false, it will be spatial (3D)

***

### Set Panner

```lua
exports['mx-surround']:setPanner(soundId, panner)
```

#### Parameters

* > **soundId:** `string`
* > **panner:** `PannerNode`
  >
  > * [See](https://developer.mozilla.org/en-US/docs/Web/API/PannerNode?retiredLocale=tr)

***

### Set Coords

```lua
exports['mx-surround']:setCoords(soundId, coords, xSound)
```

#### Parameters

* > **soundId:** `string`
* > **coords:** `vector3`
* > **xSound?:** `boolean`

***

### Set TimeStamp

```lua
exports['mx-surround']:setTimeStamp(soundId, timeStamp)
```

#### Parameters

* > **soundId:** `string`
* > **timeStamp:** `number`

***

### Set Loop

```lua
exports['mx-surround']:setLoop(soundId, loop)
```

#### Parameters

* > **soundId:** `string`
* > **loop:** `boolean`

***

### Set Max Distance

```lua
exports['mx-surround']:setMaxDistance(soundId, maxDistance)
```

#### Parameters

* > **soundId:** `string`
* > **maxDistance:** `number`

***

### Set Destroy On Finish

```lua
exports['mx-surround']:setDestroyOnFinish(soundId, destroyOnFinish)
```

#### Parameters

* > **soundId:** `string`
* > **destroyOnFinish:** `boolean`<br>

***

### Disable Interior Filter

It allows you to disable or enable effects that make sound appear to come from within an interior. If you are playing small sounds like stove sounds in a interior, it will also disable the feature that plays them in stereo rather than 3D. Therefore, it is very useful for particle sounds.

```lua
exports['mx-surround']:setDisableInteriorFilter(soundId, disableFilter)
```

#### Parameters

* > **soundId:** `string`
* > **disableFilter:** `boolean`

***

### Disable Vehicle Filter

```lua
exports['mx-surround']:setDisableVehicleFilter(soundId, disableFilter)
```

#### Parameters

* > **soundId:** `string`
* > **disableFilter:** `boolean`

***

### Set Rolloff

```lua
exports['mx-surround']:setRolloff(soundId, scale, plateau)
```

How far a sound carries. Raise it for sirens and alarms that should be heard across a block, lower it for something that should stay in one room.

#### Parameters

* **soundId**: `string | number`
* **scale**: `number`
  * `1.0` is normal. `3.0` carries about three times further
* **plateau?**: `number`
  * Metres of full volume around the source before any falloff starts. Defaults to `0.0`

***

### Set Emitters

```lua
exports['mx-surround']:setEmitters(soundId, emitters)
```

Render one sound from several speaker positions at once, the way a venue drives a room. Each emitter gets its own distance attenuation and occlusion, so the music spreads through the room instead of coming from a single point.

#### Parameters

* **soundId**: `string | number`
* **emitters**: `vector3[] | nil`
  * Up to 8 positions; anything past that is ignored
  * `nil` or an empty table restores a single emitter at the sound's coords

#### Returns

* `true | false`

***

### Set Fills Space

```lua
exports['mx-surround']:setFillsSpace(soundId, options)
```

Make a sound fill the space around the listener instead of staying a point source. Inside the space it stops being directional, which is what a room full of speakers actually sounds like.

Pass a `polygon` for the full behaviour: anywhere inside it the sound is fully non-directional, and it fades back to positional over `margin` metres outside. A sphere works too when you only have a centre point.

#### Parameters

* **soundId**: `string | number`
* **options**: `boolean | table`
  * `false` disables it, `true` enables it with defaults
  * **polygon?**: `{ x: number, y: number }[]` — the room footprint, at least 3 points
  * **minZ?** / **maxZ?**: `number` — floor and ceiling of the footprint
  * **margin?**: `number` — metres it takes to fade back to positional outside. Default `12.0`
  * **inner?** / **outer?**: `number` — sphere radii, used when there is no polygon
  * **coords?**: `vector3` — centre of the sphere
  * **maxLeakage?**: `number` — `0.0` - `1.0`, how much escapes the space. Default `1.0`
  * **interior?**: `boolean` — sharing an interior with the listener fills it. Default `true`

#### Returns

* `true | false`

***

### Set Leak Distance

```lua
exports['mx-surround']:setLeakDistance(soundId, options)
```

Let a sound bleed through walls purely by proximity — the muffled club music through a wall effect. The sound stays occluded, it just does not disappear because there is no open door.

#### Parameters

* **soundId**: `string | number`
* **options**: `boolean | table`
  * `false` disables it
  * **min?**: `number` — inside this distance leakage is at full strength. Default `0.0`
  * **max?**: `number` — leakage fades to nothing by here. Default `25.0`
  * **maxLeakage?**: `number` — `0.0` - `1.0`, strongest leak. Default `0.5`

#### Returns

* `true | false`

***

### Set Sync Trim

```lua
exports['mx-surround']:setSyncTrim(soundId, rate)
```

Run a sound fractionally fast or slow to close a small timing gap without seeking. A seek on a stream rebuffers and is plainly audible; half a percent of speed is not, and closes the gap over the next minute.

Rates outside the inaudible range are clamped. Backends with no fine speed control ignore this entirely, so check `supportsRateTrim` first.

#### Parameters

* **soundId**: `string | number`
* **rate**: `number`
  * `1.0` is normal speed

***

#### Set Playback Rate

```lua
local applied = exports['mx-surround']:setPlaybackRate(soundId, rate, preservePitch)
```

Play a sound faster or slower: a DJ pushing a track to 1.25x, or dragging it down to 0.8x. `preservePitch` decides how it sounds. Keep it on and only the tempo changes. Turn it off and the pitch follows the speed, like a vinyl deck.

Only this client hears the change. To change it for everyone, and for players who join later, use the server export with `-1`.

{% hint style="info" %}
`getTimeStamp` and `getMaxDuration` stay in media time. At 2x a track still runs from 0 to its full length, just twice as fast.
{% endhint %}

**Parameters**

* **soundId**: `string | number`
* **rate**: `number`
  * `1.0` is normal speed. Clamped to `0.25` - `4.0`
  * YouTube links snap to YouTube's own speeds: `0.25`, `0.5`, `0.75`, `1.0`, `1.25`, `1.5`, `1.75`, `2.0`
* **preservePitch?**: `boolean`
  * `true` keeps the key, `false` lets the pitch follow the speed. Default `true`

**Returns**

* `number | false`
  * The rate actually applied, after clamping and YouTube snapping

***

### Supports Rate Trim

```lua
local canTrim = exports['mx-surround']:supportsRateTrim(soundId)
```

Whether this sound's backend can be nudged by a fraction of a percent of speed. `false` for YouTube, which only offers a handful of discrete speeds — callers keeping a room in step have to seek those instead.

#### Parameters

* **soundId**: `string | number`

#### Returns

* `boolean`

***

### Is Deafened

```lua
local strength = exports['mx-surround']:isDeafened()
```

How badly the listener's ears are ringing right now, so your own systems can react to a nearby blast.

#### Returns

* `number`
  * `0.0` is normal hearing, `1.0` is fully deafened. Each ear recovers over about 7 seconds

***
