Class SoundBank
The persistent storage for sounds and sound buses.
Inheritance
Namespace: Stem
Assembly: Stem.dll
Syntax
public class SoundBank : ScriptableObject, IBank, ISerializationCallbackReceiver
Properties
| Improve this Doc View SourceBuses
The collection of sound buses.
Declaration
public ReadOnlyCollection<SoundBus> Buses { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<SoundBus> | A reference to a read-only collection of sound buses. |
DefaultBus
The sound bus which will be used by default on newly created sounds.
Declaration
public SoundBus DefaultBus { get; }
Property Value
Type | Description |
---|---|
SoundBus | A reference to a sound bus. |
ShowSoundBuses
The flag indicating whether the sound bank inspector should show the 'Buses' group.
Declaration
public bool ShowSoundBuses { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if the 'Buses' group is shown. False otherwise. |
Remarks
This property is used only by the sound bank inspector and does nothing during runtime.
ShowSounds
The flag indicating whether the sound bank inspector should show the 'Sounds' group.
Declaration
public bool ShowSounds { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if the 'Sounds' group is shown. False otherwise. |
Remarks
This property is used only by the sound bank inspector and does nothing during runtime.
SoundBatchImportMode
The batch import mode defining how new sounds will be created after the drag-drop event.
Declaration
public AudioClipImportMode SoundBatchImportMode { get; set; }
Property Value
Type | Description |
---|---|
AudioClipImportMode | An enum value. |
SoundManagementMode
The default audio clip management mode for all sounds of the sound bank.
Declaration
public AudioClipManagementMode SoundManagementMode { get; set; }
Property Value
Type | Description |
---|---|
AudioClipManagementMode | An enum value. |
Remarks
By default, all sounds will use this value for audio clip management, however, it can be overridden by the OverrideAudioClipManagement flag.
Sounds
The collection of sounds.
Declaration
public ReadOnlyCollection<Sound> Sounds { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<Sound> | A reference to a read-only collection of sounds. |
SoundUnloadInterval
The default audio clip unload interval for all sounds of the the sound bank.
Declaration
public float SoundUnloadInterval { get; set; }
Property Value
Type | Description |
---|---|
System.Single | A time interval in seconds. |
Remarks
By default, all sounds will use this value for audio clip unload interval, however, it can be overridden by the OverrideAudioClipManagement flag.
Methods
| Improve this Doc View SourceAddSound(String)
Adds an empty sound to the sound bank.
Declaration
public Sound AddSound(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the sound. |
Returns
Type | Description |
---|---|
Sound | A reference to a newly created sound. |
AddSound(String, AudioClip)
Adds a sound with a single variation to the sound bank.
Declaration
public Sound AddSound(string name, AudioClip clip)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the sound. |
AudioClip | clip | A reference to the audio clip with audio data. |
Returns
Type | Description |
---|---|
Sound | A reference to a newly created sound. |
AddSound(String, AudioClip[])
Adds a sound with multiple variations to the sound bank.
Declaration
public Sound AddSound(string name, AudioClip[] clips)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the sound. |
AudioClip[] | clips | An array of audio clips with audio data. |
Returns
Type | Description |
---|---|
Sound | A reference to a newly created sound. |
AddSoundBus(String)
Adds a new sound bus to the sound bank.
Declaration
public SoundBus AddSoundBus(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the sound bus. |
Returns
Type | Description |
---|---|
SoundBus | A reference to a newly created sound bus. |
GetBankID()
Returns sound bank ID.
Declaration
public ID GetBankID()
Returns
Type | Description |
---|---|
ID | An ID value. |
GetSound(ID)
Searches for the specified sound by ID.
Declaration
public Sound GetSound(ID id)
Parameters
Type | Name | Description |
---|---|---|
ID | id | ID that refers to a sound. |
Returns
Type | Description |
---|---|
Sound | A reference to a sound, if found. Null reference otherwise. |
GetSound(String)
Searches for the specified sound with a matching name.
Declaration
public Sound GetSound(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the sound. |
Returns
Type | Description |
---|---|
Sound | A reference to a sound, if found. Null reference otherwise. |
GetSoundBus(ID)
Searches for the specified sound bus by ID.
Declaration
public SoundBus GetSoundBus(ID id)
Parameters
Type | Name | Description |
---|---|---|
ID | id | ID that refers to a sound bus. |
Returns
Type | Description |
---|---|
SoundBus | A reference to a sound bus, if found. Null reference otherwise. |
GetSoundBus(String)
Searches for the specified sound bus with a matching name.
Declaration
public SoundBus GetSoundBus(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the sound bus. |
Returns
Type | Description |
---|---|
SoundBus | A reference to a sound bus, if found. Null reference otherwise. |
GetSoundBusID(Int32)
Gets an ID to the specific sound bus.
Declaration
public ID GetSoundBusID(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Zero-based index of the sound bus in the current sound bank. |
Returns
Type | Description |
---|---|
ID | An ID to the specific sound bus. |
GetSoundID(Int32)
Gets an ID to the specific sound.
Declaration
public ID GetSoundID(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Zero-based index of the sound in the current sound bank. |
Returns
Type | Description |
---|---|
ID | An ID to the specific sound. |
OnAfterDeserialize()
Prepares sound bank 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 bank for serialization.
Declaration
public void OnBeforeSerialize()
Remarks
This method is automatically called by Unity during serialization process. Don't call it manually.
RegenerateBankID()
Generates a new unique ID for the sound bank.
Declaration
public void RegenerateBankID()
Remarks
This method is automatically called by Stem during serialization process. Don't call it manually as it may break existing ID references.
RemoveSound(Sound)
Removes existing sound from the sound bank.
Declaration
public void RemoveSound(Sound sound)
Parameters
Type | Name | Description |
---|---|---|
Sound | sound | A reference to a sound. |
Remarks
This method does nothing if the sound was not found in the sound bank.
RemoveSoundBus(SoundBus)
Removes existing sound bus from the sound bank.
Declaration
public void RemoveSoundBus(SoundBus bus)
Parameters
Type | Name | Description |
---|---|---|
SoundBus | bus | A reference to a sound bus. |
Remarks
This method does nothing if the sound bus was not found in the sound bank.
Events
| Improve this Doc View SourceOnSoundAdded
The delegate informing about adding sounds.
Declaration
public event SoundAddedDelegate OnSoundAdded
Event Type
Type | Description |
---|---|
SoundAddedDelegate |
OnSoundBusAdded
The delegate informing about adding sound buses.
Declaration
public event SoundBusAddedDelegate OnSoundBusAdded
Event Type
Type | Description |
---|---|
SoundBusAddedDelegate |
OnSoundBusRemoved
The delegate informing about removing sound buses.
Declaration
public event SoundBusRemovedDelegate OnSoundBusRemoved
Event Type
Type | Description |
---|---|
SoundBusRemovedDelegate |
OnSoundBusRenamed
The delegate informing about the change of sound bus names.
Declaration
public event SoundBusRenamedDelegate OnSoundBusRenamed
Event Type
Type | Description |
---|---|
SoundBusRenamedDelegate |
OnSoundRemoved
The delegate informing about removing sounds.
Declaration
public event SoundRemovedDelegate OnSoundRemoved
Event Type
Type | Description |
---|---|
SoundRemovedDelegate |
OnSoundRenamed
The delegate informing about the change of sound names.
Declaration
public event SoundRenamedDelegate OnSoundRenamed
Event Type
Type | Description |
---|---|
SoundRenamedDelegate |