Debian Codegraph @

doc/classes/AudioServer.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="AudioServer" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Server interface for low-level audio access.
5 </brief_description>
6 <description>
7 [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.
8 </description>
9 <tutorials>
10 <link title="Audio buses">$DOCS_URL/tutorials/audio/audio_buses.html</link>
11 <link title="Audio Device Changer Demo">https://godotengine.org/asset-library/asset/2758</link>
12 <link title="Audio Microphone Record Demo">https://godotengine.org/asset-library/asset/2760</link>
13 <link title="Audio Spectrum Visualizer Demo">https://godotengine.org/asset-library/asset/2762</link>
14 </tutorials>
15 <methods>
16 <method name="add_bus">
17 <return type="void" />
18 <param index="0" name="at_position" type="int" default="-1" />
19 <description>
20 Adds a bus at [param at_position].
21 </description>
22 </method>
23 <method name="add_bus_effect">
24 <return type="void" />
25 <param index="0" name="bus_idx" type="int" />
26 <param index="1" name="effect" type="AudioEffect" />
27 <param index="2" name="at_position" type="int" default="-1" />
28 <description>
29 Adds an [AudioEffect] effect to the bus [param bus_idx] at [param at_position].
30 </description>
31 </method>
32 <method name="generate_bus_layout" qualifiers="const">
33 <return type="AudioBusLayout" />
34 <description>
35 Generates an [AudioBusLayout] using the available buses and effects.
36 </description>
37 </method>
38 <method name="get_bus_channels" qualifiers="const">
39 <return type="int" />
40 <param index="0" name="bus_idx" type="int" />
41 <description>
42 Returns the number of channels of the bus at index [param bus_idx].
43 </description>
44 </method>
45 <method name="get_bus_effect">
46 <return type="AudioEffect" />
47 <param index="0" name="bus_idx" type="int" />
48 <param index="1" name="effect_idx" type="int" />
49 <description>
50 Returns the [AudioEffect] at position [param effect_idx] in bus [param bus_idx].
51 </description>
52 </method>
53 <method name="get_bus_effect_count">
54 <return type="int" />
55 <param index="0" name="bus_idx" type="int" />
56 <description>
57 Returns the number of effects on the bus at [param bus_idx].
58 </description>
59 </method>
60 <method name="get_bus_effect_instance">
61 <return type="AudioEffectInstance" />
62 <param index="0" name="bus_idx" type="int" />
63 <param index="1" name="effect_idx" type="int" />
64 <param index="2" name="channel" type="int" default="0" />
65 <description>
66 Returns the [AudioEffectInstance] assigned to the given bus and effect indices (and optionally channel).
67 </description>
68 </method>
69 <method name="get_bus_index" qualifiers="const">
70 <return type="int" />
71 <param index="0" name="bus_name" type="StringName" />
72 <description>
73 Returns the index of the bus with the name [param bus_name]. Returns [code]-1[/code] if no bus with the specified name exist.
74 </description>
75 </method>
76 <method name="get_bus_name" qualifiers="const">
77 <return type="String" />
78 <param index="0" name="bus_idx" type="int" />
79 <description>
80 Returns the name of the bus with the index [param bus_idx].
81 </description>
82 </method>
83 <method name="get_bus_peak_volume_left_db" qualifiers="const">
84 <return type="float" />
85 <param index="0" name="bus_idx" type="int" />
86 <param index="1" name="channel" type="int" />
87 <description>
88 Returns the peak volume of the left speaker at bus index [param bus_idx] and channel index [param channel].
89 </description>
90 </method>
91 <method name="get_bus_peak_volume_right_db" qualifiers="const">
92 <return type="float" />
93 <param index="0" name="bus_idx" type="int" />
94 <param index="1" name="channel" type="int" />
95 <description>
96 Returns the peak volume of the right speaker at bus index [param bus_idx] and channel index [param channel].
97 </description>
98 </method>
99 <method name="get_bus_send" qualifiers="const">
100 <return type="StringName" />
101 <param index="0" name="bus_idx" type="int" />
102 <description>
103 Returns the name of the bus that the bus at index [param bus_idx] sends to.
104 </description>
105 </method>
106 <method name="get_bus_volume_db" qualifiers="const">
107 <return type="float" />
108 <param index="0" name="bus_idx" type="int" />
109 <description>
110 Returns the volume of the bus at index [param bus_idx] in dB.
111 </description>
112 </method>
113 <method name="get_bus_volume_linear" qualifiers="const">
114 <return type="float" />
115 <param index="0" name="bus_idx" type="int" />
116 <description>
117 Returns the volume of the bus at index [param bus_idx] as a linear value.
118 [b]Note:[/b] The returned value is equivalent to the result of [method @GlobalScope.db_to_linear] on the result of [method get_bus_volume_db].
119 </description>
120 </method>
121 <method name="get_driver_name" qualifiers="const">
122 <return type="String" />
123 <description>
124 Returns the name of the current audio driver. The default usually depends on the operating system, but may be overridden via the [code]--audio-driver[/code] [url=$DOCS_URL/tutorials/editor/command_line_tutorial.html]command line argument[/url]. [code]--headless[/code] also automatically sets the audio driver to [code]Dummy[/code]. See also [member ProjectSettings.audio/driver/driver].
125 </description>
126 </method>
127 <method name="get_input_buffer_length_frames" experimental="">
128 <return type="int" />
129 <description>
130 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.
131 </description>
132 </method>
133 <method name="get_input_device_list">
134 <return type="PackedStringArray" />
135 <description>
136 Returns the names of all audio input devices detected on the system.
137 [b]Note:[/b] [member ProjectSettings.audio/driver/enable_input] must be [code]true[/code] for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.
138 </description>
139 </method>
140 <method name="get_input_frames" experimental="">
141 <return type="PackedVector2Array" />
142 <param index="0" name="frames" type="int" />
143 <description>
144 Returns a [PackedVector2Array] containing exactly [param frames] audio samples from the internal microphone buffer if available, otherwise returns an empty [PackedVector2Array].
145 The buffer is filled at the rate of [method get_input_mix_rate] frames per second when [method set_input_device_active] has successfully been set to [code]true[/code].
146 The samples are signed floating-point PCM values between [code]-1[/code] and [code]1[/code].
147 </description>
148 </method>
149 <method name="get_input_frames_available" experimental="">
150 <return type="int" />
151 <description>
152 Returns the number of frames available to read using [method get_input_frames].
153 </description>
154 </method>
155 <method name="get_input_mix_rate" qualifiers="const">
156 <return type="float" />
157 <description>
158 Returns the sample rate at the input of the [AudioServer].
159 </description>
160 </method>
161 <method name="get_mix_rate" qualifiers="const">
162 <return type="float" />
163 <description>
164 Returns the sample rate at the output of the [AudioServer].
165 </description>
166 </method>
167 <method name="get_output_device_list">
168 <return type="PackedStringArray" />
169 <description>
170 Returns the names of all audio output devices detected on the system.
171 </description>
172 </method>
173 <method name="get_output_latency" qualifiers="const">
174 <return type="float" />
175 <description>
176 Returns the audio driver's effective output latency. This is based on [member ProjectSettings.audio/driver/output_latency], but the exact returned value will differ depending on the operating system and audio driver.
177 [b]Note:[/b] This can be expensive; it is not recommended to call [method get_output_latency] every frame.
178 </description>
179 </method>
180 <method name="get_speaker_mode" qualifiers="const">
181 <return type="int" enum="AudioServer.SpeakerMode" />
182 <description>
183 Returns the speaker configuration.
184 </description>
185 </method>
186 <method name="get_time_since_last_mix" qualifiers="const">
187 <return type="float" />
188 <description>
189 Returns the relative time since the last mix occurred.
190 </description>
191 </method>
192 <method name="get_time_to_next_mix" qualifiers="const">
193 <return type="float" />
194 <description>
195 Returns the relative time until the next mix occurs.
196 </description>
197 </method>
198 <method name="is_bus_bypassing_effects" qualifiers="const">
199 <return type="bool" />
200 <param index="0" name="bus_idx" type="int" />
201 <description>
202 If [code]true[/code], the bus at index [param bus_idx] is bypassing effects.
203 </description>
204 </method>
205 <method name="is_bus_effect_enabled" qualifiers="const">
206 <return type="bool" />
207 <param index="0" name="bus_idx" type="int" />
208 <param index="1" name="effect_idx" type="int" />
209 <description>
210 If [code]true[/code], the effect at index [param effect_idx] on the bus at index [param bus_idx] is enabled.
211 </description>
212 </method>
213 <method name="is_bus_mute" qualifiers="const">
214 <return type="bool" />
215 <param index="0" name="bus_idx" type="int" />
216 <description>
217 If [code]true[/code], the bus at index [param bus_idx] is muted.
218 </description>
219 </method>
220 <method name="is_bus_solo" qualifiers="const">
221 <return type="bool" />
222 <param index="0" name="bus_idx" type="int" />
223 <description>
224 If [code]true[/code], the bus at index [param bus_idx] is in solo mode.
225 </description>
226 </method>
227 <method name="is_stream_registered_as_sample" experimental="">
228 <return type="bool" />
229 <param index="0" name="stream" type="AudioStream" />
230 <description>
231 If [code]true[/code], the stream is registered as a sample. The engine will not have to register it before playing the sample.
232 If [code]false[/code], the stream will have to be registered before playing it. To prevent lag spikes, register the stream as sample with [method register_stream_as_sample].
233 </description>
234 </method>
235 <method name="lock">
236 <return type="void" />
237 <description>
238 Locks the audio driver's main loop.
239 [b]Note:[/b] Remember to unlock it afterwards.
240 </description>
241 </method>
242 <method name="move_bus">
243 <return type="void" />
244 <param index="0" name="index" type="int" />
245 <param index="1" name="to_index" type="int" />
246 <description>
247 Moves the bus from index [param index] to index [param to_index].
248 </description>
249 </method>
250 <method name="register_stream_as_sample" experimental="">
251 <return type="void" />
252 <param index="0" name="stream" type="AudioStream" />
253 <description>
254 Forces the registration of a stream as a sample.
255 [b]Note:[/b] 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.
256 </description>
257 </method>
258 <method name="remove_bus">
259 <return type="void" />
260 <param index="0" name="index" type="int" />
261 <description>
262 Removes the bus at index [param index].
263 </description>
264 </method>
265 <method name="remove_bus_effect">
266 <return type="void" />
267 <param index="0" name="bus_idx" type="int" />
268 <param index="1" name="effect_idx" type="int" />
269 <description>
270 Removes the effect at index [param effect_idx] from the bus at index [param bus_idx].
271 </description>
272 </method>
273 <method name="set_bus_bypass_effects">
274 <return type="void" />
275 <param index="0" name="bus_idx" type="int" />
276 <param index="1" name="enable" type="bool" />
277 <description>
278 If [code]true[/code], the bus at index [param bus_idx] is bypassing effects.
279 </description>
280 </method>
281 <method name="set_bus_effect_enabled">
282 <return type="void" />
283 <param index="0" name="bus_idx" type="int" />
284 <param index="1" name="effect_idx" type="int" />
285 <param index="2" name="enabled" type="bool" />
286 <description>
287 If [code]true[/code], the effect at index [param effect_idx] on the bus at index [param bus_idx] is enabled.
288 </description>
289 </method>
290 <method name="set_bus_layout">
291 <return type="void" />
292 <param index="0" name="bus_layout" type="AudioBusLayout" />
293 <description>
294 Overwrites the currently used [AudioBusLayout].
295 </description>
296 </method>
297 <method name="set_bus_mute">
298 <return type="void" />
299 <param index="0" name="bus_idx" type="int" />
300 <param index="1" name="enable" type="bool" />
301 <description>
302 If [code]true[/code], the bus at index [param bus_idx] is muted.
303 </description>
304 </method>
305 <method name="set_bus_name">
306 <return type="void" />
307 <param index="0" name="bus_idx" type="int" />
308 <param index="1" name="name" type="String" />
309 <description>
310 Sets the name of the bus at index [param bus_idx] to [param name].
311 </description>
312 </method>
313 <method name="set_bus_send">
314 <return type="void" />
315 <param index="0" name="bus_idx" type="int" />
316 <param index="1" name="send" type="StringName" />
317 <description>
318 Connects the output of the bus at [param bus_idx] to the bus named [param send].
319 </description>
320 </method>
321 <method name="set_bus_solo">
322 <return type="void" />
323 <param index="0" name="bus_idx" type="int" />
324 <param index="1" name="enable" type="bool" />
325 <description>
326 If [code]true[/code], the bus at index [param bus_idx] is in solo mode.
327 </description>
328 </method>
329 <method name="set_bus_volume_db">
330 <return type="void" />
331 <param index="0" name="bus_idx" type="int" />
332 <param index="1" name="volume_db" type="float" />
333 <description>
334 Sets the volume in decibels of the bus at index [param bus_idx] to [param volume_db].
335 </description>
336 </method>
337 <method name="set_bus_volume_linear">
338 <return type="void" />
339 <param index="0" name="bus_idx" type="int" />
340 <param index="1" name="volume_linear" type="float" />
341 <description>
342 Sets the volume as a linear value of the bus at index [param bus_idx] to [param volume_linear].
343 [b]Note:[/b] Using this method is equivalent to calling [method set_bus_volume_db] with the result of [method @GlobalScope.linear_to_db] on a value.
344 </description>
345 </method>
346 <method name="set_enable_tagging_used_audio_streams">
347 <return type="void" />
348 <param index="0" name="enable" type="bool" />
349 <description>
350 If set to [code]true[/code], all instances of [AudioStreamPlayback] will call [method AudioStreamPlayback._tag_used_streams] every mix step.
351 [b]Note:[/b] This is enabled by default in the editor, as it is used by editor plugins for the audio stream previews.
352 </description>
353 </method>
354 <method name="set_input_device_active" experimental="">
355 <return type="int" enum="Error" />
356 <param index="0" name="active" type="bool" />
357 <description>
358 If [param active] is [code]true[/code], starts the microphone input stream specified by [member input_device] or returns an error if it failed.
359 If [param active] is [code]false[/code], stops the input stream if it is running.
360 </description>
361 </method>
362 <method name="swap_bus_effects">
363 <return type="void" />
364 <param index="0" name="bus_idx" type="int" />
365 <param index="1" name="effect_idx" type="int" />
366 <param index="2" name="by_effect_idx" type="int" />
367 <description>
368 Swaps the position of two effects in bus [param bus_idx].
369 </description>
370 </method>
371 <method name="unlock">
372 <return type="void" />
373 <description>
374 Unlocks the audio driver's main loop. (After locking it, you should always unlock it.)
375 </description>
376 </method>
377 </methods>
378 <members>
379 <member name="bus_count" type="int" setter="set_bus_count" getter="get_bus_count" default="1">
380 Number of available audio buses.
381 </member>
382 <member name="input_device" type="String" setter="set_input_device" getter="get_input_device" default="&quot;Default&quot;">
383 Name of the current device for audio input (see [method 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 [code]"Default"[/code] will record audio on the system-wide default audio input. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code].
384 [b]Note:[/b] [member ProjectSettings.audio/driver/enable_input] must be [code]true[/code] for audio input to work. See also that setting's description for caveats related to permissions and operating system privacy settings.
385 </member>
386 <member name="output_device" type="String" setter="set_output_device" getter="get_output_device" default="&quot;Default&quot;">
387 Name of the current device for audio output (see [method 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 [code]"Default"[/code] will play audio on the system-wide default audio output. If an invalid device name is set, the value will be reverted back to [code]"Default"[/code].
388 </member>
389 <member name="playback_speed_scale" type="float" setter="set_playback_speed_scale" getter="get_playback_speed_scale" default="1.0">
390 Scales the rate at which audio is played (i.e. setting it to [code]0.5[/code] will make the audio be played at half its speed). See also [member Engine.time_scale] to affect the general simulation speed, which is independent from [member AudioServer.playback_speed_scale].
391 </member>
392 </members>
393 <signals>
394 <signal name="bus_layout_changed">
395 <description>
396 Emitted when an audio bus is added, deleted, or moved.
397 </description>
398 </signal>
399 <signal name="bus_renamed">
400 <param index="0" name="bus_index" type="int" />
401 <param index="1" name="old_name" type="StringName" />
402 <param index="2" name="new_name" type="StringName" />
403 <description>
404 Emitted when the audio bus at [param bus_index] is renamed from [param old_name] to [param new_name].
405 </description>
406 </signal>
407 </signals>
408 <constants>
409 <constant name="SPEAKER_MODE_STEREO" value="0" enum="SpeakerMode">
410 Two or fewer speakers were detected.
411 </constant>
412 <constant name="SPEAKER_SURROUND_31" value="1" enum="SpeakerMode">
413 A 3.1 channel surround setup was detected.
414 </constant>
415 <constant name="SPEAKER_SURROUND_51" value="2" enum="SpeakerMode">
416 A 5.1 channel surround setup was detected.
417 </constant>
418 <constant name="SPEAKER_SURROUND_71" value="3" enum="SpeakerMode">
419 A 7.1 channel surround setup was detected.
420 </constant>
421 <constant name="PLAYBACK_TYPE_DEFAULT" value="0" enum="PlaybackType" experimental="">
422 The playback will be considered of the type declared at [member ProjectSettings.audio/general/default_playback_type].
423 </constant>
424 <constant name="PLAYBACK_TYPE_STREAM" value="1" enum="PlaybackType" experimental="">
425 Force the playback to be considered as a stream.
426 </constant>
427 <constant name="PLAYBACK_TYPE_SAMPLE" value="2" enum="PlaybackType" experimental="">
428 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.
429 [b]Note:[/b] Only currently supported on the web platform.
430 [b]Note:[/b] [AudioEffect]s are not supported when playback is considered as a sample.
431 </constant>
432 <constant name="PLAYBACK_TYPE_MAX" value="3" enum="PlaybackType" experimental="">
433 Represents the size of the [enum PlaybackType] enum.
434 </constant>
435 </constants>
436 </class>