mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
channel mapping: treat "simple" mix mode as a 1:1 mapping only mode
We already map the in:out 1:1 mappings above the switch statement, but the code for "simple" mapping stomps on the mappings. Also, even before that loop was added, mix mode "simple" did not necessarily map to the same channel types you'd expect. For example, if you have a 6-channel input and 8-channel output, you would get something like this with "simple": Correct: CHANNEL_FRONT_LEFT -> CHANNEL_FRONT_LEFT Correct: CHANNEL_FRONT_RIGHT -> CHANNEL_FRONT_RIGHT Correct: CHANNEL_FRONT_CENTER -> CHANNEL_FRONT_CENTER Correct: CHANNEL_LFE -> CHANNEL_LFE Wrong: CHANNEL_SIDE_LEFT -> CHANNEL_BACK_LEFT Wrong: CHANNEL_SIDE_RIGHT -> CHANNEL_BACK_RIGHT Instead of just assuming the input channel map is a truncation of the output channel map and has channels in the same order, just keep the existing 1:1 mappings and hope that's sufficient. Signed-off-by: Steven Noonan <steven@uplinklabs.net>
This commit is contained in:
committed by
David Reid
parent
1a1bd8129b
commit
5aee5d656a
+2
-13
@@ -51293,19 +51293,8 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert
|
||||
|
||||
case ma_channel_mix_mode_simple:
|
||||
{
|
||||
/* In simple mode, excess channels need to be silenced or dropped. */
|
||||
ma_uint32 iChannel;
|
||||
for (iChannel = 0; iChannel < ma_min(pConverter->channelsIn, pConverter->channelsOut); iChannel += 1) {
|
||||
if (pConverter->format == ma_format_f32) {
|
||||
if (pConverter->weights.f32[iChannel][iChannel] == 0) {
|
||||
pConverter->weights.f32[iChannel][iChannel] = 1;
|
||||
}
|
||||
} else {
|
||||
if (pConverter->weights.s16[iChannel][iChannel] == 0) {
|
||||
pConverter->weights.s16[iChannel][iChannel] = ma_channel_converter_float_to_fixed(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* In simple mode, only set weights for channels that have exactly matching types, leave the rest at
|
||||
zero. The 1:1 mappings have already been covered before this switch statement. */
|
||||
} break;
|
||||
|
||||
case ma_channel_mix_mode_rectangular:
|
||||
|
||||
Reference in New Issue
Block a user