Class AudioServerInstance
- 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.
[GodotClassName("AudioServer")]
public class AudioServerInstance : GodotObject, IDisposable
- Inheritance
-
AudioServerInstance
- Implements
- Inherited Members
Properties
BusCount
Number of available audio buses.
public 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 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 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 float PlaybackSpeedScale { get; set; }
Property Value
Methods
AddBus(int)
Adds a bus at atPosition
.
public void AddBus(int atPosition = -1)
Parameters
atPosition
int
AddBusEffect(int, AudioEffect, int)
Adds an AudioEffect effect to the bus busIdx
at atPosition
.
public 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 AudioBusLayout GenerateBusLayout()
Returns
GetBusChannels(int)
Returns the number of channels of the bus at index busIdx
.
public int GetBusChannels(int busIdx)
Parameters
busIdx
int
Returns
GetBusEffect(int, int)
Returns the AudioEffect at position effectIdx
in bus busIdx
.
public AudioEffect GetBusEffect(int busIdx, int effectIdx)
Parameters
Returns
GetBusEffectCount(int)
Returns the number of effects on the bus at busIdx
.
public 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 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 int GetBusIndex(StringName busName)
Parameters
busName
StringName
Returns
GetBusName(int)
Returns the name of the bus with the index busIdx
.
public 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 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 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 StringName GetBusSend(int busIdx)
Parameters
busIdx
int
Returns
GetBusVolumeDb(int)
Returns the volume of the bus at index busIdx
in dB.
public 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 string[] GetInputDeviceList()
Returns
- string[]
GetMixRate()
Returns the sample rate at the output of the AudioServer.
public float GetMixRate()
Returns
GetOutputDeviceList()
Returns the names of all audio output devices detected on the system.
public 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 double GetOutputLatency()
Returns
GetSpeakerMode()
Returns the speaker configuration.
public AudioServer.SpeakerMode GetSpeakerMode()
Returns
GetTimeSinceLastMix()
Returns the relative time since the last mix occurred.
public double GetTimeSinceLastMix()
Returns
GetTimeToNextMix()
Returns the relative time until the next mix occurs.
public double GetTimeToNextMix()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsBusBypassingEffects(int)
If true
, the bus at index busIdx
is bypassing effects.
public 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 bool IsBusEffectEnabled(int busIdx, int effectIdx)
Parameters
Returns
IsBusMute(int)
If true
, the bus at index busIdx
is muted.
public bool IsBusMute(int busIdx)
Parameters
busIdx
int
Returns
IsBusSolo(int)
If true
, the bus at index busIdx
is in solo mode.
public bool IsBusSolo(int busIdx)
Parameters
busIdx
int
Returns
Lock()
Locks the audio driver's main loop.
Note: Remember to unlock it afterwards.
public void Lock()
MoveBus(int, int)
Moves the bus from index index
to index toIndex
.
public void MoveBus(int index, int toIndex)
Parameters
RemoveBus(int)
Removes the bus at index index
.
public void RemoveBus(int index)
Parameters
index
int
RemoveBusEffect(int, int)
Removes the effect at index effectIdx
from the bus at index busIdx
.
public void RemoveBusEffect(int busIdx, int effectIdx)
Parameters
SetBusBypassEffects(int, bool)
If true
, the bus at index busIdx
is bypassing effects.
public 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 void SetBusEffectEnabled(int busIdx, int effectIdx, bool enabled)
Parameters
SetBusLayout(AudioBusLayout)
Overwrites the currently used AudioBusLayout.
public void SetBusLayout(AudioBusLayout busLayout)
Parameters
busLayout
AudioBusLayout
SetBusMute(int, bool)
If true
, the bus at index busIdx
is muted.
public void SetBusMute(int busIdx, bool enable)
Parameters
SetBusName(int, string)
Sets the name of the bus at index busIdx
to name
.
public void SetBusName(int busIdx, string name)
Parameters
SetBusSend(int, StringName)
Connects the output of the bus at busIdx
to the bus named send
.
public 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 void SetBusSolo(int busIdx, bool enable)
Parameters
SetBusVolumeDb(int, float)
Sets the volume of the bus at index busIdx
to volumeDb
.
public 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 void SetEnableTaggingUsedAudioStreams(bool enable)
Parameters
enable
bool
SwapBusEffects(int, int, int)
Swaps the position of two effects in bus busIdx
.
public 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 void Unlock()
Events
BusLayoutChanged
Emitted when an audio bus is added, deleted, or moved.
public event Action BusLayoutChanged
Event Type
BusRenamed
Emitted when the audio bus at busIndex
is renamed from oldName
to newName
.
public event AudioServerInstance.BusRenamedEventHandler BusRenamed