Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
Table of contents
-
var bus_count: int = 1 -
var input_device: String = "Default" -
var output_device: String = "Default" -
var playback_speed_scale: float = 1.0 -
func add_bus(at_position: int = -1) -> void -
func add_bus_effect(at_position: int = -1) -> void -
const func generate_bus_layout() -> AudioBusLayout -
const func get_bus_channels(bus_idx: int) -> int -
func get_bus_effect(effect_idx: int) -> AudioEffect -
func get_bus_effect_count(bus_idx: int) -> int -
func get_bus_effect_instance(channel: int = 0) -> AudioEffectInstance -
const func get_bus_index(bus_name: StringName) -> int -
const func get_bus_name(bus_idx: int) -> String -
const func get_bus_peak_volume_left_db(channel: int) -> float -
const func get_bus_peak_volume_right_db(channel: int) -> float -
const func get_bus_send(bus_idx: int) -> StringName -
const func get_bus_volume_db(bus_idx: int) -> float -
const func get_bus_volume_linear(bus_idx: int) -> float -
const func get_driver_name() -> String -
func get_input_device_list() -> PackedStringArray -
const func get_input_mix_rate() -> float -
const func get_mix_rate() -> float -
func get_output_device_list() -> PackedStringArray -
const func get_output_latency() -> float -
const func get_speaker_mode() -> intAudioServer.SpeakerMode -
const func get_time_since_last_mix() -> float -
const func get_time_to_next_mix() -> float -
const func is_bus_bypassing_effects(bus_idx: int) -> bool -
const func is_bus_effect_enabled(effect_idx: int) -> bool -
const func is_bus_mute(bus_idx: int) -> bool -
const func is_bus_solo(bus_idx: int) -> bool -
func is_stream_registered_as_sample(stream: AudioStream) -> bool -
func lock() -> void -
func move_bus(to_index: int) -> void -
func register_stream_as_sample(stream: AudioStream) -> void -
func remove_bus(index: int) -> void -
func remove_bus_effect(effect_idx: int) -> void -
func set_bus_bypass_effects(enable: bool) -> void -
func set_bus_effect_enabled(enabled: bool) -> void -
func set_bus_layout(bus_layout: AudioBusLayout) -> void -
func set_bus_mute(enable: bool) -> void -
func set_bus_name(name: String) -> void -
func set_bus_send(send: StringName) -> void -
func set_bus_solo(enable: bool) -> void -
func set_bus_volume_db(volume_db: float) -> void -
func set_bus_volume_linear(volume_linear: float) -> void -
func set_enable_tagging_used_audio_streams(enable: bool) -> void -
func swap_bus_effects(by_effect_idx: int) -> void -
func unlock() -> void -
const SPEAKER_MODE_STEREO = 0 enum SpeakerMode -
const SPEAKER_SURROUND_31 = 1 enum SpeakerMode -
const SPEAKER_SURROUND_51 = 2 enum SpeakerMode -
const SPEAKER_SURROUND_71 = 3 enum SpeakerMode -
const PLAYBACK_TYPE_DEFAULT = 0 enum PlaybackType -
const PLAYBACK_TYPE_STREAM = 1 enum PlaybackType -
const PLAYBACK_TYPE_SAMPLE = 2 enum PlaybackType -
const PLAYBACK_TYPE_MAX = 3 enum PlaybackType -
enum SpeakerMode -
enum PlaybackType -
signal bus_layout_changed() -
signal bus_renamed(new_name: StringName)
AudioServer #
is_instantiable, core, not_builtin_classes, singleton
Server interface for low-level audio access.
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.
Members #
var bus_count: int = 1#
Number of available audio buses.
var input_device: String = "Default"#
Name of the current device for audio input (see get_input_device_list). 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.
var output_device: String = "Default"#
Name of the current device for audio output (see get_output_device_list). 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".
var playback_speed_scale: float = 1.0#
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.time_scale to affect the general simulation speed, which is independent from AudioServer.playback_speed_scale.
Methods #
func add_bus(at_position: int = -1) -> void#
Adds a bus at at_position.
func add_bus_effect(at_position: int = -1) -> void#
Adds an AudioEffect effect to the bus bus_idx at at_position.
const func generate_bus_layout() -> AudioBusLayout#
Generates an AudioBusLayout using the available buses and effects.
const func get_bus_channels(bus_idx: int) -> int#
Returns the number of channels of the bus at index bus_idx.
func get_bus_effect(effect_idx: int) -> AudioEffect#
Returns the AudioEffect at position effect_idx in bus bus_idx.
func get_bus_effect_count(bus_idx: int) -> int#
Returns the number of effects on the bus at bus_idx.
func get_bus_effect_instance(channel: int = 0) -> AudioEffectInstance#
Returns the AudioEffectInstance assigned to the given bus and effect indices (and optionally channel).
const func get_bus_index(bus_name: StringName) -> int#
Returns the index of the bus with the name bus_name. Returns -1 if no bus with the specified name exist.
const func get_bus_name(bus_idx: int) -> String#
Returns the name of the bus with the index bus_idx.
const func get_bus_peak_volume_left_db(channel: int) -> float#
Returns the peak volume of the left speaker at bus index bus_idx and channel index channel.
const func get_bus_peak_volume_right_db(channel: int) -> float#
Returns the peak volume of the right speaker at bus index bus_idx and channel index channel.
const func get_bus_send(bus_idx: int) -> StringName#
Returns the name of the bus that the bus at index bus_idx sends to.
const func get_bus_volume_db(bus_idx: int) -> float#
Returns the volume of the bus at index bus_idx in dB.
const func get_bus_volume_linear(bus_idx: int) -> float#
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 get_bus_volume_db.
const func get_driver_name() -> String#
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.
func get_input_device_list() -> PackedStringArray#
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.
const func get_input_mix_rate() -> float#
Returns the sample rate at the input of the AudioServer.
const func get_mix_rate() -> float#
Returns the sample rate at the output of the AudioServer.
func get_output_device_list() -> PackedStringArray#
Returns the names of all audio output devices detected on the system.
const func get_output_latency() -> float#
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 get_output_latency every frame.
const func get_speaker_mode() -> intAudioServer.SpeakerMode#
Returns the speaker configuration.
const func get_time_since_last_mix() -> float#
Returns the relative time since the last mix occurred.
const func get_time_to_next_mix() -> float#
Returns the relative time until the next mix occurs.
const func is_bus_bypassing_effects(bus_idx: int) -> bool#
If true, the bus at index bus_idx is bypassing effects.
const func is_bus_effect_enabled(effect_idx: int) -> bool#
If true, the effect at index effect_idx on the bus at index bus_idx is enabled.
const func is_bus_mute(bus_idx: int) -> bool#
If true, the bus at index bus_idx is muted.
const func is_bus_solo(bus_idx: int) -> bool#
If true, the bus at index bus_idx is in solo mode.
func is_stream_registered_as_sample(stream: AudioStream) -> bool#
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 register_stream_as_sample.
func move_bus(to_index: int) -> void#
Moves the bus from index index to index to_index.
func register_stream_as_sample(stream: AudioStream) -> void#
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.
func remove_bus(index: int) -> void#
Removes the bus at index index.
func remove_bus_effect(effect_idx: int) -> void#
Removes the effect at index effect_idx from the bus at index bus_idx.
func set_bus_bypass_effects(enable: bool) -> void#
If true, the bus at index bus_idx is bypassing effects.
func set_bus_effect_enabled(enabled: bool) -> void#
If true, the effect at index effect_idx on the bus at index bus_idx is enabled.
func set_bus_layout(bus_layout: AudioBusLayout) -> void#
Overwrites the currently used AudioBusLayout.
func set_bus_mute(enable: bool) -> void#
If true, the bus at index bus_idx is muted.
func set_bus_name(name: String) -> void#
Sets the name of the bus at index bus_idx to name.
func set_bus_send(send: StringName) -> void#
Connects the output of the bus at bus_idx to the bus named send.
func set_bus_solo(enable: bool) -> void#
If true, the bus at index bus_idx is in solo mode.
func set_bus_volume_db(volume_db: float) -> void#
Sets the volume in decibels of the bus at index bus_idx to volume_db.
func set_bus_volume_linear(volume_linear: float) -> void#
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 set_bus_volume_db with the result of @GlobalScope.linear_to_db on a value.
func set_enable_tagging_used_audio_streams(enable: bool) -> void#
If set to true, all instances of AudioStreamPlayback will call AudioStreamPlayback._tag_used_streams every mix step.
Note: This is enabled by default in the editor, as it is used by editor plugins for the audio stream previews.
func swap_bus_effects(by_effect_idx: int) -> void#
Swaps the position of two effects in bus bus_idx.
func unlock() -> void#
Unlocks the audio driver's main loop. (After locking it, you should always unlock it.)
Annotations #
Constants #
const SPEAKER_MODE_STEREO = 0 enum SpeakerMode#
Two or fewer speakers were detected.
const SPEAKER_SURROUND_31 = 1 enum SpeakerMode#
A 3.1 channel surround setup was detected.
const SPEAKER_SURROUND_51 = 2 enum SpeakerMode#
A 5.1 channel surround setup was detected.
const SPEAKER_SURROUND_71 = 3 enum SpeakerMode#
A 7.1 channel surround setup was detected.
const PLAYBACK_TYPE_DEFAULT = 0 enum PlaybackType#
The playback will be considered of the type declared at ProjectSettings.audio/general/default_playback_type.
const PLAYBACK_TYPE_STREAM = 1 enum PlaybackType#
Force the playback to be considered as a stream.
const PLAYBACK_TYPE_SAMPLE = 2 enum PlaybackType#
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.
const PLAYBACK_TYPE_MAX = 3 enum PlaybackType#
Represents the size of the PlaybackType enum.
Constructors #
Enums #
SpeakerMode#
enum SpeakerMode {
SPEAKER_MODE_STEREO = 0,
SPEAKER_SURROUND_31 = 1,
SPEAKER_SURROUND_51 = 2,
SPEAKER_SURROUND_71 = 3,
}PlaybackType#
enum PlaybackType {
PLAYBACK_TYPE_DEFAULT = 0,
PLAYBACK_TYPE_STREAM = 1,
PLAYBACK_TYPE_SAMPLE = 2,
PLAYBACK_TYPE_MAX = 3,
} Operators #
Signals #
signal bus_layout_changed()#
Emitted when an audio bus is added, deleted, or moved.
signal bus_renamed(new_name: StringName)#
Emitted when the audio bus at bus_index is renamed from old_name to new_name.