Class Sound
The persistent storage for sound variations and the most important audio source settings.
Inheritance
Inherited Members
Namespace: Stem
Assembly: Stem.dll
Syntax
[Serializable]
public class Sound : IAudioClipContainer, ISerializationCallbackReceiver
Properties
| Improve this Doc View SourceAttenuationMode
The attenuation mode defining how sound volume will be lowered over the distance.
Declaration
public AttenuationMode AttenuationMode { get; set; }
Property Value
Type | Description |
---|---|
AttenuationMode | An enum value. |
Remarks
Note that attenuation rules applies only for 3D sounds. Please refer to Unity Scripting Reference for details.
Audible
The flag indicating if the sound can be heard.
Declaration
public bool Audible { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if the sound can be heard. False otherwise. |
Remarks
If the Bus is inaudible, the sound will also be inaudible.
AudioClipManagementMode
The audio clip management mode of the sound.
Declaration
public AudioClipManagementMode AudioClipManagementMode { get; set; }
Property Value
Type | Description |
---|---|
AudioClipManagementMode | An enum value. |
Remarks
This value is used only if OverrideAudioClipManagement flag is true.
AudioClipUnloadInterval
The audio clip unload interval of the sound.
Declaration
public float AudioClipUnloadInterval { get; set; }
Property Value
Type | Description |
---|---|
System.Single | A time interval in seconds. |
Remarks
This value is used only if OverrideAudioClipManagement flag is true and GetAudioClipManagementMode() return value is UnloadUnused.
Bank
The sound bank the sound belongs to.
Declaration
public SoundBank Bank { get; set; }
Property Value
Type | Description |
---|---|
SoundBank | A reference to a sound bank. |
Bus
The reference to a sound bus which will manage the sound.
Declaration
public SoundBus Bus { get; set; }
Property Value
Type | Description |
---|---|
SoundBus | A reference to a sound bus. |
Remarks
If set to null, DefaultBus will be used.
DopplerLevel
The parameter defining the Doppler scale for the sound.
Declaration
public float DopplerLevel { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Doppler scale of the sound. The value must be greater or equal to zero. |
Remarks
This parameter duplicates corresponding parameter from AudioSource. Please refer to Unity Scripting Reference for details.
ID
The unique identifier for fast access to the sound.
Declaration
public int ID { get; }
Property Value
Type | Description |
---|---|
System.Int32 | A unique identifier value of the sound. |
MaxDistance
The parameter defining the boundary outside which the sound will be inaudible or stop attenuating depending on AttenuationMode value.
Declaration
public float MaxDistance { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Distance in units. |
Remarks
This parameter duplicates corresponding parameter from AudioSource. Please refer to Unity Scripting Reference for details.
MinDistance
The parameter defining the boundary within which the sound won't get any louder.
Declaration
public float MinDistance { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Distance in units. |
Remarks
This parameter duplicates corresponding parameter from AudioSource. Please refer to Unity Scripting Reference for details.
Muted
The flag indicating if the sound is muted and can't be heard.
Declaration
public bool Muted { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if the sound is muted. False otherwise. |
Remarks
This flag may be overridden by the Soloed flag, i.e. if the sound is simultaneously muted and soloed it'll be audible.
Name
The name of the sound. Used for fast search in corresponding sound bank.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String | Name of the sound. |
OverrideAudioClipManagement
The flag indicating whether the sound should use its own audio clip management mode and unload interval.
Declaration
public bool OverrideAudioClipManagement { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if the sound has overridden audio clip management and unload interval. False otherwise. |
Remarks
This flag defines the behaviour of GetAudioClipManagementMode() and GetAudioClipUnloadInterval() methods.
If true, the sound will use its own AudioClipManagementMode and AudioClipUnloadInterval properties. Otherwise, SoundManagementMode and SoundUnloadInterval properties of the containing bank will be used.
PanStereo
The stereo panning parameter defining sound position in a stereo way (left or right).
Declaration
public float PanStereo { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Stereo pan of the sound. The value must be in [-1;1] range. |
Remarks
This parameter duplicates corresponding parameter from AudioSource. Please refer to Unity Scripting Reference for details.
Soloed
The flag indicating if the sound is soloed. If set to true, all other non-solo sounds won't be audible.
Declaration
public bool Soloed { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if the sound is soloed. False otherwise. |
Remarks
This flag may override the Muted flag, i.e. if the sound is simultaneously muted and soloed it'll be audible.
SpatialBlend
The spatial blend parameter defining how much the sound is affected by 3d spatialisation calculations (attenuation, doppler etc).
Declaration
public float SpatialBlend { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Spatial blend of the sound. The value must be in [0;1] range. |
Remarks
This parameter duplicates corresponding parameter from AudioSource. Please refer to Unity Scripting Reference for details.
Spread
The parameter defining the spread angle (in degrees) of a 3d stereo or multichannel sound in speaker space.
Declaration
public float Spread { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Spread angle of the sound. The value must be in [0;360] range. |
Remarks
This parameter duplicates corresponding parameter from AudioSource. Please refer to Unity Scripting Reference for details.
Unfolded
The flag indicating whether the sound bank inspector should show advanced settings for the sound.
Declaration
public bool Unfolded { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if advanced settings are shown. False otherwise. |
Remarks
This property is used only by the sound bank inspector and does nothing during runtime.
VariationRetriggerMode
The retrigger mode defining how the sound will play variations.
Declaration
public RetriggerMode VariationRetriggerMode { get; set; }
Property Value
Type | Description |
---|---|
RetriggerMode | An enum value. |
Variations
The collection of sound variations.
Declaration
public ReadOnlyCollection<SoundVariation> Variations { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<SoundVariation> | A reference to a read-only collection of sound variations. |
Methods
| Improve this Doc View SourceAddVariation(AudioClip)
Adds a single sound variation to the sound.
Declaration
public SoundVariation AddVariation(AudioClip clip)
Parameters
Type | Name | Description |
---|---|---|
AudioClip | clip | A reference to the audio clip with audio data. |
Returns
Type | Description |
---|---|
SoundVariation | A reference to a newly created sound variation. |
AddVariations(AudioClip[])
Adds multiple sound variations (one per audio clip) to the sound.
Declaration
public void AddVariations(AudioClip[] clips)
Parameters
Type | Name | Description |
---|---|---|
AudioClip[] | clips | An array of audio clips with audio data. |
GetAudioClip(Int32)
Gets the audio clip at the specified index.
Declaration
public AudioClip GetAudioClip(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The zero-based index of the audio clip to get. |
Returns
Type | Description |
---|---|
AudioClip | A reference to an audio clip. |
GetAudioClipManagementMode()
Gets the audio clip management mode of the sound.
Declaration
public AudioClipManagementMode GetAudioClipManagementMode()
Returns
Type | Description |
---|---|
AudioClipManagementMode | An enum value. |
Remarks
If OverrideAudioClipManagement value is true, AudioClipManagementMode will be used. Otherwise, SoundManagementMode value of the containing bank will be used.
GetAudioClipUnloadInterval()
Gets the audio clip unload interval of the sound.
Declaration
public float GetAudioClipUnloadInterval()
Returns
Type | Description |
---|---|
System.Single | The time interval in seconds. |
Remarks
This value is only used if GetAudioClipManagementMode() return value is UnloadUnused
If OverrideAudioClipManagement value is true, AudioClipUnloadInterval will be used. Otherwise, SoundUnloadInterval value of the containing bank will be used.
GetNumAudioClips()
Gets the number of audio clips in the sound.
Declaration
public int GetNumAudioClips()
Returns
Type | Description |
---|---|
System.Int32 | The number of audio clips. |
OnAfterDeserialize()
Prepares sound for runtime use after deserialization.
Declaration
public void OnAfterDeserialize()
Remarks
This method is automatically called by Unity during deserialization process. Don't call it manually.
OnBeforeSerialize()
Prepares sound for serialization.
Declaration
public void OnBeforeSerialize()
Remarks
This method is automatically called by Unity during serialization process. Don't call it manually.