]> git.sesse.net Git - pitch/commitdiff
Don't choose impossible tones as undertones.
authorsgunderson@bigfoot.com <>
Tue, 5 Feb 2008 01:53:19 +0000 (02:53 +0100)
committersgunderson@bigfoot.com <>
Tue, 5 Feb 2008 01:53:19 +0000 (02:53 +0100)
pitchdetector.cpp

index 02c7035754e2bf9b4940ec4823e951345f900069..69888642310beab15ed3ac47a198bbd73943b703 100644 (file)
@@ -107,7 +107,8 @@ std::pair<double, double> PitchDetector::find_peak(double *in, unsigned num_samp
        // see if we might have hit an overtone (set a limit of 10dB)
        for (unsigned i = 6; i >= 1; --i) {
                if (best_bin != best_bin / i &&
        // see if we might have hit an overtone (set a limit of 10dB)
        for (unsigned i = 6; i >= 1; --i) {
                if (best_bin != best_bin / i &&
-                   20.0 * log10(in[best_bin] / in[best_bin / i]) < 10.0f) {
+                   20.0 * log10(in[best_bin] / in[best_bin / i]) < 10.0f &&
+                   best_bin / i >= 5) {
 #if 0
                        printf("Overtone of degree %u!\n", i);
 #endif
 #if 0
                        printf("Overtone of degree %u!\n", i);
 #endif