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.
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.
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".
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 playback_speed_scale.
Adds an AudioEffect effect to the bus bus_idx at at_position.
Generates an AudioBusLayout using the available buses and effects.
Returns the AudioEffect at position effect_idx in bus bus_idx.
Returns the AudioEffectInstance assigned to the given bus and effect indices (and optionally channel).
Returns the index of the bus with the name bus_name. Returns -1 if no bus with the specified name exist.
Returns the volume of the bus at index bus_idx as a linear value.
Note: The returned value is equivalent to the result of db_to_linear() on the result of get_bus_volume_db().
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.
Returns the absolute size of the microphone input buffer. This is set to a multiple of the audio latency and can be used to estimate the minimum rate at which the frames need to be fetched.
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.
Returns a PackedVector2Array containing exactly frames audio samples from the internal microphone buffer if available, otherwise returns an empty PackedVector2Array.
The buffer is filled at the rate of get_input_mix_rate() frames per second when set_input_device_active() has successfully been set to true.
The samples are signed floating-point PCM values between -1 and 1.
Returns the number of frames available to read using get_input_frames().
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.
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().
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.
Overwrites the currently used AudioBusLayout.
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 linear_to_db() on a value.
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.
If active is true, starts the microphone input stream specified by input_device or returns an error if it failed.
If active is false, stops the input stream if it is running.
Unlocks the audio driver's main loop. (After locking it, you should always unlock it.)
SPEAKER_MODE_STEREO = 0Two or fewer speakers were detected.
SPEAKER_SURROUND_31 = 1A 3.1 channel surround setup was detected.
SPEAKER_SURROUND_51 = 2A 5.1 channel surround setup was detected.
SPEAKER_SURROUND_71 = 3A 7.1 channel surround setup was detected.
PLAYBACK_TYPE_DEFAULT = 0The playback will be considered of the type declared at ProjectSettings.audio/general/default_playback_type.
PLAYBACK_TYPE_STREAM = 1Force the playback to be considered as a stream.
PLAYBACK_TYPE_SAMPLE = 2Force 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.
PLAYBACK_TYPE_MAX = 3Represents the size of the PlaybackType enum.