reckfellENGINE

AudioServer

Manages the global mixer, buses and audio timing.

On this page
class AudioServerReckfellSharp

AudioServer configures buses across the running project. Sources send signals into buses; effects run in order, then bus gain applies and the result is sent to a receiving bus on the left. Master supplies the final mix.

Look up a bus by name with GetBusIndex() and check for -1. Indices change when the layout changes. Runtime adjustments do not automatically save the project resource. The mixer operates separately from game frames; its timing and latency estimates do not measure physical sound at the listener.

Working example.

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

Properties5

BusCountProperty
# BusCount
C#
public static int BusCount { get; set; }

Number of available audio buses.

InputDeviceProperty
# InputDevice
C#
public static string InputDevice { get; set; }

Name of the current device for audio input (see AudioServer.GetInputDeviceList). On systems with multiple audio inputs (such as analog, USB and HDMI audio), this can be used to select the audio input device. The value "Default" will record audio on the system-wide default audio input. If an invalid device name is set, the value will be reverted back to "Default". Note: ProjectSettings.audio/driver/enable_input must be true for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.

OutputDeviceProperty
# OutputDevice
C#
public static string OutputDevice { get; set; }

Name of the current device for audio output (see AudioServer.GetOutputDeviceList). On systems with multiple audio outputs (such as analog, USB and HDMI audio), this can be used to select the audio output device. The value "Default" will play audio on the system-wide default audio output. If an invalid device name is set, the value will be reverted back to "Default".

PlaybackSpeedScaleProperty
# PlaybackSpeedScale
C#
public static float PlaybackSpeedScale { get; set; }

Scales the rate at which audio is played (i.e. setting it to 0.5 will make the audio be played at half its speed). See also Engine.TimeScale to affect the general simulation speed, which is independent from AudioServer.PlaybackSpeedScale.

SingletonProperty
# Singleton
C#
public static AudioServerInstance Singleton { get; }

Methods57

AddBusvoid
# AddBus
C#
public static void AddBus(int atPosition = -1);

Adds a bus at at_position.

Parameters
NameTypeDefault
atPositionint-1
AddBusEffectvoid
# AddBusEffect
C#
public static void AddBusEffect(int busIdx, AudioEffect effect, int atPosition = -1);

Adds an AudioEffect effect to the bus bus_idx at at_position.

Parameters
NameTypeDefault
busIdxint—
effectAudioEffect—
atPositionint-1
GenerateBusLayoutAudioBusLayout
# GenerateBusLayout
C#
public static AudioBusLayout GenerateBusLayout();

Generates an AudioBusLayout using the available buses and effects.

Returns AudioBusLayout
GetBusChannelsint
# GetBusChannels
C#
public static int GetBusChannels(int busIdx);

Returns the number of channels of the bus at index bus_idx.

Parameters
NameTypeDefault
busIdxint—
Returns int
GetBusCountint
# GetBusCount
C#
public static int GetBusCount();
Returns int
GetBusEffectAudioEffect
# GetBusEffect
C#
public static AudioEffect GetBusEffect(int busIdx, int effectIdx);

Returns the AudioEffect at position effect_idx in bus bus_idx.

Parameters
NameTypeDefault
busIdxint—
effectIdxint—
Returns AudioEffect
GetBusEffectCountint
# GetBusEffectCount
C#
public static int GetBusEffectCount(int busIdx);

Returns the number of effects on the bus at bus_idx.

Parameters
NameTypeDefault
busIdxint—
Returns int
GetBusEffectInstanceAudioEffectInstance
# GetBusEffectInstance
C#
public static AudioEffectInstance GetBusEffectInstance(int busIdx, int effectIdx, int channel = 0);

Returns the AudioEffectInstance assigned to the given bus and effect indices (and optionally channel).

Parameters
NameTypeDefault
busIdxint—
effectIdxint—
channelint0
Returns AudioEffectInstance
GetBusIndexint
# GetBusIndex
C#
public static int GetBusIndex(StringName busName);

Returns the current bus index by name, or -1 when absent. Look it up again after layout changes; do not store it as a stable category identifier.

Parameters
NameTypeDefault
busNameStringName—
Returns int
GetBusNamestring
# GetBusName
C#
public static string GetBusName(int busIdx);

Returns the name of the bus with the index bus_idx.

Parameters
NameTypeDefault
busIdxint—
Returns string
GetBusPeakVolumeLeftDbfloat
# GetBusPeakVolumeLeftDb
C#
public static float GetBusPeakVolumeLeftDb(int busIdx, int channel);

Returns the peak volume of the left speaker at bus index bus_idx and channel index channel.

Parameters
NameTypeDefault
busIdxint—
channelint—
Returns float
GetBusPeakVolumeRightDbfloat
# GetBusPeakVolumeRightDb
C#
public static float GetBusPeakVolumeRightDb(int busIdx, int channel);

Returns the peak volume of the right speaker at bus index bus_idx and channel index channel.

Parameters
NameTypeDefault
busIdxint—
channelint—
Returns float
GetBusSendStringName
# GetBusSend
C#
public static StringName GetBusSend(int busIdx);

Returns the name of the bus that the bus at index bus_idx sends to.

Parameters
NameTypeDefault
busIdxint—
Returns StringName
GetBusVolumeDbfloat
# GetBusVolumeDb
C#
public static float GetBusVolumeDb(int busIdx);

Returns the volume of the bus at index bus_idx in dB.

Parameters
NameTypeDefault
busIdxint—
Returns float
GetBusVolumeLinearfloat
# GetBusVolumeLinear
C#
public static float GetBusVolumeLinear(int busIdx);

Returns the volume of the bus at index bus_idx as a linear value. Note: The returned value is equivalent to the result of @GlobalScope.db_to_linear on the result of AudioServer.GetBusVolumeDb.

Parameters
NameTypeDefault
busIdxint—
Returns float
GetDriverNamestring
# GetDriverName
C#
public static string GetDriverName();

Returns the name of the current audio driver. The default usually depends on the operating system, but may be overridden via the --audio-driver command line argument. --headless also automatically sets the audio driver to Dummy. See also ProjectSettings.audio/driver/driver.

Returns string
GetInputBufferLengthFramesint
# GetInputBufferLengthFrames
C#
public static int GetInputBufferLengthFrames();

Returns the absolute size of the microphone input buffer. This is set to a multiple of the audio latency and can be used to estimate the minimum rate at which the frames need to be fetched.

Returns int
GetInputDevicestring
# GetInputDevice
C#
public static string GetInputDevice();
Returns string
GetInputDeviceListstring[]
# GetInputDeviceList
C#
public static string[] GetInputDeviceList();

Returns the names of all audio input devices detected on the system. Note: ProjectSettings.audio/driver/enable_input must be true for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.

Returns string[]
GetInputFramesVector2[]
# GetInputFrames
C#
public static Vector2[] GetInputFrames(int frames);

Returns a Vector2[] containing exactly frames audio samples from the internal microphone buffer if available, otherwise returns an empty Vector2[]. The buffer is filled at the rate of AudioServer.GetInputMixRate frames per second when AudioServer.SetInputDeviceActive has successfully been set to true. The samples are signed floating-point PCM values between -1 and 1.

Parameters
NameTypeDefault
framesint—
Returns Vector2[]
GetInputFramesAvailableint
# GetInputFramesAvailable
C#
public static int GetInputFramesAvailable();

Returns the number of frames available to read using AudioServer.GetInputFrames.

Returns int
GetInputMixRatefloat
# GetInputMixRate
C#
public static float GetInputMixRate();

Returns the sample rate at the input of the AudioServer.

Returns float
GetMixRatefloat
# GetMixRate
C#
public static float GetMixRate();

Returns the sample rate at the output of the AudioServer.

Returns float
GetOutputDevicestring
# GetOutputDevice
C#
public static string GetOutputDevice();
Returns string
GetOutputDeviceListstring[]
# GetOutputDeviceList
C#
public static string[] GetOutputDeviceList();

Returns the names of all audio output devices detected on the system.

Returns string[]
GetOutputLatencydouble
# GetOutputLatency
C#
public static double GetOutputLatency();

Returns the audio driver's effective output latency. This is based on ProjectSettings.audio/driver/output_latency, but the exact returned value will differ depending on the operating system and audio driver. Note: This can be expensive; it is not recommended to call AudioServer.GetOutputLatency every frame.

Returns double
GetPlaybackSpeedScalefloat
# GetPlaybackSpeedScale
C#
public static float GetPlaybackSpeedScale();
Returns float
GetSpeakerModeAudioServer.SpeakerMode
# GetSpeakerMode
C#
public static AudioServer.SpeakerMode GetSpeakerMode();

Returns the speaker configuration.

Returns AudioServer.SpeakerMode
GetTimeSinceLastMixdouble
# GetTimeSinceLastMix
C#
public static double GetTimeSinceLastMix();

Returns the relative time since the last mix occurred, in seconds.

Returns double
GetTimeToNextMixdouble
# GetTimeToNextMix
C#
public static double GetTimeToNextMix();

Returns the relative time until the next mix occurs, in seconds.

Returns double
IsBusBypassingEffectsbool
# IsBusBypassingEffects
C#
public static bool IsBusBypassingEffects(int busIdx);

If true, the bus at index bus_idx is bypassing effects.

Parameters
NameTypeDefault
busIdxint—
Returns bool
IsBusEffectEnabledbool
# IsBusEffectEnabled
C#
public static bool IsBusEffectEnabled(int busIdx, int effectIdx);

If true, the effect at index effect_idx on the bus at index bus_idx is enabled.

Parameters
NameTypeDefault
busIdxint—
effectIdxint—
Returns bool
IsBusMutebool
# IsBusMute
C#
public static bool IsBusMute(int busIdx);

If true, the bus at index bus_idx is muted.

Parameters
NameTypeDefault
busIdxint—
Returns bool
IsBusSolobool
# IsBusSolo
C#
public static bool IsBusSolo(int busIdx);

If true, the bus at index bus_idx is in solo mode.

Parameters
NameTypeDefault
busIdxint—
Returns bool
IsStreamRegisteredAsSamplebool
# IsStreamRegisteredAsSample
C#
public static bool IsStreamRegisteredAsSample(AudioStream stream);

If true, the stream is registered as a sample. The engine will not have to register it before playing the sample. If false, the stream will have to be registered before playing it. To prevent lag spikes, register the stream as sample with AudioServer.RegisterStreamAsSample.

Parameters
NameTypeDefault
streamAudioStream—
Returns bool
Lockvoid
# Lock
C#
public static void Lock();

Locks the audio driver's main loop. Note: Remember to unlock it afterwards.

MoveBusvoid
# MoveBus
C#
public static void MoveBus(int index, int toIndex);

Moves the bus from index index to index to_index.

Parameters
NameTypeDefault
indexint—
toIndexint—
RegisterStreamAsSamplevoid
# RegisterStreamAsSample
C#
public static void RegisterStreamAsSample(AudioStream stream);

Forces the registration of a stream as a sample. Note: Lag spikes may occur when calling this method, especially on single-threaded builds. It is suggested to call this method while loading assets, where the lag spike could be masked, instead of registering the sample right before it needs to be played.

Parameters
NameTypeDefault
streamAudioStream—
RemoveBusvoid
# RemoveBus
C#
public static void RemoveBus(int index);

Removes the bus at index index.

Parameters
NameTypeDefault
indexint—
RemoveBusEffectvoid
# RemoveBusEffect
C#
public static void RemoveBusEffect(int busIdx, int effectIdx);

Removes the effect at index effect_idx from the bus at index bus_idx.

Parameters
NameTypeDefault
busIdxint—
effectIdxint—
SetBusBypassEffectsvoid
# SetBusBypassEffects
C#
public static void SetBusBypassEffects(int busIdx, bool enable);

If true, the bus at index bus_idx is bypassing effects.

Parameters
NameTypeDefault
busIdxint—
enablebool—
SetBusCountvoid
# SetBusCount
C#
public static void SetBusCount(int amount);
Parameters
NameTypeDefault
amountint—
SetBusEffectEnabledvoid
# SetBusEffectEnabled
C#
public static void SetBusEffectEnabled(int busIdx, int effectIdx, bool enabled);

If true, the effect at index effect_idx on the bus at index bus_idx is enabled.

Parameters
NameTypeDefault
busIdxint—
effectIdxint—
enabledbool—
SetBusLayoutvoid
# SetBusLayout
C#
public static void SetBusLayout(AudioBusLayout busLayout);

Overwrites the currently used AudioBusLayout.

Parameters
NameTypeDefault
busLayoutAudioBusLayout—
SetBusMutevoid
# SetBusMute
C#
public static void SetBusMute(int busIdx, bool enable);

Mutes or restores a bus output without stopping or pausing its sources. That bus's effects are before mute, so Capture on it can still receive data.

Parameters
NameTypeDefault
busIdxint—
enablebool—
SetBusNamevoid
# SetBusName
C#
public static void SetBusName(int busIdx, string name);

Sets the name of the bus at index bus_idx to name.

Parameters
NameTypeDefault
busIdxint—
namestring—
SetBusSendvoid
# SetBusSend
C#
public static void SetBusSend(int busIdx, StringName send);

Sets the receiving bus by name. During processing it must be left of its sender; a missing name or a rightward/self route falls back to Master. Index 0 is Master and has no subsequent send.

Parameters
NameTypeDefault
busIdxint—
sendStringName—
SetBusSolovoid
# SetBusSolo
C#
public static void SetBusSolo(int busIdx, bool enable);

If true, the bus at index bus_idx is in solo mode.

Parameters
NameTypeDefault
busIdxint—
enablebool—
SetBusVolumeDbvoid
# SetBusVolumeDb
C#
public static void SetBusVolumeDb(int busIdx, float volumeDb);

Sets bus gain in dB: 0 is unity and about -6.02 halves amplitude. This is not a digital peak measurement in dBFS. Gain applies after bus effects and before sending onward. Mute is useful for a slider's zero position.

Parameters
NameTypeDefault
busIdxint—
volumeDbfloat—
SetBusVolumeLinearvoid
# SetBusVolumeLinear
C#
public static void SetBusVolumeLinear(int busIdx, float volumeLinear);

Sets the volume as a linear value of the bus at index bus_idx to volume_linear. Note: Using this method is equivalent to calling AudioServer.SetBusVolumeDb with the result of @GlobalScope.linear_to_db on a value.

Parameters
NameTypeDefault
busIdxint—
volumeLinearfloat—
SetEnableTaggingUsedAudioStreamsvoid
# SetEnableTaggingUsedAudioStreams
C#
public static void SetEnableTaggingUsedAudioStreams(bool enable);

If set to true, all instances of AudioStreamPlayback will call AudioStreamPlayback._TagUsedStreams every mix step. Note: This is enabled by default in the editor, as it is used by editor plugins for the audio stream previews.

Parameters
NameTypeDefault
enablebool—
SetInputDevicevoid
# SetInputDevice
C#
public static void SetInputDevice(string name);
Parameters
NameTypeDefault
namestring—
SetInputDeviceActiveError
# SetInputDeviceActive
C#
public static Error SetInputDeviceActive(bool active);

If active is true, starts the microphone input stream specified by AudioServer.InputDevice or returns an error if it failed. If active is false, stops the input stream if it is running.

Parameters
NameTypeDefault
activebool—
Returns Error
SetOutputDevicevoid
# SetOutputDevice
C#
public static void SetOutputDevice(string name);
Parameters
NameTypeDefault
namestring—
SetPlaybackSpeedScalevoid
# SetPlaybackSpeedScale
C#
public static void SetPlaybackSpeedScale(float scale);
Parameters
NameTypeDefault
scalefloat—
SwapBusEffectsvoid
# SwapBusEffects
C#
public static void SwapBusEffects(int busIdx, int effectIdx, int byEffectIdx);

Swaps the position of two effects in bus bus_idx.

Parameters
NameTypeDefault
busIdxint—
effectIdxint—
byEffectIdxint—
Unlockvoid
# Unlock
C#
public static void Unlock();

Unlocks the audio driver's main loop. (After locking it, you should always unlock it.)

Signals and events2

BusLayoutChangedEvent
# BusLayoutChanged
C#
public static event Action BusLayoutChanged;

Emitted when an audio bus is added, deleted, or moved.

BusRenamedEvent
# BusRenamed
C#
public static event AudioServer.BusRenamedEventHandler BusRenamed;

Emitted when the audio bus at bus_index is renamed from old_name to new_name.

Handler parameters
NameTypeDefault
busIndexlong—
oldNameStringName—
newNameStringName—

AudioServer.PlaybackType

ValueDescription
Default = 0

The playback will be considered of the type declared at ProjectSettings.audio/general/default_playback_type.

Max = 3

Represents the size of the AudioServer.PlaybackType enum.

Sample = 2

Force the playback to be considered as a sample. This can provide lower latency and more stable playback (with less risk of audio crackling), at the cost of having less flexibility. Note: Only currently supported on the web platform. Note: AudioEffects are not supported when playback is considered as a sample.

Stream = 1

Force the playback to be considered as a stream.

AudioServer.SpeakerMode

ValueDescription
ModeStereo = 0

Two or fewer speakers were detected.

Surround31 = 1

A 3.1 channel surround setup was detected.

Surround51 = 2

A 5.1 channel surround setup was detected.

Surround71 = 3

A 7.1 channel surround setup was detected.

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.