Commit 5aee5d65 authored by Steven Noonan's avatar Steven Noonan Committed by David Reid

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: default avatarSteven Noonan <steven@uplinklabs.net>
parent 1a1bd812
...@@ -51293,19 +51293,8 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert ...@@ -51293,19 +51293,8 @@ MA_API ma_result ma_channel_converter_init_preallocated(const ma_channel_convert
case ma_channel_mix_mode_simple: case ma_channel_mix_mode_simple:
{ {
/* In simple mode, excess channels need to be silenced or dropped. */ /* In simple mode, only set weights for channels that have exactly matching types, leave the rest at
ma_uint32 iChannel; zero. The 1:1 mappings have already been covered before this switch statement. */
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);
}
}
}
} break; } break;
case ma_channel_mix_mode_rectangular: case ma_channel_mix_mode_rectangular:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment