From 30c93c96a72ce0ffb909857658faf844a2d25672 Mon Sep 17 00:00:00 2001 From: Louis-Joseph Fournier Date: Tue, 5 Jan 2016 22:55:08 +0100 Subject: [PATCH] Display pause icon and several details --- Tuner.pro | 3 ++- images/icon-m-pause.svg | 18 ++++++++++++++++++ images/images.qrc | 5 +++++ qml/DesktopTheme.qml | 2 ++ qml/TunerScreen.qml | 16 ++++++++++++++-- src/PitchDetection.cpp | 9 ++++++++- src/TunerWorker.cpp | 8 ++++++-- src/scale/Scale.cpp | 2 +- 8 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 images/icon-m-pause.svg create mode 100644 images/images.qrc diff --git a/Tuner.pro b/Tuner.pro index 78915e5..8085f9a 100644 --- a/Tuner.pro +++ b/Tuner.pro @@ -28,4 +28,5 @@ HEADERS += \ RESOURCES += \ qml/desktop.qrc \ - data/temperaments.qrc + data/temperaments.qrc \ + images/images.qrc diff --git a/images/icon-m-pause.svg b/images/icon-m-pause.svg new file mode 100644 index 0000000..eaeb9dc --- /dev/null +++ b/images/icon-m-pause.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/images/images.qrc b/images/images.qrc new file mode 100644 index 0000000..2a3ddc0 --- /dev/null +++ b/images/images.qrc @@ -0,0 +1,5 @@ + + +icon-m-pause.svg + + diff --git a/qml/DesktopTheme.qml b/qml/DesktopTheme.qml index 110ed0e..b49e45c 100644 --- a/qml/DesktopTheme.qml +++ b/qml/DesktopTheme.qml @@ -27,4 +27,6 @@ Item { property int fontSizeMedium: 16 property int fontSizeLarge: 25 property int fontSizeExtraLarge: 40 + + property string icon_pause: "qrc://images/icon-m-pause.svg" } diff --git a/qml/TunerScreen.qml b/qml/TunerScreen.qml index 40a23f6..b262429 100644 --- a/qml/TunerScreen.qml +++ b/qml/TunerScreen.qml @@ -40,8 +40,6 @@ Item { property color led_green: "green" property color led_red: "red" - opacity: tuner.running ? 1 : 0.8 - property bool dev_is_ok: Math.abs(tuner.deviation) <= deviation_ok Led { @@ -155,6 +153,7 @@ Item { // frequency and temperament Column { + id: freq_temp x: is_portrait ? theme.paddingLarge : meter.x + meter.width / 6 y: is_portrait ? theme.paddingLarge : meter.y + meter.height - theme.fontSizeSmall * 4 - theme.paddingLarge width: parent.width * 0.4 @@ -163,10 +162,23 @@ Item { Text { text: tuner.la + " hz" font.pixelSize: theme.fontSizeSmall + color: theme.secondaryColor } Text { text: tuner.temperament_list[tuner.temperament_idx] font.pixelSize: theme.fontSizeSmall + color: theme.secondaryColor } } + + // icon for pause status + Image { + visible: !tuner.running + + x: is_portrait ? parent.width - freq_temp.x - width : parent.width - freq_temp.x - width * 2 + y: freq_temp.y + width: theme.iconSizeMedium + height: width + source: theme.icon_pause ? theme.icon_pause : "image://theme/icon-m-pause?" + theme.secondaryColor + } } diff --git a/src/PitchDetection.cpp b/src/PitchDetection.cpp index 5fb8494..8f15bb1 100644 --- a/src/PitchDetection.cpp +++ b/src/PitchDetection.cpp @@ -58,13 +58,19 @@ PitchDetection::PitchDetection() scale = new Scale(); temperaments = new Temperaments(":/data"); + /* + * done by worker before first frame, + * and protected in scale: construct equal if nothing + * on first analyse + */ + /* if (temperaments->SetTemperament(0)) { scale->SetNotesFrequencies(temperaments->NotesFrequencies()); } else { scale->ConstructEqualTemperament(); } - +*/ Reset(); } @@ -214,6 +220,7 @@ void PitchDetection::analyse_file(const char *filename) const int nb_frame = 1024; PitchDetection *pitch = new PitchDetection(); + pitch->SetTemperament(0); int16_t buffer[nb_frame]; PitchResult result; diff --git a/src/TunerWorker.cpp b/src/TunerWorker.cpp index 1257e67..1c69ff9 100644 --- a/src/TunerWorker.cpp +++ b/src/TunerWorker.cpp @@ -57,7 +57,7 @@ TunerWorker::TunerWorker() : running(false), quit(false), la_to_update(0), - temperament_to_update(-1) + temperament_to_update(0) // update the first time in every cases { //qRegisterMetaType("PitchDetection::PitchResult"); } @@ -183,11 +183,15 @@ void TunerWorker::Entry() pa_simple_flush(p_simple, NULL); } - // if srteam was stopped, reset analyse + // if stream was stopped, reset analyse if (new_stream) { pitchDetection->Reset(); + blank_prevent(true); nb_sample_running = 0; new_stream = false; + // send a not-found result on restart + result.found = false; + emit resultUpdated(result); } // get audio data diff --git a/src/scale/Scale.cpp b/src/scale/Scale.cpp index 3e788c3..1d3bbe5 100644 --- a/src/scale/Scale.cpp +++ b/src/scale/Scale.cpp @@ -137,5 +137,5 @@ void Scale::SetLa(double la) { assert(la > 0); actualLa = la; - updateScale(); + if (freq_setted) updateScale(); }