Class SoundInstance
The game object with audio source component. Used for manual playback and custom mixing logic.
Inheritance
Inherited Members
Namespace: Stem
Assembly: Stem.dll
Syntax
public class SoundInstance
Properties
| Improve this Doc View SourceLooped
The flag indicating that the sound instance is looping. Set whether it should replay the audio clip after it finishes.
Declaration
public bool Looped { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if sound instance is looping. False otherwise. |
Paused
The flag indicating that the sound instance is paused.
Declaration
public bool Paused { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if sound instance is paused. False otherwise. |
Pitch
The pitch property allows controlling how high or low the tone of the audio source is.
Declaration
public float Pitch { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Pitch value in [3;3] range. |
Playing
The flag indicating that the sound instance is playing.
Declaration
public bool Playing { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if sound instance is playing. False otherwise. |
Position
The position of the sound instance in world space.
Declaration
public Vector3 Position { get; set; }
Property Value
Type | Description |
---|---|
Vector3 | A world space coordinates of the sound instance. |
Remarks
Non-null Target will override this property value.
Sound
The reference to a sound which will be used for playback. Changing this value allows playing different sounds.
Declaration
public Sound Sound { get; set; }
Property Value
Type | Description |
---|---|
Sound | A reference to a sound. |
Target
The transform component to which sound instance is attached.
Declaration
public Transform Target { get; set; }
Property Value
Type | Description |
---|---|
Transform | A reference a transform component. |
Remarks
Once set, it will override Position property value.
TimeSamples
The playback position in samples.
Declaration
public int TimeSamples { get; }
Property Value
Type | Description |
---|---|
System.Int32 | An offset in samples from the start of an audio clip. |
Volume
The volume property allows controlling the overall level of sound coming to the audio source.
Declaration
public float Volume { get; set; }
Property Value
Type | Description |
---|---|
System.Single | Volume value in [0;1] range. |
Methods
| Improve this Doc View SourcePause()
Pauses sound.
Declaration
public void Pause()
Play()
Plays sound.
Declaration
public void Play()
Play(Int32)
Plays specific sound variation.
Declaration
public void Play(int variationIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
Play(Int32, Single)
Plays specific sound variation.
Declaration
public void Play(int variationIndex, float volume)
Parameters
Type | Name | Description |
---|---|---|
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(Int32, Single, Single)
Plays specific sound variation.
Declaration
public void Play(int variationIndex, float volume, float pitch)
Parameters
Type | Name | Description |
---|---|---|
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(Int32, Single, Single, Single)
Plays specific sound variation.
Declaration
public void Play(int variationIndex, float volume, float pitch, float delay)
Parameters
Type | Name | Description |
---|---|---|
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(Single)
Plays sound.
Declaration
public void Play(float volume)
Parameters
Type | Name | Description |
---|---|---|
System.Single | volume | Volume of the sound. Value must be in [0;1] range. |
Remarks
Volume parameter value will override SoundVariation.Volume value.
Play(Single, Single)
Plays sound.
Declaration
public void Play(float volume, float pitch)
Parameters
Type | Name | Description |
---|---|---|
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(Single, Single, Single)
Plays sound.
Declaration
public void Play(float volume, float pitch, float delay)
Parameters
Type | Name | Description |
---|---|---|
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(Vector3)
Plays sound in 3D space.
Declaration
public void Play3D(Vector3 position)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | Position of the sound. |
Play3D(Vector3, Int32)
Plays specific sound variation in 3D space.
Declaration
public void Play3D(Vector3 position, int variationIndex)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | Position of the sound. |
System.Int32 | variationIndex | Variation index. Must be within Variations bounds. |
Play3D(Vector3, Int32, Single)
Plays specific sound variation in 3D space.
Declaration
public void Play3D(Vector3 position, int variationIndex, float volume)
Parameters
Type | Name | Description |
---|---|---|
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(Vector3, Int32, Single, Single)
Plays specific sound variation in 3D space.
Declaration
public void Play3D(Vector3 position, int variationIndex, float volume, float pitch)
Parameters
Type | Name | Description |
---|---|---|
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(Vector3, Int32, Single, Single, Single)
Plays specific sound variation in 3D space.
Declaration
public void Play3D(Vector3 position, int variationIndex, float volume, float pitch, float delay)
Parameters
Type | Name | Description |
---|---|---|
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(Vector3, Single)
Plays sound in 3D space.
Declaration
public void Play3D(Vector3 position, float volume)
Parameters
Type | Name | Description |
---|---|---|
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(Vector3, Single, Single)
Plays sound in 3D space.
Declaration
public void Play3D(Vector3 position, float volume, float pitch)
Parameters
Type | Name | Description |
---|---|---|
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(Vector3, Single, Single, Single)
Plays sound in 3D space.
Declaration
public void Play3D(Vector3 position, float volume, float pitch, float delay)
Parameters
Type | Name | Description |
---|---|---|
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.
Stop()
Stops sound.
Declaration
public void Stop()
UnPause()
Resumes sound.
Declaration
public void UnPause()