diff --git a/qml/PlayerScreen.qml b/qml/PlayerScreen.qml index e18beb6..ea2f8f2 100644 --- a/qml/PlayerScreen.qml +++ b/qml/PlayerScreen.qml @@ -111,9 +111,11 @@ Item { //octave: tuner.octave onReleased: { - note = tuner.note = index % 12 - octave = tuner.octave = index / 12 - toise_octave.index = tuner.octave + note = index % 12 + octave = index / 12 + toise_octave.index = octave + // set octave and note atomically + tuner.SetNoteOctave(note, octave) toise_octave.updateFlickable() } } diff --git a/src/Tuner.cpp b/src/Tuner.cpp index 10d6407..46ce51a 100644 --- a/src/Tuner.cpp +++ b/src/Tuner.cpp @@ -104,6 +104,14 @@ void Tuner::SetNote(int note) emit resultChanged(); } +void Tuner::SetNoteOctave(int note, int octave) +{ + result.note = note; + result.octave = octave; + worker->SetNoteOctave(note, octave); + emit resultChanged(); +} + double Tuner::GetDeviation() { return result.deviation; diff --git a/src/Tuner.hpp b/src/Tuner.hpp index 1317245..5919ce3 100644 --- a/src/Tuner.hpp +++ b/src/Tuner.hpp @@ -71,6 +71,7 @@ class Tuner : public QObject { // slots from worker void ResultUpdated(const PitchDetection::PitchResult &result); void TemperamentListUpdated(const QStringList &list); + void SetNoteOctave(int note, int octave); signals: // signals to UI diff --git a/src/TunerWorker.cpp b/src/TunerWorker.cpp index 7f3419f..661b0ce 100644 --- a/src/TunerWorker.cpp +++ b/src/TunerWorker.cpp @@ -134,7 +134,6 @@ void TunerWorker::SetNote(int note) mutex.unlock(); } - void TunerWorker::SetOctave(int octave) { mutex.lock(); @@ -142,6 +141,14 @@ void TunerWorker::SetOctave(int octave) mutex.unlock(); } +void TunerWorker::SetNoteOctave(int note, int octave) +{ + mutex.lock(); + note_to_update = note; + octave_to_update = octave; + mutex.unlock(); +} + void TunerWorker::Entry() { cerr << __func__ << endl; diff --git a/src/TunerWorker.hpp b/src/TunerWorker.hpp index 1dd920f..fe0071c 100644 --- a/src/TunerWorker.hpp +++ b/src/TunerWorker.hpp @@ -67,6 +67,7 @@ class TunerWorker : public QObject { void SetOctave(int octave); void Entry(); void Quit(); + void SetNoteOctave(int note, int octave); /// write a file with raw audio static void set_record(const char *filename_record);