From 16f0a95a30c969c9951e10e2c03bba073bafd3c7 Mon Sep 17 00:00:00 2001 From: oparviai Date: Tue, 24 Aug 2010 15:53:56 +0000 Subject: [PATCH] Relaxed peak detection low limit from 1e-6 to 1e-9 to improve detections --- source/SoundTouch/BPMDetect.cpp | 2 +- source/SoundTouch/PeakFinder.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/SoundTouch/BPMDetect.cpp b/source/SoundTouch/BPMDetect.cpp index 32c80ba..6baaecd 100644 --- a/source/SoundTouch/BPMDetect.cpp +++ b/source/SoundTouch/BPMDetect.cpp @@ -332,7 +332,7 @@ float BPMDetect::getBpm() peakPos = peakFinder.detectPeak(xcorr, windowStart, windowLen); assert(decimateBy != 0); - if (peakPos < 1e-6) return 0.0; // detection failed. + if (peakPos < 1e-9) return 0.0; // detection failed. // calculate BPM return (float)(60.0 * (((double)sampleRate / (double)decimateBy) / peakPos)); diff --git a/source/SoundTouch/PeakFinder.cpp b/source/SoundTouch/PeakFinder.cpp index 534f6cf..9ad601c 100644 --- a/source/SoundTouch/PeakFinder.cpp +++ b/source/SoundTouch/PeakFinder.cpp @@ -164,7 +164,7 @@ double PeakFinder::getPeakCenter(const float *data, int peakpos) const groundLevel = max(data[gp1], data[gp2]); peakLevel = data[peakpos]; - if (groundLevel < 1e-6) return 0; // ground level too small => detection failed + if (groundLevel < 1e-9) return 0; // ground level too small => detection failed if ((peakLevel / groundLevel) < 1.3) return 0; // peak less than 30% of the ground level => no good peak detected // calculate 70%-level of the peak