BPMDetect: Change correlation loop 'sum' variable type from double to float, because double causes big performance penalty for autovectorized code.

This commit is contained in:
Olli 2018-12-02 22:33:55 +02:00
parent 9205fc971e
commit eef1220d72

View File

@ -313,7 +313,7 @@ void BPMDetect::updateXCorr(int process_samples)
#pragma omp parallel for #pragma omp parallel for
for (offs = windowStart; offs < windowLen; offs ++) for (offs = windowStart; offs < windowLen; offs ++)
{ {
double sum; float sum;
int i; int i;
sum = 0; sum = 0;
@ -341,7 +341,6 @@ void BPMDetect::updateBeatPos(int process_samples)
// static double thr = 0.0003; // static double thr = 0.0003;
double posScale = (double)this->decimateBy / (double)this->sampleRate; double posScale = (double)this->decimateBy / (double)this->sampleRate;
int resetDur = (int)(0.12 / posScale + 0.5); int resetDur = (int)(0.12 / posScale + 0.5);
double corrScale = 1.0 / (double)(windowLen - windowStart);
// prescale pbuffer // prescale pbuffer
float tmp[XCORR_UPDATE_SEQUENCE / 2]; float tmp[XCORR_UPDATE_SEQUENCE / 2];
@ -353,7 +352,7 @@ void BPMDetect::updateBeatPos(int process_samples)
#pragma omp parallel for #pragma omp parallel for
for (int offs = windowStart; offs < windowLen; offs++) for (int offs = windowStart; offs < windowLen; offs++)
{ {
double sum = 0; float sum = 0;
for (int i = 0; i < process_samples; i++) for (int i = 0; i < process_samples; i++)
{ {
sum += tmp[i] * pBuffer[offs + i]; sum += tmp[i] * pBuffer[offs + i];