Player: set note and octave atomically

This commit is contained in:
Louis-Joseph Fournier 2016-01-14 15:56:19 +01:00
parent e45423edde
commit b9bf210551
5 changed files with 23 additions and 4 deletions

View file

@ -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()
}
}

View file

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

View file

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

View file

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

View file

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