SamplePlayer

Inherits: Node < Object

Category: Core

Brief Description

Sample Player node.

Member Functions

float get_chorus ( int voice ) const
float get_default_chorus ( ) const
float get_default_filter_cutoff ( ) const
float get_default_filter_gain ( ) const
float get_default_filter_resonance ( ) const
int get_default_filter_type ( ) const
float get_default_pan ( ) const
float get_default_pan_depth ( ) const
float get_default_pan_height ( ) const
float get_default_pitch_scale ( ) const
float get_default_reverb ( ) const
int get_default_reverb_room ( ) const
float get_default_volume ( ) const
float get_default_volume_db ( ) const
float get_filter_cutoff ( int voice ) const
float get_filter_gain ( int voice ) const
float get_filter_resonance ( int voice ) const
int get_filter_type ( int voice ) const
int get_mix_rate ( int voice ) const
float get_pan ( int voice ) const
float get_pan_depth ( int voice ) const
float get_pan_height ( int voice ) const
float get_pitch_scale ( int voice ) const
int get_polyphony ( ) const
float get_reverb ( int voice ) const
int get_reverb_room ( int voice ) const
SampleLibrary get_sample_library ( ) const
float get_volume ( int voice ) const
float get_volume_db ( int voice ) const
bool is_active ( ) const
bool is_voice_active ( int voice ) const
int play ( String name, bool unique=false )
void set_chorus ( int voice, float send )
void set_default_chorus ( float send )
void set_default_filter ( int type, float cutoff_hz, float resonance, float gain=0 )
void set_default_pan ( float pan, float depth=0, float height=0 )
void set_default_pitch_scale ( float ratio )
void set_default_reverb ( int room_type, float send )
void set_default_volume ( float volume )
void set_default_volume_db ( float db )
void set_filter ( int voice, int type, float cutoff_hz, float resonance, float gain=0 )
void set_mix_rate ( int voice, int hz )
void set_pan ( int voice, float pan, float depth=0, float height=0 )
void set_pitch_scale ( int voice, float ratio )
void set_polyphony ( int max_voices )
void set_reverb ( int voice, int room_type, float send )
void set_sample_library ( SampleLibrary library )
void set_volume ( int voice, float volume )
void set_volume_db ( int voice, float db )
void stop ( int voice )
void stop_all ( )

Numeric Constants

  • FILTER_NONE = 0 — Filter is disabled for voice.
  • FILTER_LOWPASS = 1 — Low-pass filter is used for voice.
  • FILTER_BANDPASS = 2 — Band-pass filter is used for voice.
  • FILTER_HIPASS = 3 — High-pass filter is used for voice.
  • FILTER_NOTCH = 4 — Notch (band reject) filter is used for voice.
  • FILTER_PEAK = 5 — Peak (exclusive band) filter is used for voice.
  • FILTER_BANDLIMIT = 6 — Band-limit filter is used for voice, in this case resonance is the high-pass cutoff. A band-limit filter has a different frequency response than a notch filter, but otherwise both are band-rejecting filters.
  • FILTER_LOW_SHELF = 7 — Low-shelf filter is used for voice.
  • FILTER_HIGH_SHELF = 8 — High-shelf filter is used for voice.
  • REVERB_SMALL = 0 — Small reverberation room (house room).
  • REVERB_MEDIUM = 1 — Medium reverberation room (street)
  • REVERB_LARGE = 2 — Large reverberation room (theatre)
  • REVERB_HALL = 3 — Huge reverberation room (cathedral, warehouse).
  • INVALID_VOICE_ID = -1 — Value returned if the voice ID is invalid.

Description

SamplePlayer is a Node meant for simple sample playback. A library of samples is loaded and played back “as is”, without positioning or anything.

Member Function Description

float get_chorus ( int voice ) const

Return the current chorus send level for a given voice.

float get_default_chorus ( ) const

Return the default chorus send level of the player.

float get_default_filter_cutoff ( ) const

Return the default filter cutoff frequency of the player.

float get_default_filter_gain ( ) const

Return the default filter gain of the player.

float get_default_filter_resonance ( ) const

Return the default filter resonance of the player.

int get_default_filter_type ( ) const

Return the default filter type in use (see FILTER_* constants) for the player.

float get_default_pan ( ) const

Return the default panning of the player.

float get_default_pan_depth ( ) const

Return the default pan depth of the player.

float get_default_pan_height ( ) const

Return the default pan height of the player.

float get_default_pitch_scale ( ) const

Return the default pitch scale of the player.

float get_default_reverb ( ) const

Return the default reverberation send level of the player.

int get_default_reverb_room ( ) const

Return the default reverberation room type of the player (see REVERB_* enum).

float get_default_volume ( ) const

Return the default volume (on a linear scale) of the player.

float get_default_volume_db ( ) const

Return the default volume (in dB) of the player.

float get_filter_cutoff ( int voice ) const

Return the current filter cutoff frequency for a given voice.

float get_filter_gain ( int voice ) const

Return the current filter gain for a given voice.

float get_filter_resonance ( int voice ) const

Return the current filter resonance for a given voice.

int get_filter_type ( int voice ) const

Return the current filter type in use (see FILTER_* constants) for a given voice.

int get_mix_rate ( int voice ) const

Return the current mix rate for a given voice.

float get_pan ( int voice ) const

Return the current panning for a given voice.

float get_pan_depth ( int voice ) const

Return the current pan depth for a given voice.

float get_pan_height ( int voice ) const

Return the current pan height for a given voice.

float get_pitch_scale ( int voice ) const

Return the current pitch scale for a given voice.

int get_polyphony ( ) const

Return the polyphony of the player.

float get_reverb ( int voice ) const

Return the current reverberation send level for a given voice.

int get_reverb_room ( int voice ) const

Return the current reverberation room type for a given voice (see REVERB_* enum).

SampleLibrary get_sample_library ( ) const

Return the sample library used by the player.

float get_volume ( int voice ) const

Return the current volume (on a linear scale) for a given voice.

float get_volume_db ( int voice ) const

Return the current volume (in dB) for a given voice.

bool is_active ( ) const

Return whether the player is currently active.

bool is_voice_active ( int voice ) const

Return whether the given voice is currently active.

int play ( String name, bool unique=false )

Play a sample referenced by its name.

Optionally, the playback can be made “unique” to force stopping all other samples currently played. The voices allocated for playback will then be returned.

void set_chorus ( int voice, float send )

Set the chorus send level of a voice (from 0 to 1.0). For setting chorus parameters, see AudioServer.

void set_default_chorus ( float send )

Set the default chorus send level of the player (from 0 to 1.0). For setting chorus parameters, see AudioServer.

void set_default_filter ( int type, float cutoff_hz, float resonance, float gain=0 )

Set the default filter for the player, using the given type (see FILTER_* constants), cutoff frequency (from 20 to 16,384 Hz) and resonance (from 0 to 4.0).

Optionally, a gain can also be given (from 0 to 2.0).

void set_default_pan ( float pan, float depth=0, float height=0 )

Set the default panning of the player. Panning goes from -1.0 (left) to +1.0 (right).

Optionally, for hardware than support 3D sound, one can also set depth and height (also in range -1.0 to +1.0).

void set_default_pitch_scale ( float ratio )

Set the default pitch scale of the player. A ratio of 1.0 is the normal scale.

void set_default_reverb ( int room_type, float send )

Set the default reverberation type (see REVERB_* constants) and send level (from 0 to 1.0) of the player.

void set_default_volume ( float volume )

Set the default volume of the player using a linear scale.

The “volume” argument should be a positive factor ranging from 0.0 (mute) up to 16.0 (i.e. 24 dB).

A factor of 1.0 means that the voice will be played at normal system volume. Factors above 1.0 might be limited by the platform’s audio output.

void set_default_volume_db ( float db )

Set the default volume of the player in dB.

The “dB” argument can range from -80 to 24 dB, 0 dB being the maximum volume. Every 6 dB (resp. -6 dB), the volume is increased (resp. reduced) by half.

void set_filter ( int voice, int type, float cutoff_hz, float resonance, float gain=0 )

Set the filter for a given voice, using the given type (see FILTER_* constants), cutoff frequency (from 20 to 16,384 Hz) and resonance (from 0 to 4.0).

Optionally, a gain can also be given (from 0 to 2.0).

void set_mix_rate ( int voice, int hz )

Set the mix rate (in Hz) of a given voice.

void set_pan ( int voice, float pan, float depth=0, float height=0 )

Set the panning of a voice. Panning goes from -1.0 (left) to +1.0 (right).

Optionally, for hardware than support 3D sound, one can also set depth and height (also in range -1.0 to +1.0).

void set_pitch_scale ( int voice, float ratio )

Set the pitch scale of a given voice. A ratio of 1.0 is the normal scale.

void set_polyphony ( int max_voices )

Set the polyphony of the player (maximum amount of simultaneous voices).

void set_reverb ( int voice, int room_type, float send )

Set the reverberation type (see REVERB_* constants) and send level (from 0 to 1.0) of a voice.

void set_sample_library ( SampleLibrary library )

Set the sample library for the player.

void set_volume ( int voice, float volume )

Set the volume of a given voice using a linear scale.

The “volume” argument should be a positive factor ranging from 0.0 (mute) up to 16.0 (i.e. 24 dB).

A factor of 1.0 means that the voice will be played at normal system volume. Factors above 1.0 might be limited by the platform’s audio output.

void set_volume_db ( int voice, float db )

Set the volume of a given voice in dB.

The “dB” argument can range from -80 to 24 dB, 0 dB being the maximum volume. Every 6 dB (resp. -6 dB), the volume is increased (resp. reduced) by half.

void stop ( int voice )

Stop a given voice.

void stop_all ( )

Stop all playing voices.

© 2014–2020 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
https://docs.godotengine.org/en/2.1/classes/class_sampleplayer.html