Class AudioServer
- Namespace
- Godot
- Assembly
- GodotSharp.dll
AudioServer is a low-level server interface for audio access. It is in charge of creating sample data (playable audio) as well as its playback via a voice interface.
public static class AudioServer
- Inheritance
-
AudioServer
- Inherited Members
Properties
BusCount
Number of available audio buses.
public static int BusCount { get; set; }
Property Value
InputDevice
Name of the current device for audio input (see 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.
public static string InputDevice { get; set; }
Property Value
OutputDevice
Name of the current device for audio output (see 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"
.
public static string OutputDevice { get; set; }
Property Value
PlaybackSpeedScale
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).
public static float PlaybackSpeedScale { get; set; }
Property Value
Singleton
public static AudioServerInstance Singleton { get; }
Property Value
Methods
AddBus(int)
Adds a bus at atPosition
.
public static void AddBus(int atPosition = -1)
Parameters
atPosition
int
AddBusEffect(int, AudioEffect, int)
Adds an AudioEffect effect to the bus busIdx
at atPosition
.
public static void AddBusEffect(int busIdx, AudioEffect effect, int atPosition = -1)
Parameters
busIdx
inteffect
AudioEffectatPosition
int
GenerateBusLayout()
Generates an AudioBusLayout using the available buses and effects.
public static AudioBusLayout GenerateBusLayout()
Returns
GetBusChannels(int)
Returns the number of channels of the bus at index busIdx
.
public static int GetBusChannels(int busIdx)
Parameters
busIdx
int
Returns
GetBusEffect(int, int)
Returns the AudioEffect at position effectIdx
in bus busIdx
.
public static AudioEffect GetBusEffect(int busIdx, int effectIdx)
Parameters
Returns
GetBusEffectCount(int)
Returns the number of effects on the bus at busIdx
.
public static int GetBusEffectCount(int busIdx)
Parameters
busIdx
int
Returns
GetBusEffectInstance(int, int, int)
Returns the AudioEffectInstance assigned to the given bus and effect indices (and optionally channel).
public static AudioEffectInstance GetBusEffectInstance(int busIdx, int effectIdx, int channel = 0)
Parameters
Returns
GetBusIndex(StringName)
Returns the index of the bus with the name busName
. Returns -1
if no bus with the specified name exist.
public static int GetBusIndex(StringName busName)
Parameters
busName
StringName
Returns
GetBusName(int)
Returns the name of the bus with the index busIdx
.
public static string GetBusName(int busIdx)
Parameters
busIdx
int
Returns
GetBusPeakVolumeLeftDb(int, int)
Returns the peak volume of the left speaker at bus index busIdx
and channel index channel
.
public static float GetBusPeakVolumeLeftDb(int busIdx, int channel)
Parameters
Returns
GetBusPeakVolumeRightDb(int, int)
Returns the peak volume of the right speaker at bus index busIdx
and channel index channel
.
public static float GetBusPeakVolumeRightDb(int busIdx, int channel)
Parameters
Returns
GetBusSend(int)
Returns the name of the bus that the bus at index busIdx
sends to.
public static StringName GetBusSend(int busIdx)
Parameters
busIdx
int
Returns
GetBusVolumeDb(int)
Returns the volume of the bus at index busIdx
in dB.
public static float GetBusVolumeDb(int busIdx)
Parameters
busIdx
int
Returns
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.
public static string[] GetInputDeviceList()
Returns
- string[]
GetMixRate()
Returns the sample rate at the output of the AudioServer.
public static float GetMixRate()
Returns
GetOutputDeviceList()
Returns the names of all audio output devices detected on the system.
public static string[] GetOutputDeviceList()
Returns
- string[]
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 GetOutputLatency() every frame.
public static double GetOutputLatency()
Returns
GetSpeakerMode()
Returns the speaker configuration.
public static AudioServer.SpeakerMode GetSpeakerMode()
Returns
GetTimeSinceLastMix()
Returns the relative time since the last mix occurred.
public static double GetTimeSinceLastMix()
Returns
GetTimeToNextMix()
Returns the relative time until the next mix occurs.
public static double GetTimeToNextMix()
Returns
IsBusBypassingEffects(int)
If true
, the bus at index busIdx
is bypassing effects.
public static bool IsBusBypassingEffects(int busIdx)
Parameters
busIdx
int
Returns
IsBusEffectEnabled(int, int)
If true
, the effect at index effectIdx
on the bus at index busIdx
is enabled.
public static bool IsBusEffectEnabled(int busIdx, int effectIdx)
Parameters
Returns
IsBusMute(int)
If true
, the bus at index busIdx
is muted.
public static bool IsBusMute(int busIdx)
Parameters
busIdx
int
Returns
IsBusSolo(int)
If true
, the bus at index busIdx
is in solo mode.
public static bool IsBusSolo(int busIdx)
Parameters
busIdx
int
Returns
Lock()
Locks the audio driver's main loop.
Note: Remember to unlock it afterwards.
public static void Lock()
MoveBus(int, int)
Moves the bus from index index
to index toIndex
.
public static void MoveBus(int index, int toIndex)
Parameters
RemoveBus(int)
Removes the bus at index index
.
public static void RemoveBus(int index)
Parameters
index
int
RemoveBusEffect(int, int)
Removes the effect at index effectIdx
from the bus at index busIdx
.
public static void RemoveBusEffect(int busIdx, int effectIdx)
Parameters
SetBusBypassEffects(int, bool)
If true
, the bus at index busIdx
is bypassing effects.
public static void SetBusBypassEffects(int busIdx, bool enable)
Parameters
SetBusEffectEnabled(int, int, bool)
If true
, the effect at index effectIdx
on the bus at index busIdx
is enabled.
public static void SetBusEffectEnabled(int busIdx, int effectIdx, bool enabled)
Parameters
SetBusLayout(AudioBusLayout)
Overwrites the currently used AudioBusLayout.
public static void SetBusLayout(AudioBusLayout busLayout)
Parameters
busLayout
AudioBusLayout
SetBusMute(int, bool)
If true
, the bus at index busIdx
is muted.
public static void SetBusMute(int busIdx, bool enable)
Parameters
SetBusName(int, string)
Sets the name of the bus at index busIdx
to name
.
public static void SetBusName(int busIdx, string name)
Parameters
SetBusSend(int, StringName)
Connects the output of the bus at busIdx
to the bus named send
.
public static void SetBusSend(int busIdx, StringName send)
Parameters
busIdx
intsend
StringName
SetBusSolo(int, bool)
If true
, the bus at index busIdx
is in solo mode.
public static void SetBusSolo(int busIdx, bool enable)
Parameters
SetBusVolumeDb(int, float)
Sets the volume of the bus at index busIdx
to volumeDb
.
public static void SetBusVolumeDb(int busIdx, float volumeDb)
Parameters
SetEnableTaggingUsedAudioStreams(bool)
If set to true
, all instances of AudioStreamPlayback will call _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.
public static void SetEnableTaggingUsedAudioStreams(bool enable)
Parameters
enable
bool
SwapBusEffects(int, int, int)
Swaps the position of two effects in bus busIdx
.
public static void SwapBusEffects(int busIdx, int effectIdx, int byEffectIdx)
Parameters
Unlock()
Unlocks the audio driver's main loop. (After locking it, you should always unlock it.)
public static void Unlock()
Events
BusLayoutChanged
Emitted when an audio bus is added, deleted, or moved.
public static event Action BusLayoutChanged
Event Type
BusRenamed
Emitted when the audio bus at busIndex
is renamed from oldName
to newName
.
public static event AudioServer.BusRenamedEventHandler BusRenamed