Tuner: fix octave and deviation post-filters

This commit is contained in:
Louis-Joseph Fournier 2016-01-03 13:18:42 +01:00
parent a5e74d6300
commit ef3f8db1d3
3 changed files with 6 additions and 4 deletions

View file

@ -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 {

View file

@ -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;

View file

@ -73,7 +73,7 @@ PatternMatch FindPattern(const vector<Pattern> &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;