diff --git a/src/Tuner.cpp b/src/Tuner.cpp index 951f243..1e43826 100644 --- a/src/Tuner.cpp +++ b/src/Tuner.cpp @@ -74,6 +74,7 @@ void Tuner::Start() cerr << __func__ << endl; count_found = count_not_found = 0; nb_sample_running = 0; + note_found = octave_found = -1; ResetDeviation(); blank_prevent(true); high_filter->Clear(); @@ -123,13 +124,13 @@ void Tuner::UpdateDeviation(double d) deviation_values[(deviation_start + nb_deviation) % nbDeviationValues] = d; nb_deviation++; deviation_sum += d; - deviation = deviation_sum / nb_deviation; } void Tuner::SetFound(int n, int o, double d) { - if (n != note_found) { + if (n != note_found || o != octave_found) { note_found = n; + octave_found = o; count_found = 0; SetNotFound(); @@ -151,6 +152,7 @@ void Tuner::SetFound(int n, int o, double d) octaveChanged(); } UpdateDeviation(d); + deviation = deviation_sum / nb_deviation; deviationChanged(); } else { diff --git a/src/Tuner.hpp b/src/Tuner.hpp index fc77cb1..74d6ed7 100644 --- a/src/Tuner.hpp +++ b/src/Tuner.hpp @@ -27,7 +27,7 @@ class Tuner : public QObject { bool running, found; double freq, deviation; int note, octave, nb_sample_running; - int note_found, count_found, count_not_found; + int note_found, octave_found, count_found, count_not_found; int nb_deviation, deviation_start; double deviation_sum; diff --git a/src/audio/ZeroCross.cpp b/src/audio/ZeroCross.cpp index eaebf57..11333e4 100644 --- a/src/audio/ZeroCross.cpp +++ b/src/audio/ZeroCross.cpp @@ -73,7 +73,7 @@ PatternMatch FindPattern(const vector &values, double pattern_min, doub if (interval > pattern_max) break; res = IsPattern(values, interval); - // cout << " " << res.time << " " << 16000/res.time << " " << res.time_deviation << " " << res.energy_deviation << endl; + //cout << " " << res.time << " " << 16000/res.time << " " << res.time_deviation << " " << res.energy_deviation << endl; if (res.time && ((res.time_deviation < best.time_deviation && best.time_deviation > CORRECT_TIME_DEVIATION_NO_LOWER) || best.time == 0)) { if (best.time && best.time_deviation < CORRECT_TIME_DEVIATION && best.time_deviation / res.time_deviation < MAX_TIME_DEVIATION_FACTOR_MULTIPLE) { double div = res.time / best.time;