reckfellENGINE

AudioStreamPlayer3D

A sound source with direction and attenuation in a 3D world.

On this page
class AudioStreamPlayer3DReckfellSharpInherits Entity3D

AudioStreamPlayer3D calculates sound relative to an active 3D listener. AudioListener3D can separate the listening point from the camera. The viewport must have 3D listening enabled.

The attenuation model and UnitSize determine level changes with distance. A positive MaxDistance additionally limits range. These parameters do not resize objects. Wall occlusion needs separate logic: collisions do not automatically muffle sound. Spatial updates run during physics steps.

Working example.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

AudioStreamPlayer3DConstructor
# AudioStreamPlayer3D
C#
public AudioStreamPlayer3D();

Properties22

AreaMaskProperty
# AreaMask
C#
public uint AreaMask { get; set; }

Determines which Area3D layers affect the sound for reverb and audio bus effects. Areas can be used to redirect AudioStreams so that they play in a certain audio bus. An example of how you might use this is making a "water" area so that sounds played in the water are redirected through an audio bus to make them sound like they are being played underwater.

AttenuationFilterCutoffHzProperty
# AttenuationFilterCutoffHz
C#
public float AttenuationFilterCutoffHz { get; set; }

The cutoff frequency of the attenuation low-pass filter, in Hz. A sound above this frequency is attenuated more than a sound below this frequency. To disable this effect, set this to 20500 as this frequency is above the human hearing limit.

AttenuationFilterDbProperty
# AttenuationFilterDb
C#
public float AttenuationFilterDb { get; set; }

Amount how much the filter affects the loudness, in decibels.

AttenuationModelProperty
# AttenuationModel
C#
public AudioStreamPlayer3D.AttenuationModelEnum AttenuationModel { get; set; }

Decides if audio should get quieter with distance linearly, quadratically, logarithmically, or not be affected by distance, effectively disabling attenuation.

AutoplayProperty
# Autoplay
C#
public bool Autoplay { get; set; }

If true, audio plays when the AudioStreamPlayer3D node is added to scene tree.

BusProperty
# Bus
C#
public StringName Bus { get; set; }

The bus on which this audio is playing. Note: When setting this property, keep in mind that no validation is performed to see if the given name matches an existing bus. This is because audio bus layouts might be loaded after this property is set. If this given name can't be resolved at runtime, it will fall back to "Master".

DopplerTrackingProperty
# DopplerTracking
C#
public AudioStreamPlayer3D.DopplerTrackingEnum DopplerTracking { get; set; }

Decides in which step the Doppler effect should be calculated. Note: If AudioStreamPlayer3D.DopplerTracking is not AudioStreamPlayer3D.DopplerTrackingEnum.Disabled but the current Camera3D/AudioListener3D has doppler tracking disabled, the Doppler effect will be heard but will not take the movement of the current listener into account. If accurate Doppler effect is desired, doppler tracking should be enabled on both the AudioStreamPlayer3D and the current Camera3D/AudioListener3D.

EmissionAngleDegreesProperty
# EmissionAngleDegrees
C#
public float EmissionAngleDegrees { get; set; }

The angle in which the audio reaches a listener unattenuated.

EmissionAngleEnabledProperty
# EmissionAngleEnabled
C#
public bool EmissionAngleEnabled { get; set; }

If true, the audio should be attenuated according to the direction of the sound.

EmissionAngleFilterAttenuationDbProperty
# EmissionAngleFilterAttenuationDb
C#
public float EmissionAngleFilterAttenuationDb { get; set; }

Attenuation factor used if listener is outside of AudioStreamPlayer3D.EmissionAngleDegrees and AudioStreamPlayer3D.EmissionAngleEnabled is set, in decibels.

MaxDbProperty
# MaxDb
C#
public float MaxDb { get; set; }

Sets the absolute maximum of the sound level, in decibels.

MaxDistanceProperty
# MaxDistance
C#
public float MaxDistance { get; set; }

The distance past which the sound can no longer be heard at all. Only has an effect if set to a value greater than 0.0. AudioStreamPlayer3D.MaxDistance works in tandem with AudioStreamPlayer3D.UnitSize. However, unlike AudioStreamPlayer3D.UnitSize whose behavior depends on the AudioStreamPlayer3D.AttenuationModel, AudioStreamPlayer3D.MaxDistance always works in a linear fashion. This can be used to prevent the AudioStreamPlayer3D from requiring audio mixing when the listener is far away, which saves CPU resources.

MaxPolyphonyProperty
# MaxPolyphony
C#
public int MaxPolyphony { get; set; }

Maximum simultaneous voices in this player. A new Play exceeding the limit replaces the oldest voice. Use a positive value; choose 1 for a single controlled music stream.

PanningStrengthProperty
# PanningStrength
C#
public float PanningStrength { get; set; }

Scales the panning strength for this node by multiplying the base ProjectSettings.audio/general/3d_panning_strength by this factor. If the product is 0.0 then stereo panning is disabled and the volume is the same for all channels. If the product is 1.0 then one of the channels will be muted when the sound is located exactly to the left (or right) of the listener. Two speaker stereo arrangements implement the WebAudio standard for StereoPannerNode Panning where the volume is cosine of half the azimuth angle to the ear. For other speaker arrangements such as the 5.1 and 7.1 the SPCAP (Speaker-Placement Correction Amplitude) algorithm is implemented.

PitchScaleProperty
# PitchScale
C#
public float PitchScale { get; set; }

The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.

PlaybackTypeProperty
# PlaybackType
C#
public AudioServer.PlaybackType PlaybackType { get; set; }

The playback type of the stream player. If set other than to the default value, it will force that playback type.

PlayingProperty
# Playing
C#
public bool Playing { get; set; }

If true, audio is playing or is queued to be played (see AudioStreamPlayer3D.Play).

StreamProperty
# Stream
C#
public AudioStream Stream { get; set; }

The AudioStream resource to be played.

StreamPausedProperty
# StreamPaused
C#
public bool StreamPaused { get; set; }

Pauses or resumes existing voices. A pending pause is not retained when no voices exist. In Stream mode, pausing makes IsPlaying() false while HasStreamPlayback() remains true.

UnitSizeProperty
# UnitSize
C#
public float UnitSize { get; set; }

The factor for the attenuation effect. Higher values make the sound audible over a larger distance.

VolumeDbProperty
# VolumeDb
C#
public float VolumeDb { get; set; }

The base sound level before attenuation, in decibels.

VolumeLinearProperty
# VolumeLinear
C#
public float VolumeLinear { get; set; }

The base sound level before attenuation, as a linear value. Note: This member modifies AudioStreamPlayer3D.VolumeDb for convenience. The returned value is equivalent to the result of @GlobalScope.db_to_linear on AudioStreamPlayer3D.VolumeDb. Setting this member is equivalent to setting AudioStreamPlayer3D.VolumeDb to the result of @GlobalScope.linear_to_db on a value.

Methods50

GetAreaMaskuint
# GetAreaMask
C#
public uint GetAreaMask();
Returns uint
GetAttenuationFilterCutoffHzfloat
# GetAttenuationFilterCutoffHz
C#
public float GetAttenuationFilterCutoffHz();
Returns float
GetAttenuationFilterDbfloat
# GetAttenuationFilterDb
C#
public float GetAttenuationFilterDb();
Returns float
GetAttenuationModelAudioStreamPlayer3D.AttenuationModelEnum
# GetAttenuationModel
C#
public AudioStreamPlayer3D.AttenuationModelEnum GetAttenuationModel();
Returns AudioStreamPlayer3D.AttenuationModelEnum
GetBusStringName
# GetBus
C#
public StringName GetBus();
Returns StringName
GetDopplerTrackingAudioStreamPlayer3D.DopplerTrackingEnum
# GetDopplerTracking
C#
public AudioStreamPlayer3D.DopplerTrackingEnum GetDopplerTracking();
Returns AudioStreamPlayer3D.DopplerTrackingEnum
GetEmissionAnglefloat
# GetEmissionAngle
C#
public float GetEmissionAngle();
Returns float
GetEmissionAngleFilterAttenuationDbfloat
# GetEmissionAngleFilterAttenuationDb
C#
public float GetEmissionAngleFilterAttenuationDb();
Returns float
GetMaxDbfloat
# GetMaxDb
C#
public float GetMaxDb();
Returns float
GetMaxDistancefloat
# GetMaxDistance
C#
public float GetMaxDistance();
Returns float
GetMaxPolyphonyint
# GetMaxPolyphony
C#
public int GetMaxPolyphony();
Returns int
GetPanningStrengthfloat
# GetPanningStrength
C#
public float GetPanningStrength();
Returns float
GetPitchScalefloat
# GetPitchScale
C#
public float GetPitchScale();
Returns float
GetPlaybackPositionfloat
# GetPlaybackPosition
C#
public float GetPlaybackPosition();

Returns the most recently created voice's position in seconds, not the combined time of all voices. It can advance in steps between mixes. For a single stream at speed 1, time since the last mix can refine an estimate; handle pause, seeking and output latency separately.

Returns float
GetPlaybackTypeAudioServer.PlaybackType
# GetPlaybackType
C#
public AudioServer.PlaybackType GetPlaybackType();
Returns AudioServer.PlaybackType
GetStreamAudioStream
# GetStream
C#
public AudioStream GetStream();
Returns AudioStream
GetStreamPausedbool
# GetStreamPaused
C#
public bool GetStreamPaused();
Returns bool
GetStreamPlaybackAudioStreamPlayback
# GetStreamPlayback
C#
public AudioStreamPlayback GetStreamPlayback();

Returns the AudioStreamPlayback object associated with this AudioStreamPlayer3D.

Returns AudioStreamPlayback
GetUnitSizefloat
# GetUnitSize
C#
public float GetUnitSize();
Returns float
GetVolumeDbfloat
# GetVolumeDb
C#
public float GetVolumeDb();
Returns float
GetVolumeLinearfloat
# GetVolumeLinear
C#
public float GetVolumeLinear();
Returns float
HasStreamPlaybackbool
# HasStreamPlayback
C#
public bool HasStreamPlayback();

Checks whether the player retains playback objects, including paused ones. This does not prove audible output: mute, distance or pause can produce silence.

Returns bool
IsAutoplayEnabledbool
# IsAutoplayEnabled
C#
public bool IsAutoplayEnabled();
Returns bool
IsEmissionAngleEnabledbool
# IsEmissionAngleEnabled
C#
public bool IsEmissionAngleEnabled();
Returns bool
IsPlayingbool
# IsPlaying
C#
public bool IsPlaying();

In Stream mode, returns true for an actively playing voice. Returns false while paused; use HasStreamPlayback() or StreamPaused to detect retained playback. Do not reject a resume command using this method.

Returns bool
Playvoid
# Play
C#
public void Play(float fromPosition = 0f);

Queues the audio to play on the next physics frame, from the given position from_position, in seconds.

Parameters
NameTypeDefault
fromPositionfloat0f
Seekvoid
# Seek
C#
public void Seek(float toPosition);

Restarts the player at a position in seconds only while actively playing. Stops previous voices and starts a new one at the position. In Stream mode it does nothing while paused or stopped. To seek while retaining pause, save the flag, call Stop(), Play(position), then restore StreamPaused.

Parameters
NameTypeDefault
toPositionfloat—
SetAreaMaskvoid
# SetAreaMask
C#
public void SetAreaMask(uint mask);
Parameters
NameTypeDefault
maskuint—
SetAttenuationFilterCutoffHzvoid
# SetAttenuationFilterCutoffHz
C#
public void SetAttenuationFilterCutoffHz(float degrees);
Parameters
NameTypeDefault
degreesfloat—
SetAttenuationFilterDbvoid
# SetAttenuationFilterDb
C#
public void SetAttenuationFilterDb(float db);
Parameters
NameTypeDefault
dbfloat—
SetAttenuationModelvoid
# SetAttenuationModel
C#
public void SetAttenuationModel(AudioStreamPlayer3D.AttenuationModelEnum model);
Parameters
NameTypeDefault
modelAudioStreamPlayer3D.AttenuationModelEnum—
SetAutoplayvoid
# SetAutoplay
C#
public void SetAutoplay(bool enable);
Parameters
NameTypeDefault
enablebool—
SetBusvoid
# SetBus
C#
public void SetBus(StringName bus);
Parameters
NameTypeDefault
busStringName—
SetDopplerTrackingvoid
# SetDopplerTracking
C#
public void SetDopplerTracking(AudioStreamPlayer3D.DopplerTrackingEnum mode);
Parameters
NameTypeDefault
modeAudioStreamPlayer3D.DopplerTrackingEnum—
SetEmissionAnglevoid
# SetEmissionAngle
C#
public void SetEmissionAngle(float degrees);
Parameters
NameTypeDefault
degreesfloat—
SetEmissionAngleEnabledvoid
# SetEmissionAngleEnabled
C#
public void SetEmissionAngleEnabled(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetEmissionAngleFilterAttenuationDbvoid
# SetEmissionAngleFilterAttenuationDb
C#
public void SetEmissionAngleFilterAttenuationDb(float db);
Parameters
NameTypeDefault
dbfloat—
SetMaxDbvoid
# SetMaxDb
C#
public void SetMaxDb(float maxDb);
Parameters
NameTypeDefault
maxDbfloat—
SetMaxDistancevoid
# SetMaxDistance
C#
public void SetMaxDistance(float meters);
Parameters
NameTypeDefault
metersfloat—
SetMaxPolyphonyvoid
# SetMaxPolyphony
C#
public void SetMaxPolyphony(int maxPolyphony);
Parameters
NameTypeDefault
maxPolyphonyint—
SetPanningStrengthvoid
# SetPanningStrength
C#
public void SetPanningStrength(float panningStrength);
Parameters
NameTypeDefault
panningStrengthfloat—
SetPitchScalevoid
# SetPitchScale
C#
public void SetPitchScale(float pitchScale);
Parameters
NameTypeDefault
pitchScalefloat—
SetPlaybackTypevoid
# SetPlaybackType
C#
public void SetPlaybackType(AudioServer.PlaybackType playbackType);
Parameters
NameTypeDefault
playbackTypeAudioServer.PlaybackType—
SetPlayingvoid
# SetPlaying
C#
public void SetPlaying(bool enable);
Parameters
NameTypeDefault
enablebool—
SetStreamvoid
# SetStream
C#
public void SetStream(AudioStream stream);
Parameters
NameTypeDefault
streamAudioStream—
SetStreamPausedvoid
# SetStreamPaused
C#
public void SetStreamPaused(bool pause);
Parameters
NameTypeDefault
pausebool—
SetUnitSizevoid
# SetUnitSize
C#
public void SetUnitSize(float unitSize);
Parameters
NameTypeDefault
unitSizefloat—
SetVolumeDbvoid
# SetVolumeDb
C#
public void SetVolumeDb(float volumeDb);
Parameters
NameTypeDefault
volumeDbfloat—
SetVolumeLinearvoid
# SetVolumeLinear
C#
public void SetVolumeLinear(float volumeLinear);
Parameters
NameTypeDefault
volumeLinearfloat—
Stopvoid
# Stop
C#
public void Stop();

Stops the audio.

Signals and events1

FinishedEvent
# Finished
C#
public event Action Finished;

Emitted when an update removes one or more naturally ended voices. Other voices may still be playing. Stop() and voice-limit replacement are not natural completion; looping does not emit this signal each cycle.

AudioStreamPlayer3D.AttenuationModelEnum

ValueDescription
Disabled = 3

No attenuation of loudness according to distance. The sound will still be heard positionally, unlike an AudioStreamPlayer. AudioStreamPlayer3D.AttenuationModelEnum.Disabled can be combined with a AudioStreamPlayer3D.MaxDistance value greater than 0.0 to achieve linear attenuation clamped to a sphere of a defined size.

InverseDistance = 0

Attenuation of loudness according to linear distance.

InverseSquareDistance = 1

Attenuation of loudness according to squared distance.

Logarithmic = 2

Attenuation of loudness according to logarithmic distance.

AudioStreamPlayer3D.DopplerTrackingEnum

ValueDescription
Disabled = 0

Disables doppler tracking.

IdleStep = 1

Executes doppler tracking during process frames (see Entity.NotificationInternalProcess).

PhysicsStep = 2

Executes doppler tracking during physics frames (see Entity.NotificationInternalPhysicsProcess).

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.