[Downmixer] Only downmix to stereo if not stereo
When downmixing to mono, only downmix to stereo first if the source is not already stereo. Signed-off-by: Christopher Snowhill <kode54@gmail.com>main
parent
000a2e0cb6
commit
8bc9738ccb
|
@ -149,10 +149,12 @@ static void downmix_to_stereo(const float *inBuffer, int channels, uint32_t conf
|
||||||
|
|
||||||
static void downmix_to_mono(const float *inBuffer, int channels, uint32_t config, float *outBuffer, size_t count) {
|
static void downmix_to_mono(const float *inBuffer, int channels, uint32_t config, float *outBuffer, size_t count) {
|
||||||
float tempBuffer[count * 2];
|
float tempBuffer[count * 2];
|
||||||
downmix_to_stereo(inBuffer, channels, config, tempBuffer, count);
|
if(channels > 2 || config != AudioConfigStereo) {
|
||||||
inBuffer = tempBuffer;
|
downmix_to_stereo(inBuffer, channels, config, tempBuffer, count);
|
||||||
channels = 2;
|
inBuffer = tempBuffer;
|
||||||
config = AudioConfigStereo;
|
channels = 2;
|
||||||
|
config = AudioConfigStereo;
|
||||||
|
}
|
||||||
cblas_scopy((int)count, inBuffer, 2, outBuffer, 1);
|
cblas_scopy((int)count, inBuffer, 2, outBuffer, 1);
|
||||||
vDSP_vadd(outBuffer, 1, inBuffer + 1, 2, outBuffer, 1, count);
|
vDSP_vadd(outBuffer, 1, inBuffer + 1, 2, outBuffer, 1, count);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue