Don't run adjust_for_overtones if we found no peak.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Apr 2006 12:06:00 +0000 (12:06 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Apr 2006 12:06:00 +0000 (12:06 +0000)
pitch.cpp

index c8246dc..72e9569 100644 (file)
--- a/pitch.cpp
+++ b/pitch.cpp
@@ -60,7 +60,8 @@ int main()
                fftw_execute(p);
                find_peak_magnitudes(out, bins, FFT_LENGTH);
                std::pair<double, double> peak = find_peak(bins, FFT_LENGTH);
-               peak = adjust_for_overtones(peak, bins, FFT_LENGTH);
+               if (beak.first > 0.0)
+                       peak = adjust_for_overtones(peak, bins, FFT_LENGTH);
 
                if (peak.first < 50.0 || peak.second - log10(FFT_LENGTH) < 0.0) {
 #if TUNING == WELL_TEMPERED_GUITAR