From eef1220d7200c5a67b156e85d8c2fbc5a80ca388 Mon Sep 17 00:00:00 2001 From: Olli Date: Sun, 2 Dec 2018 22:33:55 +0200 Subject: [PATCH] BPMDetect: Change correlation loop 'sum' variable type from double to float, because double causes big performance penalty for autovectorized code. --- source/SoundTouch/BPMDetect.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/SoundTouch/BPMDetect.cpp b/source/SoundTouch/BPMDetect.cpp index 3ecda49..5ad1926 100644 --- a/source/SoundTouch/BPMDetect.cpp +++ b/source/SoundTouch/BPMDetect.cpp @@ -313,7 +313,7 @@ void BPMDetect::updateXCorr(int process_samples) #pragma omp parallel for for (offs = windowStart; offs < windowLen; offs ++) { - double sum; + float sum; int i; sum = 0; @@ -341,7 +341,6 @@ void BPMDetect::updateBeatPos(int process_samples) // static double thr = 0.0003; double posScale = (double)this->decimateBy / (double)this->sampleRate; int resetDur = (int)(0.12 / posScale + 0.5); - double corrScale = 1.0 / (double)(windowLen - windowStart); // prescale pbuffer float tmp[XCORR_UPDATE_SEQUENCE / 2]; @@ -353,7 +352,7 @@ void BPMDetect::updateBeatPos(int process_samples) #pragma omp parallel for for (int offs = windowStart; offs < windowLen; offs++) { - double sum = 0; + float sum = 0; for (int i = 0; i < process_samples; i++) { sum += tmp[i] * pBuffer[offs + i];