You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The AudioServer processes audio samples as a number of stereo channels,
which are copied to the audio driver buffers. This commit adds
the ability to remap AudioServer channels to different driver
channels, primarily for debugging purposes. The way it is configured
is with get/set methods on AudioServer, exposed in GDScript/C#.
This depends on the speaker_mode override PR godotengine#105934.
It only allows for remapping the stereo channels Godot works with, and
not for mixing left/right samples between channels.
Returns the mapping for the stereo channel index at [param output_channel]. Channel index values correspond to the following stereo channels:
126
+
- [code]0[/code]: Front left and right
127
+
- [code]1[/code]: Center and LFE (bass)
128
+
- [code]2[/code]: Back left and right
129
+
- [code]3[/code]: Side left and right
130
+
- [code]-1[/code]: Muted
131
+
The default is for the [param output_channel] to map to the same corresponding internal stereo channel.
132
+
</description>
133
+
</method>
121
134
<methodname="get_driver_name"qualifiers="const">
122
135
<returntype="String" />
123
136
<description>
@@ -322,6 +335,19 @@
322
335
[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.
323
336
</description>
324
337
</method>
338
+
<methodname="set_channel_remap">
339
+
<returntype="void" />
340
+
<paramindex="0"name="output_channel"type="int" />
341
+
<paramindex="1"name="source_channel"type="int" />
342
+
<description>
343
+
Given a stereo channel index [param output_channel], configures the [AudioServer] to map it to the internal channel [param source_channel]. Channel index values correspond to the following stereo channels:
344
+
- [code]0[/code]: Front left and right
345
+
- [code]1[/code]: Center and LFE (bass)
346
+
- [code]2[/code]: Back left and right
347
+
- [code]3[/code]: Side left and right
348
+
Setting an output channel to an invalid source channel (e.g. [code]-1[/code]) will mute output from that channel. If the current [method get_speaker_mode] does not use a particular channel, mapping that source channel to an output channel will mute the output channel.
// TODO: Buffer size is hardcoded for now. This would be really nice to have as a project setting because currently it limits audio latency to an absolute minimum of 11ms with default mix rate, but there's some additional work required to make that happen. See TODOs in `_mix_step_for_channel`.
1541
1576
// When this becomes a project setting, it should be specified in milliseconds rather than raw sample count, because 512 samples at 192khz is shorter than it is at 48khz, for example.
0 commit comments