Skip to content

AudioServer

Eduard Gushchin edited this page Jul 1, 2026 · 5 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.AudioServer
Namespace Electron2D
Kind class
Category Audio

Overview

Provides process-wide audio device, bus and voice playback state.

Syntax

public static class Electron2D.AudioServer

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Partial / Not verified
Out of profile: yes
Godot reference: AudioServer

Process-wide audio query boundary with mix rate, output latency, speaker mode, Master, user buses, routing path, bus volume, mute, solo and lock/unlock. Internal voice handles are not public API.

Remarks

AudioServer is the public boundary for querying audio output state. It keeps concrete platform backend handles internal to the runtime.

Electron2D 0.1.0 Preview exposes the default Master bus, user-defined buses, simple volume routing, mute and solo state. Audio effects and editor-side bus layout editing are not part of this preview server surface.

Thread Safety

All public methods synchronize access to process-wide audio state. Calls to Electron2D.AudioServer.Lock and Electron2D.AudioServer.Unlock must be balanced on the same thread.

Since

This class is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioStream
  • Electron2D.AudioStreamPlayer
  • Electron2D.AudioStreamPlayer2D

Members

Member Kind Summary
AddBus(System.Int32) Method Adds a user audio bus.
GetBusCount() Method Gets the number of audio buses available to the server.
GetBusIndex(System.String) Method Gets the index of an audio bus by name.
GetBusName(System.Int32) Method Gets the name of an audio bus by index.
GetBusSend(System.Int32) Method Gets the target bus that receives a bus output.
GetBusVolumeDb(System.Int32) Method Gets a bus volume offset in decibels.
GetBusVolumeLinear(System.Int32) Method Gets a bus volume as linear gain.
GetMixRate() Method Gets the audio mix rate in hertz.
GetOutputLatency() Method Gets the current audio output latency estimate.
GetSpeakerMode() Method Gets the speaker layout reported by the active audio output.
IsBusMute(System.Int32) Method Checks whether a bus is muted.
IsBusSolo(System.Int32) Method Checks whether a bus is soloed.
Lock() Method Locks the audio server for a group of audio changes.
MoveBus(System.Int32, System.Int32) Method Moves a user audio bus to a different index.
RemoveBus(System.Int32) Method Removes a user audio bus.
SetBusCount(System.Int32) Method Changes the number of audio buses.
SetBusMute(System.Int32, System.Boolean) Method Enables or disables mute for a bus.
SetBusName(System.Int32, System.String) Method Changes the name of a user audio bus.
SetBusSend(System.Int32, Electron2D.StringName) Method Changes the target bus that receives a user bus output.
SetBusSolo(System.Int32, System.Boolean) Method Enables or disables solo for a bus.
SetBusVolumeDb(System.Int32, System.Single) Method Sets a bus volume offset in decibels.
SetBusVolumeLinear(System.Int32, System.Single) Method Sets a bus volume as linear gain.
Unlock() Method Unlocks the audio server after a grouped audio change.

Member Details

AddBus(System.Int32)

Kind: Method

public static System.Void AddBus(System.Int32)(System.Int32 atPosition)

Summary

Adds a user audio bus.

Remarks

Master is fixed at index 0, so explicit insertion positions must be from 1 through Electron2D.AudioServer.GetBusCount. The new bus gets a unique default name and sends to Master.

Parameters

  • atPosition: The insertion index, or -1 to append the bus at the end.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when atPosition is outside the valid range.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.SetBusName(System.Int32,System.String)
  • Electron2D.AudioServer.SetBusSend(System.Int32,Electron2D.StringName)

GetBusCount()

Kind: Method

public static System.Int32 GetBusCount()()

Summary

Gets the number of audio buses available to the server.

Remarks

The bus count is always at least 1 because Master cannot be removed. User buses are stored in process-wide audio server state and are applied to voices started after a bus change.

Returns

The number of buses, including the default Master bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusIndex(System.String)
  • Electron2D.AudioServer.GetBusName(System.Int32)

GetBusIndex(System.String)

Kind: Method

public static System.Int32 GetBusIndex(System.String)(System.String busName)

Summary

Gets the index of an audio bus by name.

Remarks

Bus lookup is case-sensitive. The method returns -1 when no bus currently has busName.

Parameters

  • busName: The bus name to search for.

Returns

The zero-based bus index, or -1 when no bus has the requested name.

Exceptions

  • System.ArgumentException: Thrown when busName is empty or whitespace.
  • System.ArgumentNullException: Thrown when busName is null.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusName(System.Int32)

GetBusName(System.Int32)

Kind: Method

public static System.String GetBusName(System.Int32)(System.Int32 busIdx)

Summary

Gets the name of an audio bus by index.

Remarks

Index 0 is always named Master. User buses occupy positive indices and may be reordered with Electron2D.AudioServer.MoveBus(System.Int32,System.Int32).

Parameters

  • busIdx: The zero-based bus index to query.

Returns

The bus name.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusCount
  • Electron2D.AudioServer.GetBusIndex(System.String)

GetBusSend(System.Int32)

Kind: Method

public static Electron2D.StringName GetBusSend(System.Int32)(System.Int32 busIdx)

Summary

Gets the target bus that receives a bus output.

Remarks

User buses default to sending to Master. Master has no send target and returns an empty value.

Parameters

  • busIdx: The bus index to query.

Returns

The target bus name, or an empty Electron2D.StringName for Master.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.SetBusSend(System.Int32,Electron2D.StringName)

GetBusVolumeDb(System.Int32)

Kind: Method

public static System.Single GetBusVolumeDb(System.Int32)(System.Int32 busIdx)

Summary

Gets a bus volume offset in decibels.

Remarks

This value is stored on the bus itself. It does not include the volume of any other bus on the routing path.

Parameters

  • busIdx: The bus index to query.

Returns

The bus decibel volume offset.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusVolumeLinear(System.Int32)
  • Electron2D.AudioServer.SetBusVolumeDb(System.Int32,System.Single)

GetBusVolumeLinear(System.Int32)

Kind: Method

public static System.Single GetBusVolumeLinear(System.Int32)(System.Int32 busIdx)

Summary

Gets a bus volume as linear gain.

Remarks

The returned value is converted from the bus decibel volume only. It does not include any routed parent bus.

Parameters

  • busIdx: The bus index to query.

Returns

The bus volume as linear gain.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusVolumeDb(System.Int32)
  • Electron2D.AudioServer.SetBusVolumeLinear(System.Int32,System.Single)

GetMixRate()

Kind: Method

public static System.Single GetMixRate()()

Summary

Gets the audio mix rate in hertz.

Remarks

The preview backend defaults to 48000. Platform backends may report a different value when the active audio device requires it.

Returns

The number of output sample frames mixed per second.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetOutputLatency
  • Electron2D.AudioServer.GetSpeakerMode

GetOutputLatency()

Kind: Method

public static System.Single GetOutputLatency()()

Summary

Gets the current audio output latency estimate.

Remarks

The value is an estimate supplied by the active backend. The default preview backend reports 0 because it does not own a physical output device.

Returns

The estimated output latency in seconds.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetMixRate

GetSpeakerMode()

Kind: Method

public static Electron2D.AudioServer.SpeakerMode GetSpeakerMode()()

Summary

Gets the speaker layout reported by the active audio output.

Remarks

The value is a query result only. Changing speaker layout is handled by platform startup settings and is not exposed in this preview server API.

Returns

The current speaker layout.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.SpeakerMode

IsBusMute(System.Int32)

Kind: Method

public static System.Boolean IsBusMute(System.Int32)(System.Int32 busIdx)

Summary

Checks whether a bus is muted.

Remarks

The result describes the bus flag only. It does not inspect parent buses on the routing path.

Parameters

  • busIdx: The bus index to query.

Returns

true when the bus is muted; otherwise false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.SetBusMute(System.Int32,System.Boolean)

IsBusSolo(System.Int32)

Kind: Method

public static System.Boolean IsBusSolo(System.Int32)(System.Int32 busIdx)

Summary

Checks whether a bus is soloed.

Remarks

The result describes the bus flag only. It does not inspect other buses.

Parameters

  • busIdx: The bus index to query.

Returns

true when the bus is soloed; otherwise false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.SetBusSolo(System.Int32,System.Boolean)

Lock()

Kind: Method

public static System.Void Lock()()

Summary

Locks the audio server for a group of audio changes.

Remarks

Use this method when several audio operations need to be observed as a single change by the backend. Every successful call must be paired with Electron2D.AudioServer.Unlock on the same thread.

Thread Safety

This method is safe to call from any thread, but the matching Electron2D.AudioServer.Unlock must be called from the same thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.Unlock

MoveBus(System.Int32, System.Int32)

Kind: Method

public static System.Void MoveBus(System.Int32, System.Int32)(System.Int32 index, System.Int32 toIndex)

Summary

Moves a user audio bus to a different index.

Remarks

The Master bus remains fixed at index 0. If moving a bus would leave any user bus sending to itself or to a bus on its right, that send target is reset to Master.

Parameters

  • index: The current bus index.
  • toIndex: The target bus index.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when either index is outside the valid bus range.
  • System.InvalidOperationException: Thrown when index or toIndex is 0.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusName(System.Int32)
  • Electron2D.AudioServer.SetBusSend(System.Int32,Electron2D.StringName)

RemoveBus(System.Int32)

Kind: Method

public static System.Void RemoveBus(System.Int32)(System.Int32 index)

Summary

Removes a user audio bus.

Remarks

Removing a bus reroutes remaining buses that sent to it back to Master. The Master bus at index 0 cannot be removed.

Parameters

  • index: The bus index to remove.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when index does not identify an existing bus.
  • System.InvalidOperationException: Thrown when index is 0.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.AddBus(System.Int32)
  • Electron2D.AudioServer.SetBusCount(System.Int32)

SetBusCount(System.Int32)

Kind: Method

public static System.Void SetBusCount(System.Int32)(System.Int32 amount)

Summary

Changes the number of audio buses.

Remarks

The value must be at least 1. Increasing the count appends user buses routed to Master. Decreasing the count removes buses from the end and reroutes remaining buses whose send target was removed.

The change applies to voices started after the bus layout update. Existing voices keep the playback snapshot created when they started.

Parameters

  • amount: The requested bus count, including the Master bus.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when amount is less than 1.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.AddBus(System.Int32)
  • Electron2D.AudioServer.GetBusCount
  • Electron2D.AudioServer.RemoveBus(System.Int32)

SetBusMute(System.Int32, System.Boolean)

Kind: Method

public static System.Void SetBusMute(System.Int32, System.Boolean)(System.Int32 busIdx, System.Boolean enable)

Summary

Enables or disables mute for a bus.

Remarks

A muted bus silences voices whose routing path contains that bus. The change applies to voices started after the state change.

Parameters

  • busIdx: The bus index to change.
  • enable: true to mute the bus; otherwise false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.IsBusMute(System.Int32)
  • Electron2D.AudioServer.SetBusSolo(System.Int32,System.Boolean)

SetBusName(System.Int32, System.String)

Kind: Method

public static System.Void SetBusName(System.Int32, System.String)(System.Int32 busIdx, System.String name)

Summary

Changes the name of a user audio bus.

Remarks

Bus names are case-sensitive and must be unique. Renaming a bus updates other bus send targets that referenced the old name.

Parameters

  • busIdx: The bus index to rename.
  • name: The new bus name.

Exceptions

  • System.ArgumentException: Thrown when name is empty, whitespace-only or already used by another bus.
  • System.ArgumentNullException: Thrown when name is null.
  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.
  • System.InvalidOperationException: Thrown when busIdx is 0.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusName(System.Int32)

SetBusSend(System.Int32, Electron2D.StringName)

Kind: Method

public static System.Void SetBusSend(System.Int32, Electron2D.StringName)(System.Int32 busIdx, Electron2D.StringName send)

Summary

Changes the target bus that receives a user bus output.

Remarks

User buses may only send to an existing bus on their left. This keeps the routing graph acyclic. Master accepts only an empty send target.

Parameters

  • busIdx: The bus index to route.
  • send: The target bus name, or an empty value to use Master for user buses.

Exceptions

  • System.ArgumentException: Thrown when send names no existing bus.
  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.
  • System.InvalidOperationException: Thrown when the requested route would point from Master to another bus, to the same bus, or to a bus on the right.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusSend(System.Int32)

SetBusSolo(System.Int32, System.Boolean)

Kind: Method

public static System.Void SetBusSolo(System.Int32, System.Boolean)(System.Int32 busIdx, System.Boolean enable)

Summary

Enables or disables solo for a bus.

Remarks

When any bus is solo, voices are audible only if their routing path contains at least one solo bus. The change applies to voices started after the state change.

Parameters

  • busIdx: The bus index to change.
  • enable: true to solo the bus; otherwise false.

Exceptions

  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.IsBusSolo(System.Int32)
  • Electron2D.AudioServer.SetBusMute(System.Int32,System.Boolean)

SetBusVolumeDb(System.Int32, System.Single)

Kind: Method

public static System.Void SetBusVolumeDb(System.Int32, System.Single)(System.Int32 busIdx, System.Single volumeDb)

Summary

Sets a bus volume offset in decibels.

Remarks

The value is added to the voice volume and to every other bus volume on the routing path. Setting volume on Master changes the global output level for future voices.

Parameters

  • busIdx: The bus index to change.
  • volumeDb: The finite decibel offset.

Exceptions

  • System.ArgumentException: Thrown when volumeDb is not finite.
  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusVolumeDb(System.Int32)
  • Electron2D.AudioServer.SetBusVolumeLinear(System.Int32,System.Single)

SetBusVolumeLinear(System.Int32, System.Single)

Kind: Method

public static System.Void SetBusVolumeLinear(System.Int32, System.Single)(System.Int32 busIdx, System.Single volumeLinear)

Summary

Sets a bus volume as linear gain.

Remarks

A value of 1 maps to 0 dB. A value of 0 maps to the preview quiet floor used for deterministic runtime tests.

Parameters

  • busIdx: The bus index to change.
  • volumeLinear: A finite non-negative linear gain.

Exceptions

  • System.ArgumentException: Thrown when volumeLinear is not finite.
  • System.ArgumentOutOfRangeException: Thrown when busIdx does not identify an existing bus or when volumeLinear is negative.

Thread Safety

This method is safe to call from any thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.GetBusVolumeLinear(System.Int32)
  • Electron2D.AudioServer.SetBusVolumeDb(System.Int32,System.Single)

Unlock()

Kind: Method

public static System.Void Unlock()()

Summary

Unlocks the audio server after a grouped audio change.

Remarks

Call this method once for every successful Electron2D.AudioServer.Lock call. Calling it without owning the audio server lock is an error.

Thread Safety

This method must be called from the same thread that called Electron2D.AudioServer.Lock.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.AudioServer.Lock

Clone this wiki locally