> For the complete documentation index, see [llms.txt](https://sonity.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sonity.gitbook.io/docs/soundparameter.md).

# SoundParameter

Use SoundParameters to control sounds through code

[SoundParameters](/docs/soundparameter.md) are used to control how [SoundEvents](/docs/soundevent.md) are played (e.g. volume, polyphony, fade in length etc).\
They can be passed when playing a [SoundEvent](/docs/soundevent.md) and set to update either once or continuously.\
They have similar functionality as the [modifiers](/docs/modifiers.md), but with scripting capabilities.

Example code:

```csharp
using UnityEngine;
using Sonity;

public class ExampleSoundParameter : MonoBehaviour {

    public SoundEvent soundEvent;
    SoundParameterVolumeDecibel volumeParameter = new SoundParameterVolumeDecibel(0f, UpdateMode.Once);

    void Start() {
        // Sets the volume parameter to a random value between -12 dB and 0 dB
        volumeParameter.VolumeDecibel = Random.Range(-12f, 0f);

        // Plays the SoundEvent with the sound parameter
        soundEvent.Play(transform, volumeParameter);
    }
}
```

**Update Modes**\
The UpdateMode enum determines if the [SoundEvent](/docs/soundevent.md) will take the parameter into consideration only once at start or if it will be updated continuously.

```csharp
// The SoundParameter will update only once
UpdateMode.Once

// The SoundParameter will update continuously
UpdateMode.Continuous
```

**Parameter Types**\
The parameter type determines which parameter of the [SoundEvent](/docs/soundevent.md) will be controlled.\
See [modifiers](/docs/modifiers.md) for more detailed info on the individual parameters.

```csharp
// Volume offset in decibel. Range -Infinity to 0
public class SoundParameterVolumeDecibel(float volumeDecibel = 0f, UpdateMode updateMode = UpdateMode.Once);

// Volume ratio multiplier. Range 0f to 1f
public class SoundParameterVolumeRatio(float volumeRatio = 1f, UpdateMode updateMode = UpdateMode.Once);

// Pitch offset in semitones
public class SoundParameterPitchSemitone(float pitchSemitone = 0f, UpdateMode updateMode = UpdateMode.Once);

// Pitch offset ratio multiplier. Range 0 to Infinity
public class SoundParameterPitchRatio(float pitchRatio = 1f, UpdateMode updateMode = UpdateMode.Once);

// Delay increase. Range 0 to Infinity
public class SoundParameterDelay(float delay = 0f);

// Makes the sound more 2D (less spatialized). Range 0 to 1
public class SoundParameterIncrease2D(float increase2D = 0f, UpdateMode updateMode = UpdateMode.Once);

// Controls the intensity of the SoundContainer
// Go to the SoundContainer to change how intensity will affect the sound
public class SoundParameterIntensity(float intensity = 1f, UpdateMode updateMode = UpdateMode.Once);

// Reverb zone mix offset in decibel. Range -Infinity to 0
public class SoundParameterReverbZoneMixDecibel(float reverbZoneMixDecibel = 0f, UpdateMode updateMode = UpdateMode.Once);

// Reverb zone mix ratio multiplier. Range 0 to 1
public class SoundParameterReverbZoneMixRatio(float reverbZoneMixRatio = 1f, UpdateMode updateMode = UpdateMode.Once);

// Reverb zone mix ratio multiplier. Range 0 to 1
public class SoundParameterReverbZoneMixRatio(float reverbZoneMixRatio = 1f, UpdateMode updateMode = UpdateMode.Once);

// Start position. Range 0 to 1
public class SoundParameterStartPosition(float startPosition = 0f);

// If the sound should be played backwards. If enabled, set the start position to the end.
// Reverse is only supported for AudioClips which are stored in an uncompressed format or will be decompressed at load time.
public class SoundParameterReverse(bool reverse = false);

// The polyphony of the SoundEvent. Range 1 to int.MaxValue
public class SoundParameterPolyphony(int polyphony = 1);

// Distance scale multiplier. Range 0 to Infinity
public class SoundParameterDistanceScale(float distanceScale = 1f);

// Distortion increase. Range 0 to 1
public class SoundParameterDistortionIncrease(float distortionIncrease = 1f, UpdateMode updateMode = UpdateMode.Once);

// Fade in length. Range 0 to Infinity
public class SoundParameterFadeInLength(float fadeInLength = 0f, UpdateMode updateMode = UpdateMode.Once);

// Fade in shape. Range -16 to 16 (negative is exponential, 0 is linear, positive is logarithmic);
public class SoundParameterFadeInShape(float fadeInShape = 2f, UpdateMode updateMode = UpdateMode.Once);

// Fade out length. Range 0 to Infinity
public class SoundParameterFadeOutLength(float fadeOutLength = 0f, UpdateMode updateMode = UpdateMode.Once);

// Fade out shape. Range -16 to 16 (negative is exponential, 0 is linear, positive is logarithmic);
public class SoundParameterFadeOutShape(float fadeOutShape = -2f, UpdateMode updateMode = UpdateMode.Once);

// If the SoundEvent should follow the Transform position
public class SoundParameterFollowPosition(bool followPosition = true, UpdateMode updateMode = UpdateMode.Once);

// If the SoundEvent should be forced to 2D (disabling distance, spatialization and angle to stereo pan)
public class SoundParameterForce2D(bool force2D = true);

// If reverb zones should be bypassed
public class SoundParameterBypassReverbZones(bool bypassReverbZones = false, UpdateMode updateMode = UpdateMode.Once);

// If voice effects (distortion/lowpass/highpass) should be bypassed
public class SoundParameterBypassVoiceEffects(bool bypassEffects = false, UpdateMode updateMode = UpdateMode.Once);

// If listener effects should be bypassed
public class SoundParameterBypassListenerEffects(bool bypassListenerEffects = false, UpdateMode updateMode = UpdateMode.Once);
```
