Mercurial > hg > tony
changeset 198:bb391844e2aa
Switching pitch candidate no longer wraps around: you can't go higher than the highest or lower than the lowest (though you can go either "up" or "down" if none of the alternate candidates has been selected yet, regardless of whether the candidates are higher or lower than the actual pitch track)
author | Chris Cannam |
---|---|
date | Wed, 05 Mar 2014 11:39:28 +0000 |
parents | 73fafd70996e |
children | 0ba33d6c0a71 |
files | src/Analyser.cpp src/Analyser.h src/MainWindow.cpp src/MainWindow.h |
diffstat | 4 files changed, 28 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Analyser.cpp Wed Mar 05 11:31:55 2014 +0000 +++ b/src/Analyser.cpp Wed Mar 05 11:39:28 2014 +0000 @@ -372,6 +372,21 @@ emit layersChanged(); } +bool +Analyser::haveHigherPitchCandidate() const +{ + if (m_reAnalysisCandidates.empty()) return false; + return (m_currentCandidate < 0 || + (m_currentCandidate + 1 < (int)m_reAnalysisCandidates.size())); +} + +bool +Analyser::haveLowerPitchCandidate() const +{ + if (m_reAnalysisCandidates.empty()) return false; + return (m_currentCandidate < 0 || m_currentCandidate >= 1); +} + void Analyser::switchPitchCandidate(Selection sel, bool up) {
--- a/src/Analyser.h Wed Mar 05 11:31:55 2014 +0000 +++ b/src/Analyser.h Wed Mar 05 11:39:28 2014 +0000 @@ -124,6 +124,9 @@ */ void showPitchCandidates(bool shown); + bool haveHigherPitchCandidate() const; + bool haveLowerPitchCandidate() const; + /** * If a re-analysis has been activated, switch the selected area * of the main pitch track to a different candidate from the
--- a/src/MainWindow.cpp Wed Mar 05 11:31:55 2014 +0000 +++ b/src/MainWindow.cpp Wed Mar 05 11:39:28 2014 +0000 @@ -553,7 +553,7 @@ action->setStatusTip(tr("Switch to the next higher pitch candidate in the selected region")); m_keyReference->registerShortcut(action); connect(action, SIGNAL(triggered()), this, SLOT(switchPitchUp())); - connect(this, SIGNAL(canChangePitchCandidate(bool)), action, SLOT(setEnabled(bool))); + connect(this, SIGNAL(canChangeToHigherCandidate(bool)), action, SLOT(setEnabled(bool))); menu->addAction(action); m_rightButtonMenu->addAction(action); @@ -562,7 +562,7 @@ action->setStatusTip(tr("Switch to the next lower pitch candidate in the selected region")); m_keyReference->registerShortcut(action); connect(action, SIGNAL(triggered()), this, SLOT(switchPitchDown())); - connect(this, SIGNAL(canChangePitchCandidate(bool)), action, SLOT(setEnabled(bool))); + connect(this, SIGNAL(canChangeToLowerCandidate(bool)), action, SLOT(setEnabled(bool))); menu->addAction(action); m_rightButtonMenu->addAction(action); @@ -1055,6 +1055,10 @@ qobject_cast<TimeValueLayer *>(currentLayer)); bool pitchCandidatesVisible = m_analyser->arePitchCandidatesShown(); + bool haveHigher = + m_analyser->haveHigherPitchCandidate(); + bool haveLower = + m_analyser->haveLowerPitchCandidate(); emit canChangePlaybackSpeed(true); int v = m_playSpeed->value(); @@ -1062,6 +1066,8 @@ emit canSlowDownPlayback(v > m_playSpeed->minimum()); emit canChangePitchCandidate(pitchCandidatesVisible && haveSelection); + emit canChangeToHigherCandidate(pitchCandidatesVisible && haveSelection && haveHigher); + emit canChangeToLowerCandidate(pitchCandidatesVisible && haveSelection && haveLower); if (pitchCandidatesVisible) { m_showCandidatesAction->setText(tr("Hide Pitch Candidates"));
--- a/src/MainWindow.h Wed Mar 05 11:31:55 2014 +0000 +++ b/src/MainWindow.h Wed Mar 05 11:39:28 2014 +0000 @@ -32,6 +32,8 @@ signals: virtual void canChangePitchCandidate(bool); + virtual void canChangeToHigherCandidate(bool); + virtual void canChangeToLowerCandidate(bool); public slots: virtual bool commitData(bool mayAskUser); // on session shutdown