Skip to content

AudioServer

Eduard Gushchin edited this page Jun 21, 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

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 a single default Master bus and internal voice lifecycle used by future playback nodes. User buses, volume routing and audio effects are added by later audio tasks.

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

Members

Member Kind Summary
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.
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.
Lock() Method Locks the audio server for a group of audio changes.
Unlock() Method Unlocks the audio server after a grouped audio change.

Member Details

GetBusCount()

Kind: Method

public static System.Int32 GetBusCount()()

Summary

Gets the number of audio buses available to the server.

Remarks

Electron2D 0.1.0 Preview exposes only the default bus. User-defined buses and routing controls are added by the audio bus task.

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 preview server recognizes Master and returns -1 for every other valid name.

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

The preview server contains only index 0, named Master.

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)

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

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

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