From 2c0f04bbeb91a51c595ff51ef6ced5f6bc37049f Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 26 Feb 2022 01:08:55 -0800 Subject: [PATCH] Possibly improve MAD sample conversion speed No idea if this brings a noticeable improvement, but it probably makes better sense to only do the division step one time instead of doing it twice interleaved when processing stereo files, which are the most common scenario anyway. Signed-off-by: Christopher Snowhill --- Plugins/MAD/MADDecoder.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/MAD/MADDecoder.m b/Plugins/MAD/MADDecoder.m index fb90ab162..621b3e55f 100644 --- a/Plugins/MAD/MADDecoder.m +++ b/Plugins/MAD/MADDecoder.m @@ -469,11 +469,11 @@ int ch; // samples [0 ... n] - float scale = (float)MAD_F_ONE; for(ch = 0; ch < channels; ch++) { vDSP_vflt32(&_synth.pcm.samples[ch][startingSample], 1, &_outputBuffer[ch], channels, _outputFrames); - vDSP_vsdiv(&_outputBuffer[ch], channels, &scale, &_outputBuffer[ch], channels, _outputFrames); } + float scale = (float)MAD_F_ONE; + vDSP_vsdiv(&_outputBuffer[0], 1, &scale, &_outputBuffer[0], 1, _outputFrames * channels); // Output to a file // FILE *f = fopen("data.raw", "a");