Class SoundManager
The main class for sound playback and bank management.
Inheritance
Inherited Members
Namespace: Stem
Assembly: Stem.dll
Syntax
public static class SoundManager
Properties
| Improve this Doc View SourceBanks
The collection of all registered sound banks.
Declaration
public static ReadOnlyCollection<SoundBank> Banks { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.ObjectModel.ReadOnlyCollection<SoundBank> | A reference to a read-only collection of sound banks. |
PrimaryBank
The primary sound bank that will be searched first in case of name collisions.
Declaration
public static SoundBank PrimaryBank { get; set; }
Property Value
| Type | Description |
|---|---|
| SoundBank | A reference to a primary sound bank. |
Methods
| Improve this Doc View SourceDeregisterBank(SoundBank)
Deregisters existing sound bank.
Declaration
public static bool DeregisterBank(SoundBank bank)
Parameters
| Type | Name | Description |
|---|---|---|
| SoundBank | bank | A reference to a sound bank to deregister. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True, if sound bank was succesfully deregistered. False otherwise. |
GetSound(ID)
Searches for the specified sound with a matching unique ID.
Declaration
public static Sound GetSound(ID id)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the 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 static 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. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
GetSoundBus(ID)
Searches for the specified sound bus with a matching unique ID.
Declaration
public static SoundBus GetSoundBus(ID id)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the 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 static 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. |
Remarks
If multiple banks have sound buses with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound bus will be used.
GrabSound()
Grabs an empty sound instance from the sound pool. Used for manual playback and custom mixing logic.
Declaration
public static SoundInstance GrabSound()
Returns
| Type | Description |
|---|---|
| SoundInstance | A reference to an empty sound instance. |
Remarks
This method may increase the size of the sound pool causing additional memory allocations.
When a sound instance is not needed anymore, use ReleaseSound(SoundInstance) to return it back to the sound pool.
GrabSound(ID)
Grabs a sound instance from the sound pool. Used for manual playback and custom mixing logic.
Declaration
public static SoundInstance GrabSound(ID id)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
Returns
| Type | Description |
|---|---|
| SoundInstance | A reference to a sound instance. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
This method may increase the size of the sound pool causing additional memory allocations.
When a sound instance is not needed anymore, use ReleaseSound(SoundInstance) to return it back to the sound pool.
GrabSound(String)
Grabs a sound instance from the sound pool. Used for manual playback and custom mixing logic.
Declaration
public static SoundInstance GrabSound(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
Returns
| Type | Description |
|---|---|
| SoundInstance | A reference to a sound instance. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
This method may increase the size of the sound pool causing additional memory allocations.
When a sound instance is not needed anymore, use ReleaseSound(SoundInstance) to return it back to the sound pool.
Pause()
Pauses all playing sounds.
Declaration
public static void Pause()
Remarks
This method will also stop all sounds instances returned from GrabSound() or GrabSound(String).
Play(ID)
Plays one-shot sound.
Declaration
public static void Play(ID id)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
Play(ID, Int32)
Plays specific one-shot sound variation.
Declaration
public static void Play(ID id, int variationIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
Play(ID, Int32, Single)
Plays specific one-shot sound variation.
Declaration
public static void Play(ID id, int variationIndex, float volume)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Play(ID, Int32, Single, Single)
Plays specific one-shot sound variation.
Declaration
public static void Play(ID id, int variationIndex, float volume, float pitch)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Play(ID, Int32, Single, Single, Single)
Plays specific one-shot sound variation.
Declaration
public static void Play(ID id, int variationIndex, float volume, float pitch, float delay)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
| System.Single | delay | Delay of the sound. Value must be greater or equal to zero. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Delay parameter value will override SoundVariation.Delay value.
Play(ID, Single)
Plays one-shot sound.
Declaration
public static void Play(ID id, float volume)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Play(ID, Single, Single)
Plays one-shot sound.
Declaration
public static void Play(ID id, float volume, float pitch)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Play(ID, Single, Single, Single)
Plays one-shot sound.
Declaration
public static void Play(ID id, float volume, float pitch, float delay)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
| System.Single | delay | Delay of the sound. Value must be greater or equal to zero. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Delay parameter value will override SoundVariation.Delay value.
Play(String)
Plays one-shot sound.
Declaration
public static void Play(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Play(String, Int32)
Plays specific one-shot sound variation.
Declaration
public static void Play(string name, int variationIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Play(String, Int32, Single)
Plays specific one-shot sound variation.
Declaration
public static void Play(string name, int variationIndex, float volume)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Play(String, Int32, Single, Single)
Plays specific one-shot sound variation.
Declaration
public static void Play(string name, int variationIndex, float volume, float pitch)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Play(String, Int32, Single, Single, Single)
Plays specific one-shot sound variation.
Declaration
public static void Play(string name, int variationIndex, float volume, float pitch, float delay)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
| System.Single | delay | Delay of the sound. Value must be greater or equal to zero. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Delay parameter value will override SoundVariation.Delay value.
Play(String, Single)
Plays one-shot sound.
Declaration
public static void Play(string name, float volume)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Play(String, Single, Single)
Plays one-shot sound.
Declaration
public static void Play(string name, float volume, float pitch)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Play(String, Single, Single, Single)
Plays one-shot sound.
Declaration
public static void Play(string name, float volume, float pitch, float delay)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
| System.Single | delay | Delay of the sound. Value must be greater or equal to zero. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Delay parameter value will override SoundVariation.Delay value.
Play3D(ID, Vector3)
Plays one-shot sound in 3D space.
Declaration
public static void Play3D(ID id, Vector3 position)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| Vector3 | position | Position of the sound. |
Play3D(ID, Vector3, Int32)
Plays specific one-shot sound variation in 3D space.
Declaration
public static void Play3D(ID id, Vector3 position, int variationIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| Vector3 | position | Position of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
Play3D(ID, Vector3, Int32, Single)
Plays specific one-shot sound variation in 3D space.
Declaration
public static void Play3D(ID id, Vector3 position, int variationIndex, float volume)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| Vector3 | position | Position of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Play3D(ID, Vector3, Int32, Single, Single)
Plays specific one-shot sound variation in 3D space.
Declaration
public static void Play3D(ID id, Vector3 position, int variationIndex, float volume, float pitch)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| Vector3 | position | Position of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Play3D(ID, Vector3, Int32, Single, Single, Single)
Plays specific one-shot sound variation in 3D space.
Declaration
public static void Play3D(ID id, Vector3 position, int variationIndex, float volume, float pitch, float delay)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| Vector3 | position | Position of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
| System.Single | delay | Delay of the sound. Value must be greater or equal to zero. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Delay parameter value will override SoundVariation.Delay value.
Play3D(ID, Vector3, Single)
Plays one-shot sound in 3D space.
Declaration
public static void Play3D(ID id, Vector3 position, float volume)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| Vector3 | position | Position of the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Play3D(ID, Vector3, Single, Single)
Plays one-shot sound in 3D space.
Declaration
public static void Play3D(ID id, Vector3 position, float volume, float pitch)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| Vector3 | position | Position of the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Play3D(ID, Vector3, Single, Single, Single)
Plays one-shot sound in 3D space.
Declaration
public static void Play3D(ID id, Vector3 position, float volume, float pitch, float delay)
Parameters
| Type | Name | Description |
|---|---|---|
| ID | id | ID referring to the sound. |
| Vector3 | position | Position of the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
| System.Single | delay | Delay of the sound. Value must be greater or equal to zero. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Delay parameter value will override SoundVariation.Delay value.
Play3D(String, Vector3)
Plays one-shot sound in 3D space.
Declaration
public static void Play3D(string name, Vector3 position)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| Vector3 | position | Position of the sound. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Play3D(String, Vector3, Int32)
Plays specific one-shot sound variation in 3D space.
Declaration
public static void Play3D(string name, Vector3 position, int variationIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| Vector3 | position | Position of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Play3D(String, Vector3, Int32, Single)
Plays specific one-shot sound variation in 3D space.
Declaration
public static void Play3D(string name, Vector3 position, int variationIndex, float volume)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| Vector3 | position | Position of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Play3D(String, Vector3, Int32, Single, Single)
Plays specific one-shot sound variation in 3D space.
Declaration
public static void Play3D(string name, Vector3 position, int variationIndex, float volume, float pitch)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| Vector3 | position | Position of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Play3D(String, Vector3, Int32, Single, Single, Single)
Plays specific one-shot sound variation in 3D space.
Declaration
public static void Play3D(string name, Vector3 position, int variationIndex, float volume, float pitch, float delay)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| Vector3 | position | Position of the sound. |
| System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
| System.Single | delay | Delay of the sound. Value must be greater or equal to zero. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Delay parameter value will override SoundVariation.Delay value.
Play3D(String, Vector3, Single)
Plays one-shot sound in 3D space.
Declaration
public static void Play3D(string name, Vector3 position, float volume)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| Vector3 | position | Position of the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Play3D(String, Vector3, Single, Single)
Plays one-shot sound in 3D space.
Declaration
public static void Play3D(string name, Vector3 position, float volume, float pitch)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| Vector3 | position | Position of the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Play3D(String, Vector3, Single, Single, Single)
Plays one-shot sound in 3D space.
Declaration
public static void Play3D(string name, Vector3 position, float volume, float pitch, float delay)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the sound. |
| Vector3 | position | Position of the sound. |
| System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
| System.Single | pitch | Pitch of the sound. Value must be in [-3;3] range. |
| System.Single | delay | Delay of the sound. Value must be greater or equal to zero. |
Remarks
If multiple banks have sounds with a matching name, the primary sound bank will be checked first. Within a bank, the first occurrence of found sound will be used.
Volume parameter value will override SoundVariation.Volume value.
Pitch parameter value will override SoundVariation.Pitch value.
Delay parameter value will override SoundVariation.Delay value.
RegisterBank(SoundBank)
Registers new sound bank.
Declaration
public static bool RegisterBank(SoundBank bank)
Parameters
| Type | Name | Description |
|---|---|---|
| SoundBank | bank | A reference to a sound bank to register. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True, if sound bank was succesfully registered. False otherwise. |
ReleaseSound(SoundInstance)
Releases sound instance and return it back to the sound pool.
Declaration
public static bool ReleaseSound(SoundInstance instance)
Parameters
| Type | Name | Description |
|---|---|---|
| SoundInstance | instance | A reference to a sound instance. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True, if the sound instance was successfully returned to sound pool. False otherwise. |
Remarks
Once the sound instance is returned back to a sound pool, it's possible to reuse it again by calling GrabSound() or GrabSound(String).
Stop()
Stops all playing sounds.
Declaration
public static void Stop()
Remarks
This method will also stop all sounds instances returned from GrabSound() or GrabSound(String).
UnPause()
Resumes all paused sounds.
Declaration
public static void UnPause()
Remarks
This method will also resume all sounds instances returned from GrabSound() or GrabSound(String).