AudioStreamPlayer3D
Plays 3D sound in 3D space.
Plays a sound effect with directed sound effects, dampens with distance if needed, generates effect of hearable position in space. For greater realism, a low-pass filter is automatically applied to distant sounds. This can be disabled by setting to .
By default, audio is heard from the camera position. This can be changed by adding a Listener node to the scene and enabling it by calling on it.
Tutorials
Methods
get_playback_position ( ) | |
get_stream_playback ( ) | |
void | ( float from_position=0.0 ) |
void | ( float to_position ) |
void | ( ) |
- finished ( )
Emitted when the audio stops playing.
Enumerations
enum AttenuationModel:
- ATTENUATION_INVERSE_DISTANCE = 0 —- Linear dampening of loudness according to distance.
- ATTENUATION_INVERSE_SQUARE_DISTANCE = 1 —- Squared dampening of loudness according to distance.
- ATTENUATION_LOGARITHMIC = 2 —- Logarithmic dampening of loudness according to distance.
enum OutOfRangeMode:
- OUT_OF_RANGE_MIX = 0 —- Mix this audio in, even when it’s out of range. This increases CPU usage, but keeps the sound playing at the correct position if the camera leaves and enters the
AudioStreamPlayer3D
‘s max_distance radius. - OUT_OF_RANGE_PAUSE = 1 —- Pause this audio when it gets out of range. This decreases CPU usage, but will cause the sound to restart if the camera leaves and enters the
AudioStreamPlayer3D
‘s radius.
enum DopplerTracking:
- DOPPLER_TRACKING_DISABLED = 0 —- Disables doppler tracking.
- DOPPLER_TRACKING_IDLE_STEP = 1 —- Executes doppler tracking in idle step.
- DOPPLER_TRACKING_PHYSICS_STEP = 2 —- Executes doppler tracking in physics step.
- int area_mask
Default | 1 |
Setter | set_area_mask(value) |
Getter | get_area_mask() |
Areas in which this sound plays.
- attenuation_filter_cutoff_hz
Default | 5000.0 |
Setter | set_attenuation_filter_cutoff_hz(value) |
Getter | get_attenuation_filter_cutoff_hz() |
Dampens audio using a low-pass filter above this frequency, in Hz. To disable the dampening effect entirely, set this to 20500
as this frequency is above the human hearing limit.
- float attenuation_filter_db
Default | -24.0 |
Setter | set_attenuation_filter_db(value) |
Getter | get_attenuation_filter_db() |
- attenuation_model
Default | 0 |
Setter | set_attenuation_model(value) |
Getter | get_attenuation_model() |
Decides if audio should get quieter with distance linearly, quadratically, logarithmically, or not be affected by distance, effectively disabling attenuation.
- bool autoplay
Default | false |
Setter | set_autoplay(value) |
Getter | is_autoplay_enabled() |
If true
, audio plays when the AudioStreamPlayer3D node is added to scene tree.
- bus
The bus on which this audio is playing.
- DopplerTracking doppler_tracking
Default | 0 |
Setter | set_doppler_tracking(value) |
Getter | get_doppler_tracking() |
Decides in which step the Doppler effect should be calculated.
- emission_angle_degrees
Default | |
Setter | set_emission_angle(value) |
Getter | get_emission_angle() |
The angle in which the audio reaches cameras undampened.
Default | false |
Setter | set_emission_angle_enabled(value) |
Getter | is_emission_angle_enabled() |
If true
, the audio should be dampened according to the direction of the sound.
- float emission_angle_filter_attenuation_db
Default | -12.0 |
Setter | set_emission_angle_filter_attenuation_db(value) |
Getter | get_emission_angle_filter_attenuation_db() |
Dampens audio if camera is outside of and emission_angle_enabled is set by this factor, in decibels.
- max_db
Default | 3.0 |
Setter | set_max_db(value) |
Getter | get_max_db() |
Sets the absolute maximum of the soundlevel, in decibels.
- float max_distance
Default | 0.0 |
Setter | set_max_distance(value) |
Getter | get_max_distance() |
Sets the distance from which the takes effect. Has no effect if set to 0.
- OutOfRangeMode out_of_range_mode
- pitch_scale
Default | 1.0 |
Setter | set_pitch_scale(value) |
Getter | get_pitch_scale() |
The pitch and the tempo of the audio, as a multiplier of the audio sample’s sample rate.
- bool playing
Default | false |
Getter | is_playing() |
If true
, audio is playing.
- stream
Setter | set_stream(value) |
Getter | get_stream() |
The AudioStream resource to be played.
- stream_paused
Default | false |
Setter | set_stream_paused(value) |
Getter | get_stream_paused() |
If true
, the playback is paused. You can resume it by setting stream_paused to false
.
- unit_db
Default | 0.0 |
Setter | set_unit_db(value) |
Getter | get_unit_db() |
The base sound level unaffected by dampening, in decibels.
- float unit_size
Default | 1.0 |
Setter | set_unit_size(value) |
Getter | get_unit_size() |
The factor for the attenuation effect. Higher values make the sound audible over a larger distance.
Method Descriptions
- get_playback_position ( )
Returns the position in the AudioStream.
- get_stream_playback ( )
Returns the AudioStreamPlayback object associated with this .
- void play ( from_position=0.0 )
Plays the audio from the given position from_position
, in seconds.
- void stop ( )
Stops the audio.