# HG changeset patch # User Chris Cannam # Date 1394019568 0 # Node ID bb391844e2aa9007083f9ff022984ecae1822f66 # Parent 73fafd70996e009c3be955a1719a44804f1eec6b 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) diff -r 73fafd70996e -r bb391844e2aa src/Analyser.cpp --- 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) { diff -r 73fafd70996e -r bb391844e2aa src/Analyser.h --- 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 diff -r 73fafd70996e -r bb391844e2aa src/MainWindow.cpp --- 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(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")); diff -r 73fafd70996e -r bb391844e2aa src/MainWindow.h --- 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