Fix lower limit for overtone detection.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Apr 2006 12:09:17 +0000 (12:09 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Apr 2006 12:09:17 +0000 (12:09 +0000)
pitch.cpp

index 91afda5..eac947c 100644 (file)
--- a/pitch.cpp
+++ b/pitch.cpp
@@ -259,6 +259,8 @@ std::pair<double, double> adjust_for_overtones(std::pair<double, double> base, d
                unsigned middle = unsigned(floor(freq_to_bin(base.first, num_samples) * i + 0.5));
                unsigned lower = middle - (i+1)/2, upper = middle + (i+1)/2;
 
+               if (lower < 1)
+                       lower = 1;
                if (upper >= num_samples)
                        upper = num_samples - 2;