X-Git-Url: https://git.sesse.net/?p=pitch;a=blobdiff_plain;f=pitchdetector.cpp;h=3bf907a66be76ecb59e535f5919f1f4c240754ca;hp=02c7035754e2bf9b4940ec4823e951345f900069;hb=d1ad6523c5cf3b96558338c82d1cb4ff2f058e35;hpb=acfe6ba53cbe46bbc35959602c2835906e3467e7 diff --git a/pitchdetector.cpp b/pitchdetector.cpp index 02c7035..3bf907a 100644 --- a/pitchdetector.cpp +++ b/pitchdetector.cpp @@ -107,7 +107,8 @@ std::pair 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 && - 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 @@ -251,7 +252,7 @@ std::pair PitchDetector::interpolate_peak(double ym1, double y0, double c = y0; double xmax = (ym1 - y1) / (2.0 * (y1 + ym1 - 2.0 * y0)); - double ymax = 20.0 * (a * xmax * xmax + b * xmax + c) - 80.0; + double ymax = 20.0 * (a * xmax * xmax + b * xmax + c) - 70.0; return std::make_pair(xmax, ymax); }