SamplePlayer2D¶
Inherits: SoundPlayer2D < Node2D < CanvasItem < Node < Object
Category: Core
Brief Description¶
Sample player for positional 2D Sound.
Member Functions¶
int | get_polyphony ( ) const |
float | get_random_pitch_scale ( ) const |
SampleLibrary | get_sample_library ( ) const |
bool | is_voice_active ( int voice ) const |
int | play ( String sample, int voice=-2 ) |
void | set_polyphony ( int max_voices ) |
void | set_random_pitch_scale ( float val ) |
void | set_sample_library ( SampleLibrary library ) |
void | stop_all ( ) |
void | stop_voice ( int voice ) |
void | voice_set_pitch_scale ( int voice, float ratio ) |
void | voice_set_volume_scale_db ( int voice, float db ) |
Numeric Constants¶
- INVALID_VOICE = -1 — Value returned if the voice or sample are invalid.
- NEXT_VOICE = -2 — Default voice for the play method. Corresponds to the first voice following the last used voice.
Description¶
Sample player for positional 2D Sound. Plays sound samples positionally, left and right depending on the distance/place on the screen.
Member Function Description¶
- int get_polyphony ( ) const
Return the polyphony of the player.
- float get_random_pitch_scale ( ) const
Return the amplitude used for random pitch scale variations.
- SampleLibrary get_sample_library ( ) const
Return the sample library used by the player.
Return whether a voice is still active or has stopped playing.
Play a sample. An internal polyphony ID can optionally be passed, or defaults to NEXT_VOICE.
Return a voice ID which can be used to modify the voice parameters, or INVALID_VOICE if the voice or sample are invalid.
- void set_polyphony ( int max_voices )
Set the polyphony of the player (maximum amount of simultaneous voices).
- void set_random_pitch_scale ( float val )
Set the amplitude for random pitch scale variations. If different from zero, the pitch scale will vary randomly around 1.0 in a range defined by val.
The actual pitch scale will be, with “variation” ranging from -val to val:
* variation > 0: 1.0 + variation
* variation < 0: 1.0/(1.0 - variation)
- void set_sample_library ( SampleLibrary library )
Set the sample library for the player.
- void stop_all ( )
Stop all playing voices.
- void stop_voice ( int voice )
Stop a given voice.
Change the pitch scale of a currently playing voice.
Change the volume scale (in dB) of a currently playing voice.