diff options
-rw-r--r-- | src/library/dlgtrackinfo.cpp | 18 | ||||
-rw-r--r-- | src/library/dlgtrackinfo.h | 2 | ||||
-rw-r--r-- | src/library/dlgtrackinfo.ui | 34 | ||||
-rw-r--r-- | src/test/beatmaptest.cpp | 6 | ||||
-rw-r--r-- | src/track/beatgrid.cpp | 6 | ||||
-rw-r--r-- | src/track/beatmap.cpp | 14 | ||||
-rw-r--r-- | src/track/beats.h | 2 | ||||
-rw-r--r-- | src/widget/wtracktableview.cpp | 22 | ||||
-rw-r--r-- | src/widget/wtracktableview.h | 2 |
9 files changed, 105 insertions, 1 deletions
diff --git a/src/library/dlgtrackinfo.cpp b/src/library/dlgtrackinfo.cpp index 55912882d2..4eca26de33 100644 --- a/src/library/dlgtrackinfo.cpp +++ b/src/library/dlgtrackinfo.cpp @@ -63,6 +63,10 @@ void DlgTrackInfo::init() { this, SLOT(slotBpmTwoThirds())); connect(bpmThreeFourth, SIGNAL(clicked()), this, SLOT(slotBpmThreeFourth())); + connect(bpmFourThirds, SIGNAL(clicked()), + this, SLOT(slotBpmFourThirds())); + connect(bpmThreeHalves, SIGNAL(clicked()), + this, SLOT(slotBpmThreeHalves())); connect(bpmClear, SIGNAL(clicked()), this, SLOT(slotBpmClear())); @@ -503,6 +507,20 @@ void DlgTrackInfo::slotBpmThreeFourth() { spinBpm->setValue(newValue); } +void DlgTrackInfo::slotBpmFourThirds() { + m_pBeatsClone->scale(Beats::FOURTHIRDS); + // read back the actual value + double newValue = m_pBeatsClone->getBpm(); + spinBpm->setValue(newValue); +} + +void DlgTrackInfo::slotBpmThreeHalves() { + m_pBeatsClone->scale(Beats::THREEHALVES); + // read back the actual value + double newValue = m_pBeatsClone->getBpm(); + spinBpm->setValue(newValue); +} + void DlgTrackInfo::slotBpmClear() { spinBpm->setValue(0); m_pBeatsClone.clear(); diff --git a/src/library/dlgtrackinfo.h b/src/library/dlgtrackinfo.h index 51dd1a851f..92513218c0 100644 --- a/src/library/dlgtrackinfo.h +++ b/src/library/dlgtrackinfo.h @@ -47,6 +47,8 @@ class DlgTrackInfo : public QDialog, public Ui::DlgTrackInfo { void slotBpmHalve(); void slotBpmTwoThirds(); void slotBpmThreeFourth(); + void slotBpmFourThirds(); + void slotBpmThreeHalves(); void slotBpmClear(); void slotBpmConstChanged(int state); void slotBpmTap(double averageLength, int numSamples); diff --git a/src/library/dlgtrackinfo.ui b/src/library/dlgtrackinfo.ui index ddab8a45ae..5c039236fc 100644 --- a/src/library/dlgtrackinfo.ui +++ b/src/library/dlgtrackinfo.ui @@ -794,6 +794,38 @@ </property> </widget> </item> + <item row="3" column="0"> + <widget class="QPushButton" name="bpmThreeHalves"> + <property name="minimumSize"> + <size> + <width>125</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Sets the BPM to 150% of the current value.</string> + </property> + <property name="text"> + <string>3/2 BPM</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QPushButton" name="bpmFourThirds"> + <property name="minimumSize"> + <size> + <width>125</width> + <height>0</height> + </size> + </property> + <property name="toolTip"> + <string>Sets the BPM to 133% of the current value.</string> + </property> + <property name="text"> + <string>4/3 BPM</string> + </property> + </widget> + </item> <item row="1" column="2"> <widget class="QPushButton" name="bpmClear"> <property name="text"> @@ -814,7 +846,7 @@ <property name="maximumSize"> <size> <width>123</width> - <height>91</height> + <height>128</height> </size> </property> <property name="toolTip"> diff --git a/src/test/beatmaptest.cpp b/src/test/beatmaptest.cpp index 42ff7a0c38..44cfa2cebd 100644 --- a/src/test/beatmaptest.cpp +++ b/src/test/beatmaptest.cpp @@ -62,6 +62,12 @@ TEST_F(BeatMapTest, Scale) { pMap->scale(Beats::THREEFOURTHS); EXPECT_DOUBLE_EQ(bpm / 2, pMap->getBpm()); + + pMap->scale(Beats::FOURTHIRDS); + EXPECT_DOUBLE_EQ(bpm * 4 / 3, pMap->getBpm()); + + pMap->scale(Beats::THREEHALVES); + EXPECT_DOUBLE_EQ(bpm * 3 / 2, pMap->getBpm()); } TEST_F(BeatMapTest, TestNthBeat) { diff --git a/src/track/beatgrid.cpp b/src/track/beatgrid.cpp index 27aed7afad..ea6ef9dcfe 100644 --- a/src/track/beatgrid.cpp +++ b/src/track/beatgrid.cpp @@ -358,6 +358,12 @@ void BeatGrid::scale(enum BPMScale scale) { case THREEFOURTHS: bpm *= 3.0 / 4; break; + case FOURTHIRDS: + bpm *= 4.0 / 3; + break; + case THREEHALVES: + bpm *= 3.0 / 2; + break; default: DEBUG_ASSERT(!"scale value invalid"); return; diff --git a/src/track/beatmap.cpp b/src/track/beatmap.cpp index 41efe5dc70..0fb96d79df 100644 --- a/src/track/beatmap.cpp +++ b/src/track/beatmap.cpp @@ -574,6 +574,20 @@ void BeatMap::scale(enum BPMScale scale) { // remove every second third and forth beat scaleFourth(); break; + case FOURTHIRDS: + // introduce two beats into every gap + scaleDouble(); + // and again, to get four beats from one + scaleDouble(); + // remove every second third and forth beat + scaleThird(); + break; + case THREEHALVES: + // introduce two beats into every gap + scaleTriple(); + // remove every second beat + scaleHalve(); + break; default: DEBUG_ASSERT(!"scale value invalid"); return; diff --git a/src/track/beats.h b/src/track/beats.h index db89cf3abf..32d167d235 100644 --- a/src/track/beats.h +++ b/src/track/beats.h @@ -45,6 +45,8 @@ class Beats { HALVE, TWOTHIRDS, THREEFOURTHS, + FOURTHIRDS, + THREEHALVES, }; virtual Beats::CapabilitiesFlags getCapabilities() const = 0; diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index a5e753e3e8..8f74136f77 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -132,6 +132,8 @@ WTrackTableView::~WTrackTableView() { delete m_pBpmHalveAction; delete m_pBpmTwoThirdsAction; delete m_pBpmThreeFourthsAction; + delete m_pBpmFourThirdsAction; + delete m_pBpmThreeHalvesAction; delete m_pBPMMenu; delete m_pReplayGainResetAction; delete m_pPurgeAct; @@ -419,11 +421,15 @@ void WTrackTableView::createActions() { m_pBpmHalveAction = new QAction(tr("Halve BPM"), this); m_pBpmTwoThirdsAction = new QAction(tr("2/3 BPM"), this); m_pBpmThreeFourthsAction = new QAction(tr("3/4 BPM"), this); + m_pBpmFourThirdsAction = new QAction(tr("4/3 BPM"), this); + m_pBpmThreeHalvesAction = new QAction(tr("3/2 BPM"), this); m_BpmMapper.setMapping(m_pBpmDoubleAction, Beats::DOUBLE); m_BpmMapper.setMapping(m_pBpmHalveAction, Beats::HALVE); m_BpmMapper.setMapping(m_pBpmTwoThirdsAction, Beats::TWOTHIRDS); m_BpmMapper.setMapping(m_pBpmThreeFourthsAction, Beats::THREEFOURTHS); + m_BpmMapper.setMapping(m_pBpmFourThirdsAction, Beats::FOURTHIRDS); + m_BpmMapper.setMapping(m_pBpmThreeHalvesAction, Beats::THREEHALVES); connect(m_pBpmDoubleAction, SIGNAL(triggered()), &m_BpmMapper, SLOT(map())); @@ -433,6 +439,10 @@ void WTrackTableView::createActions() { &m_BpmMapper, SLOT(map())); connect(m_pBpmThreeFourthsAction, SIGNAL(triggered()), &m_BpmMapper, SLOT(map())); + connect(m_pBpmFourThirdsAction, SIGNAL(triggered()), + &m_BpmMapper, SLOT(map())); + connect(m_pBpmThreeHalvesAction, SIGNAL(triggered()), + &m_BpmMapper, SLOT(map())); m_pClearBeatsAction = new QAction(tr("Clear BPM and Beatgrid"), this); connect(m_pClearBeatsAction, SIGNAL(triggered()), @@ -837,6 +847,8 @@ void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) { m_pBPMMenu->addAction(m_pBpmHalveAction); m_pBPMMenu->addAction(m_pBpmTwoThirdsAction); m_pBPMMenu->addAction(m_pBpmThreeFourthsAction); + m_pBPMMenu->addAction(m_pBpmFourThirdsAction); + m_pBPMMenu->addAction(m_pBpmThreeHalvesAction); m_pBPMMenu->addSeparator(); m_pBPMMenu->addAction(m_pBpmLockAction); m_pBPMMenu->addAction(m_pBpmUnlockAction); @@ -854,6 +866,8 @@ void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) { m_pBpmHalveAction->setEnabled(false); m_pBpmTwoThirdsAction->setEnabled(false); m_pBpmThreeFourthsAction->setEnabled(false); + m_pBpmFourThirdsAction->setEnabled(false); + m_pBpmThreeHalvesAction->setEnabled(false); } else { //BPM is not locked m_pBpmUnlockAction->setEnabled(false); m_pBpmLockAction->setEnabled(true); @@ -861,6 +875,8 @@ void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) { m_pBpmHalveAction->setEnabled(true); m_pBpmTwoThirdsAction->setEnabled(true); m_pBpmThreeFourthsAction->setEnabled(true); + m_pBpmFourThirdsAction->setEnabled(true); + m_pBpmThreeHalvesAction->setEnabled(true); } } else { bool anyLocked = false; //true if any of the selected items are locked @@ -878,12 +894,18 @@ void WTrackTableView::contextMenuEvent(QContextMenuEvent* event) { m_pBpmDoubleAction->setEnabled(false); m_pBpmHalveAction->setEnabled(false); m_pBpmTwoThirdsAction->setEnabled(false); + m_pBpmThreeFourthsAction->setEnabled(false); + m_pBpmFourThirdsAction->setEnabled(false); + m_pBpmThreeHalvesAction->setEnabled(false); } else { m_pBpmLockAction->setEnabled(true); m_pBpmUnlockAction->setEnabled(false); m_pBpmDoubleAction->setEnabled(true); m_pBpmHalveAction->setEnabled(true); m_pBpmTwoThirdsAction->setEnabled(true); + m_pBpmThreeFourthsAction->setEnabled(true); + m_pBpmFourThirdsAction->setEnabled(true); + m_pBpmThreeHalvesAction->setEnabled(true); } } } diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 5836006ef8..6e1172960a 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -151,6 +151,8 @@ class WTrackTableView : public WLibraryTableView { QAction *m_pBpmHalveAction; QAction *m_pBpmTwoThirdsAction; QAction *m_pBpmThreeFourthsAction; + QAction *m_pBpmFourThirdsAction; + QAction *m_pBpmThreeHalvesAction; // Clear track beats QAction* m_pClearBeatsAction; |