X-Git-Url: https://git.sesse.net/?p=pitch;a=blobdiff_plain;f=pitch.cpp;fp=pitch.cpp;h=97238f5f05b1a99113837029199f44434b1f220e;hp=1c272f1080b734bb7ae891611660edf6c915d2c0;hb=f4906bf100acb8c5875196b7c2306effdd6a091d;hpb=2c1300e8b921ba945d7a03e8a4706fcfc12d49aa diff --git a/pitch.cpp b/pitch.cpp index 1c272f1..97238f5 100644 --- a/pitch.cpp +++ b/pitch.cpp @@ -234,6 +234,9 @@ std::pair find_peak(double *in, unsigned num_samples) } } + if (best_bin == 0 || best_bin == num_samples / 2) { + return std::make_pair(-1.0, 0.0); + } std::pair peak = interpolate_peak(in[best_bin - 1], in[best_bin],