AudioStreamRandomizer

继承: AudioStream < Resource < RefCounted < Object

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.

属性

方法

voidadd_stream ( index: int, stream: AudioStream, weight: float = 1.0 )
AudioStreamget_stream ( index: int ) const1
floatget_stream_probability_weight ( index: int ) const1
voidmove_stream ( index_from: int, index_to: int )
voidremove_stream ( index: int )
voidset_stream ( index: int, stream: AudioStream )
voidset_stream_probability_weight ( index: int, weight: float )

枚举

enum PlaybackMode:

PlaybackMode PLAYBACK_RANDOM_NO_REPEATS = 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.

PlaybackMode PLAYBACK_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.

PlaybackMode PLAYBACK_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.


属性说明

PlaybackMode playback_mode = 0

Controls how this AudioStreamRandomizer picks which AudioStream to play next.


float random_pitch = 1.0

  • void set_random_pitch ( value: float )
  • float get_random_pitch ( )

The intensity of random pitch variation. A value of 1 means no variation.


float random_volume_offset_db = 0.0

  • void set_random_volume_offset_db ( value: float )
  • float get_random_volume_offset_db ( )

The intensity of random volume variation. A value of 0 means no variation.


int streams_count = 0

  • void set_streams_count ( value: int )
  • int get_streams_count ( )

The number of streams in the stream pool.


方法说明

void add_stream ( index: int, stream: AudioStream, weight: float = 1.0 )

Insert a stream at the specified index. If the index is less than zero, the insertion occurs at the end of the underlying pool.


AudioStream get_stream ( index: int ) const1

Returns the stream at the specified index.


float get_stream_probability_weight ( index: int ) const1

Returns the probability weight associated with the stream at the given index.


void move_stream ( index_from: int, index_to: int )

Move a stream from one index to another.


void remove_stream ( index: int )

Remove the stream at the specified index.


void set_stream ( index: int, stream: AudioStream )

Set the AudioStream at the specified index.


void set_stream_probability_weight ( index: int, weight: float )

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.

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。