From: sgunderson@bigfoot.com <> Date: Sat, 8 Dec 2007 14:41:39 +0000 (+0100) Subject: Tuned a few parameters a bit to increase guitar tuning accuracy. X-Git-Url: https://git.sesse.net/?p=pitch;a=commitdiff_plain;h=acfe6ba53cbe46bbc35959602c2835906e3467e7;hp=24d0e4fa9a93f86fffd7bca85510973c97dc0dec Tuned a few parameters a bit to increase guitar tuning accuracy. --- diff --git a/pitchdetector.cpp b/pitchdetector.cpp index cf0abe0..02c7035 100644 --- a/pitchdetector.cpp +++ b/pitchdetector.cpp @@ -80,6 +80,13 @@ std::pair PitchDetector::find_peak(double *in, unsigned num_samp best_peak = in[i]; best_bin = i; } +#if 0 + if (20.0 * log10(in[i] / fft_length) > 0.0) { + printf("PEAK: %+4.2f dB %5.2f Hz\n", + 20.0 * log10(in[i] / fft_length), + bin_to_freq(i, num_samples)); + } +#endif } if (best_bin == 0 || best_bin == num_samples / 2) { @@ -97,10 +104,10 @@ std::pair PitchDetector::find_peak(double *in, unsigned num_samp 20.0 * log10(in[best_bin/4] / fft_length)); #endif - // see if we might have hit an overtone (set a limit of 5dB) - for (unsigned i = 4; i >= 1; --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]) < 5.0f) { + 20.0 * log10(in[best_bin] / in[best_bin / i]) < 10.0f) { #if 0 printf("Overtone of degree %u!\n", i); #endif @@ -244,7 +251,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) - 90.0; + double ymax = 20.0 * (a * xmax * xmax + b * xmax + c) - 80.0; return std::make_pair(xmax, ymax); }