reckfellENGINE

AudioStreamPlayer

Plays sound without world-position attenuation.

On this page
class AudioStreamPlayerReckfellSharpInherits Entity

AudioStreamPlayer suits music and interface sounds. Assign a Stream, choose a Bus and call Play() after entering the tree. Several players can share a resource with independent playback positions and pauses.

In Stream mode, a new Play creates a voice; MaxPolyphony limits voices by replacing the oldest. Pausing makes IsPlaying() false while retaining HasStreamPlayback(). Finished does not guarantee all voices have ended. Use a 2D/3D player for positional sources.

Working example.

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

Constructors1

AudioStreamPlayerConstructor
# AudioStreamPlayer
C#
public AudioStreamPlayer();

Properties11

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

If true, this node calls AudioStreamPlayer.Play when entering the tree.

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

Name of the receiving bus. If it is absent from the layout, audio falls back to Master. Check GetBusIndex(name) during project setup so the fallback does not hide a typo.

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.

MixTargetProperty
# MixTarget
C#
public AudioStreamPlayer.MixTargetEnum MixTarget { get; set; }

The mix target channels. Has no effect when two speakers or less are detected (see AudioServer.SpeakerMode).

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

A positive speed and pitch multiplier. A value of 2 raises pitch and speeds up an ordinary stream; this is not independent time stretching. Zero is not a pause: use StreamPaused.

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, this node is playing sounds. Setting this property has the same effect as AudioStreamPlayer.Play and AudioStreamPlayer.Stop.

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

The AudioStream resource to be played. Setting this property stops all currently playing sounds. If left empty, the AudioStreamPlayer does not work.

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.

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

Volume of sound, in decibels. This is an offset of the AudioStreamPlayer.Stream's volume. Note: To convert between decibel and linear energy (like most volume sliders do), use AudioStreamPlayer.VolumeLinear, or @GlobalScope.db_to_linear and @GlobalScope.linear_to_db.

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

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

Methods28

GetBusStringName
# GetBus
C#
public StringName GetBus();
Returns StringName
GetMaxPolyphonyint
# GetMaxPolyphony
C#
public int GetMaxPolyphony();
Returns int
GetMixTargetAudioStreamPlayer.MixTargetEnum
# GetMixTarget
C#
public AudioStreamPlayer.MixTargetEnum GetMixTarget();
Returns AudioStreamPlayer.MixTargetEnum
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 most recently created playback object. Check HasStreamPlayback() first; without voices the method reports an error. A retained decoder reference does not prove its voice remains attached to the player/mixer.

Returns AudioStreamPlayback
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
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);

Creates playback of the assigned Stream at the requested position in seconds; requires the player inside the tree. Repeated calls add voices within MaxPolyphony rather than necessarily resuming an old one. Use StreamPaused = false to resume.

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—
SetAutoplayvoid
# SetAutoplay
C#
public void SetAutoplay(bool enable);
Parameters
NameTypeDefault
enablebool—
SetBusvoid
# SetBus
C#
public void SetBus(StringName bus);
Parameters
NameTypeDefault
busStringName—
SetMaxPolyphonyvoid
# SetMaxPolyphony
C#
public void SetMaxPolyphony(int maxPolyphony);
Parameters
NameTypeDefault
maxPolyphonyint—
SetMixTargetvoid
# SetMixTarget
C#
public void SetMixTarget(AudioStreamPlayer.MixTargetEnum mixTarget);
Parameters
NameTypeDefault
mixTargetAudioStreamPlayer.MixTargetEnum—
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—
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 every voice in this player and clears its playback list. Does not emit Finished. Use Play() for a new start; this differs from resuming a pause.

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.

AudioStreamPlayer.MixTargetEnum

ValueDescription
Center = 2

The audio will be played on the second channel, which is usually the center.

Stereo = 0

The audio will be played only on the first channel. This is the default.

Surround = 1

The audio will be played on all surround channels.

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.