AudioStreamRandomizer
Wraps a pool of audio streams with pitch and volume shifting.
Wraps a pool of audio streams with pitch and volume shifting.
Picks a random AudioStream from the pool, depending on the playback mode, and applies random pitch shifting and volume shifting during playback.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
AudioStreamRandomizerConstructor
public AudioStreamRandomizer();Properties5
PlaybackModeProperty
public AudioStreamRandomizer.PlaybackModeEnum PlaybackMode { get; set; }Controls how this AudioStreamRandomizer picks which AudioStream to play next.
RandomPitchProperty
public float RandomPitch { get; set; }The largest possible frequency multiplier of the random pitch variation. Pitch will be randomly chosen within a range of [code skip-lint]1.0 / random_pitch and [code skip-lint]random_pitch. A value of 1.0 means no variation. A value of 2.0 means pitch will be randomized between double and half.
Note: Setting this property also sets AudioStreamRandomizer.RandomPitchSemitones.
RandomPitchSemitonesProperty
public float RandomPitchSemitones { get; set; }The largest possible distance, in semitones, of the random pitch variation. A value of 0.0 means no variation.
Note: Setting this property also sets AudioStreamRandomizer.RandomPitch.
RandomVolumeOffsetDbProperty
public float RandomVolumeOffsetDb { get; set; }The intensity of random volume variation. Volume will be increased or decreased by a random value up to [code skip-lint]random_volume_offset_db. A value of 0.0means no variation. A value of3.0means volume will be randomized between-3.0 dBand+3.0 dB`.
StreamsCountProperty
public int StreamsCount { get; set; }The number of streams in the stream pool.
Methods17
AddStreamvoid
public void AddStream(int index, AudioStream stream, float weight = 1f);Insert a stream at the specified index. If the index is less than zero, the insertion occurs at the end of the underlying pool.
| Name | Type | Default |
|---|---|---|
index | int | — |
stream | AudioStream | — |
weight | float | 1f |
GetPlaybackModeAudioStreamRandomizer.PlaybackModeEnum
public AudioStreamRandomizer.PlaybackModeEnum GetPlaybackMode();AudioStreamRandomizer.PlaybackModeEnumGetRandomPitchfloat
public float GetRandomPitch();floatGetRandomPitchSemitonesfloat
public float GetRandomPitchSemitones();floatGetRandomVolumeOffsetDbfloat
public float GetRandomVolumeOffsetDb();floatGetStreamAudioStream
public AudioStream GetStream(int index);Returns the stream at the specified index.
| Name | Type | Default |
|---|---|---|
index | int | — |
AudioStreamGetStreamProbabilityWeightfloat
public float GetStreamProbabilityWeight(int index);Returns the probability weight associated with the stream at the given index.
| Name | Type | Default |
|---|---|---|
index | int | — |
floatGetStreamsCountint
public int GetStreamsCount();intMoveStreamvoid
public void MoveStream(int indexFrom, int indexTo);Move a stream from one index to another.
| Name | Type | Default |
|---|---|---|
indexFrom | int | — |
indexTo | int | — |
RemoveStreamvoid
public void RemoveStream(int index);Remove the stream at the specified index.
| Name | Type | Default |
|---|---|---|
index | int | — |
SetPlaybackModevoid
public void SetPlaybackMode(AudioStreamRandomizer.PlaybackModeEnum mode);| Name | Type | Default |
|---|---|---|
mode | AudioStreamRandomizer.PlaybackModeEnum | — |
SetRandomPitchvoid
public void SetRandomPitch(float scale);| Name | Type | Default |
|---|---|---|
scale | float | — |
SetRandomPitchSemitonesvoid
public void SetRandomPitchSemitones(float semitones);| Name | Type | Default |
|---|---|---|
semitones | float | — |
SetRandomVolumeOffsetDbvoid
public void SetRandomVolumeOffsetDb(float dbOffset);| Name | Type | Default |
|---|---|---|
dbOffset | float | — |
SetStreamvoid
public void SetStream(int index, AudioStream stream);Set the AudioStream at the specified index.
| Name | Type | Default |
|---|---|---|
index | int | — |
stream | AudioStream | — |
SetStreamProbabilityWeightvoid
public void SetStreamProbabilityWeight(int index, float weight);Set the probability weight of the stream at the specified index. The higher this value, the more likely that the randomizer will choose this stream during random playback modes.
| Name | Type | Default |
|---|---|---|
index | int | — |
weight | float | — |
SetStreamsCountvoid
public void SetStreamsCount(int count);| Name | Type | Default |
|---|---|---|
count | int | — |
AudioStreamRandomizer.PlaybackModeEnum
| Value | Description |
|---|---|
Random = 1 | Pick a stream at random according to the probability weights chosen for each stream. If only 1 sound is present in the pool, the same sound will always play. |
RandomNoRepeats = 0 | Pick a stream at random according to the probability weights chosen for each stream, but avoid playing the same stream twice in a row whenever possible. If only 1 sound is present in the pool, the same sound will always play, effectively allowing repeats to occur. |
Sequential = 2 | Play streams in the order they appear in the stream pool. If only 1 sound is present in the pool, the same sound will always play. |