Skip to content

Commit

Permalink
WTrackMenu: Add fixed/variable bpm reanalysis actions
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Sep 29, 2022
1 parent f56a695 commit 6e8196d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,18 @@ void WTrackMenu::createActions() {

m_pReanalyzeAction = new QAction(tr("Reanalyze"), this);
connect(m_pReanalyzeAction, &QAction::triggered, this, &WTrackMenu::slotReanalyze);

m_pReanalyzeConstBpmAction = new QAction(tr("Reanalyze (constant BPM)"), this);
connect(m_pReanalyzeConstBpmAction,
&QAction::triggered,
this,
&WTrackMenu::slotReanalyzeWithFixedTempo);

m_pReanalyzeVarBpmAction = new QAction(tr("Reanalyze (variable BPM)"), this);
connect(m_pReanalyzeVarBpmAction,
&QAction::triggered,
this,
&WTrackMenu::slotReanalyzeWithVariableTempo);
}

// This action is only usable when m_deckGroup is set. That is true only
Expand Down Expand Up @@ -595,6 +607,9 @@ void WTrackMenu::setupActions() {
if (featureIsEnabled(Feature::Analyze)) {
m_pAnalyzeMenu->addAction(m_pAnalyzeAction);
m_pAnalyzeMenu->addAction(m_pReanalyzeAction);
m_pAnalyzeMenu->addSeparator();
m_pAnalyzeMenu->addAction(m_pReanalyzeConstBpmAction);
m_pAnalyzeMenu->addAction(m_pReanalyzeVarBpmAction);
addMenu(m_pAnalyzeMenu);
}

Expand Down Expand Up @@ -1387,6 +1402,20 @@ void WTrackMenu::slotReanalyze() {
addToAnalysis();
}

void WTrackMenu::slotReanalyzeWithFixedTempo() {
clearBeats();
AnalyzerTrack::Options options;
options.useFixedTempo = true;
addToAnalysis(options);
}

void WTrackMenu::slotReanalyzeWithVariableTempo() {
clearBeats();
AnalyzerTrack::Options options;
options.useFixedTempo = false;
addToAnalysis(options);
}

void WTrackMenu::slotLockBpm() {
lockBpm(true);
}
Expand Down
4 changes: 4 additions & 0 deletions src/widget/wtrackmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class WTrackMenu : public QMenu {
// Analysis
void slotAnalyze();
void slotReanalyze();
void slotReanalyzeWithFixedTempo();
void slotReanalyzeWithVariableTempo();

// BPM
void slotLockBpm();
Expand Down Expand Up @@ -288,6 +290,8 @@ class WTrackMenu : public QMenu {
// Analysis actions
QAction* m_pAnalyzeAction{};
QAction* m_pReanalyzeAction{};
QAction* m_pReanalyzeConstBpmAction{};
QAction* m_pReanalyzeVarBpmAction{};

// Clear track metadata actions
QAction* m_pClearBeatsAction{};
Expand Down

0 comments on commit 6e8196d

Please sign in to comment.