diff --git a/src/library/dlgtrackinfo.cpp b/src/library/dlgtrackinfo.cpp index ec2108dd5c5..1df9aa179e0 100644 --- a/src/library/dlgtrackinfo.cpp +++ b/src/library/dlgtrackinfo.cpp @@ -518,42 +518,42 @@ void DlgTrackInfo::clear() { } void DlgTrackInfo::slotBpmDouble() { - m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::DOUBLE); + m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::BpmScale::Double); // read back the actual value mixxx::Bpm newValue = m_pBeatsClone->getBpm(); spinBpm->setValue(newValue.value()); } void DlgTrackInfo::slotBpmHalve() { - m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::HALVE); + m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::BpmScale::Halve); // read back the actual value const mixxx::Bpm newValue = m_pBeatsClone->getBpm(); spinBpm->setValue(newValue.value()); } void DlgTrackInfo::slotBpmTwoThirds() { - m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::TWOTHIRDS); + m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::BpmScale::TwoThirds); // read back the actual value const mixxx::Bpm newValue = m_pBeatsClone->getBpm(); spinBpm->setValue(newValue.value()); } void DlgTrackInfo::slotBpmThreeFourth() { - m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::THREEFOURTHS); + m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::BpmScale::ThreeFourths); // read back the actual value const mixxx::Bpm newValue = m_pBeatsClone->getBpm(); spinBpm->setValue(newValue.value()); } void DlgTrackInfo::slotBpmFourThirds() { - m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::FOURTHIRDS); + m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::BpmScale::FourThirds); // read back the actual value const mixxx::Bpm newValue = m_pBeatsClone->getBpm(); spinBpm->setValue(newValue.value()); } void DlgTrackInfo::slotBpmThreeHalves() { - m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::THREEHALVES); + m_pBeatsClone = m_pBeatsClone->scale(mixxx::Beats::BpmScale::ThreeHalves); // read back the actual value const mixxx::Bpm newValue = m_pBeatsClone->getBpm(); spinBpm->setValue(newValue.value()); diff --git a/src/test/beatgridtest.cpp b/src/test/beatgridtest.cpp index cf558051627..6cd074eb3b9 100644 --- a/src/test/beatgridtest.cpp +++ b/src/test/beatgridtest.cpp @@ -35,22 +35,22 @@ TEST(BeatGridTest, Scale) { mixxx::audio::kStartFramePos); EXPECT_DOUBLE_EQ(bpm.value(), pGrid->getBpm().value()); - pGrid = pGrid->scale(Beats::DOUBLE); + pGrid = pGrid->scale(Beats::BpmScale::Double); EXPECT_DOUBLE_EQ(2 * bpm.value(), pGrid->getBpm().value()); - pGrid = pGrid->scale(Beats::HALVE); + pGrid = pGrid->scale(Beats::BpmScale::Halve); EXPECT_DOUBLE_EQ(bpm.value(), pGrid->getBpm().value()); - pGrid = pGrid->scale(Beats::TWOTHIRDS); + pGrid = pGrid->scale(Beats::BpmScale::TwoThirds); EXPECT_DOUBLE_EQ(bpm.value() * 2 / 3, pGrid->getBpm().value()); - pGrid = pGrid->scale(Beats::THREEHALVES); + pGrid = pGrid->scale(Beats::BpmScale::ThreeHalves); EXPECT_DOUBLE_EQ(bpm.value(), pGrid->getBpm().value()); - pGrid = pGrid->scale(Beats::THREEFOURTHS); + pGrid = pGrid->scale(Beats::BpmScale::ThreeFourths); EXPECT_DOUBLE_EQ(bpm.value() * 3 / 4, pGrid->getBpm().value()); - pGrid = pGrid->scale(Beats::FOURTHIRDS); + pGrid = pGrid->scale(Beats::BpmScale::FourThirds); EXPECT_DOUBLE_EQ(bpm.value(), pGrid->getBpm().value()); } diff --git a/src/test/beatmaptest.cpp b/src/test/beatmaptest.cpp index a329053d5eb..6cbe84dbb50 100644 --- a/src/test/beatmaptest.cpp +++ b/src/test/beatmaptest.cpp @@ -54,22 +54,22 @@ TEST_F(BeatMapTest, Scale) { auto pMap = BeatMap::makeBeatMap(m_pTrack->getSampleRate(), QString(), beats); EXPECT_DOUBLE_EQ(bpm.value(), pMap->getBpm().value()); - pMap = pMap->scale(Beats::DOUBLE); + pMap = pMap->scale(Beats::BpmScale::Double); EXPECT_DOUBLE_EQ(2 * bpm.value(), pMap->getBpm().value()); - pMap = pMap->scale(Beats::HALVE); + pMap = pMap->scale(Beats::BpmScale::Halve); EXPECT_DOUBLE_EQ(bpm.value(), pMap->getBpm().value()); - pMap = pMap->scale(Beats::TWOTHIRDS); + pMap = pMap->scale(Beats::BpmScale::TwoThirds); EXPECT_DOUBLE_EQ(bpm.value() * 2 / 3, pMap->getBpm().value()); - pMap = pMap->scale(Beats::THREEHALVES); + pMap = pMap->scale(Beats::BpmScale::ThreeHalves); EXPECT_DOUBLE_EQ(bpm.value(), pMap->getBpm().value()); - pMap = pMap->scale(Beats::THREEFOURTHS); + pMap = pMap->scale(Beats::BpmScale::ThreeFourths); EXPECT_DOUBLE_EQ(bpm.value() * 3 / 4, pMap->getBpm().value()); - pMap = pMap->scale(Beats::FOURTHIRDS); + pMap = pMap->scale(Beats::BpmScale::FourThirds); EXPECT_DOUBLE_EQ(bpm.value(), pMap->getBpm().value()); } diff --git a/src/track/beatgrid.cpp b/src/track/beatgrid.cpp index a8822c3de7c..a50f4ea4bb3 100644 --- a/src/track/beatgrid.cpp +++ b/src/track/beatgrid.cpp @@ -315,27 +315,27 @@ BeatsPointer BeatGrid::translate(audio::FrameDiff_t offset) const { return BeatsPointer(new BeatGrid(*this, grid, m_beatLengthFrames)); } -BeatsPointer BeatGrid::scale(enum BPMScale scale) const { +BeatsPointer BeatGrid::scale(BpmScale scale) const { mixxx::track::io::BeatGrid grid = m_grid; auto bpm = mixxx::Bpm(grid.bpm().bpm()); switch (scale) { - case DOUBLE: + case BpmScale::Double: bpm *= 2; break; - case HALVE: + case BpmScale::Halve: bpm *= 1.0 / 2; break; - case TWOTHIRDS: + case BpmScale::TwoThirds: bpm *= 2.0 / 3; break; - case THREEFOURTHS: + case BpmScale::ThreeFourths: bpm *= 3.0 / 4; break; - case FOURTHIRDS: + case BpmScale::FourThirds: bpm *= 4.0 / 3; break; - case THREEHALVES: + case BpmScale::ThreeHalves: bpm *= 3.0 / 2; break; default: diff --git a/src/track/beatgrid.h b/src/track/beatgrid.h index 3a11c707b37..2a7779d34ec 100644 --- a/src/track/beatgrid.h +++ b/src/track/beatgrid.h @@ -66,7 +66,7 @@ class BeatGrid final : public Beats { //////////////////////////////////////////////////////////////////////////// BeatsPointer translate(audio::FrameDiff_t offset) const override; - BeatsPointer scale(enum BPMScale scale) const override; + BeatsPointer scale(BpmScale scale) const override; BeatsPointer setBpm(mixxx::Bpm bpm) override; private: diff --git a/src/track/beatmap.cpp b/src/track/beatmap.cpp index e0c7b8da21b..06e46475051 100644 --- a/src/track/beatmap.cpp +++ b/src/track/beatmap.cpp @@ -588,40 +588,40 @@ BeatsPointer BeatMap::translate(audio::FrameDiff_t offset) const { return BeatsPointer(new BeatMap(*this, beats, m_nominalBpm)); } -BeatsPointer BeatMap::scale(enum BPMScale scale) const { +BeatsPointer BeatMap::scale(BpmScale scale) const { if (!isValid() || m_beats.isEmpty()) { return BeatsPointer(new BeatMap(*this)); } BeatList beats = m_beats; switch (scale) { - case DOUBLE: + case BpmScale::Double: // introduce a new beat into every gap scaleDouble(&beats); break; - case HALVE: + case BpmScale::Halve: // remove every second beat scaleHalve(&beats); break; - case TWOTHIRDS: + case BpmScale::TwoThirds: // introduce a new beat into every gap scaleDouble(&beats); // remove every second and third beat scaleThird(&beats); break; - case THREEFOURTHS: + case BpmScale::ThreeFourths: // introduce two beats into every gap scaleTriple(&beats); // remove every second third and forth beat scaleFourth(&beats); break; - case FOURTHIRDS: + case BpmScale::FourThirds: // introduce three beats into every gap scaleQuadruple(&beats); // remove every second third and forth beat scaleThird(&beats); break; - case THREEHALVES: + case BpmScale::ThreeHalves: // introduce two beats into every gap scaleTriple(&beats); // remove every second beat diff --git a/src/track/beatmap.h b/src/track/beatmap.h index 0603ed9b450..d597efce2ca 100644 --- a/src/track/beatmap.h +++ b/src/track/beatmap.h @@ -70,7 +70,7 @@ class BeatMap final : public Beats { //////////////////////////////////////////////////////////////////////////// BeatsPointer translate(audio::FrameDiff_t offset) const override; - BeatsPointer scale(enum BPMScale scale) const override; + BeatsPointer scale(BpmScale scale) const override; BeatsPointer setBpm(mixxx::Bpm bpm) override; private: diff --git a/src/track/beats.h b/src/track/beats.h index e956da78e71..048d19c2556 100644 --- a/src/track/beats.h +++ b/src/track/beats.h @@ -46,13 +46,13 @@ class Beats { /// Allows us to do ORing typedef int CapabilitiesFlags; - enum BPMScale { - DOUBLE, - HALVE, - TWOTHIRDS, - THREEFOURTHS, - FOURTHIRDS, - THREEHALVES, + enum class BpmScale { + Double, + Halve, + TwoThirds, + ThreeFourths, + FourThirds, + ThreeHalves, }; /// Retrieve the capabilities supported by the beats implementation. @@ -159,7 +159,7 @@ class Beats { /// Scale the position of every beat in the song by `scale`. The `Beats` /// class must have the capability `BEATSCAP_SCALE`. - virtual BeatsPointer scale(enum BPMScale scale) const = 0; + virtual BeatsPointer scale(BpmScale scale) const = 0; /// Adjust the beats so the global average BPM matches `bpm`. The `Beats` /// class must have the capability `BEATSCAP_SET`. diff --git a/src/widget/wtrackmenu.cpp b/src/widget/wtrackmenu.cpp index f0f9c1ff645..9fb3fee4aa0 100644 --- a/src/widget/wtrackmenu.cpp +++ b/src/widget/wtrackmenu.cpp @@ -315,22 +315,22 @@ void WTrackMenu::createActions() { m_pBpmThreeHalvesAction = new QAction(tr("3/2 BPM"), m_pBPMMenu); connect(m_pBpmDoubleAction, &QAction::triggered, this, [this] { - slotScaleBpm(mixxx::Beats::DOUBLE); + slotScaleBpm(mixxx::Beats::BpmScale::Double); }); connect(m_pBpmHalveAction, &QAction::triggered, this, [this] { - slotScaleBpm(mixxx::Beats::HALVE); + slotScaleBpm(mixxx::Beats::BpmScale::Halve); }); connect(m_pBpmTwoThirdsAction, &QAction::triggered, this, [this] { - slotScaleBpm(mixxx::Beats::TWOTHIRDS); + slotScaleBpm(mixxx::Beats::BpmScale::TwoThirds); }); connect(m_pBpmThreeFourthsAction, &QAction::triggered, this, [this] { - slotScaleBpm(mixxx::Beats::THREEFOURTHS); + slotScaleBpm(mixxx::Beats::BpmScale::ThreeFourths); }); connect(m_pBpmFourThirdsAction, &QAction::triggered, this, [this] { - slotScaleBpm(mixxx::Beats::FOURTHIRDS); + slotScaleBpm(mixxx::Beats::BpmScale::FourThirds); }); connect(m_pBpmThreeHalvesAction, &QAction::triggered, this, [this] { - slotScaleBpm(mixxx::Beats::THREEHALVES); + slotScaleBpm(mixxx::Beats::BpmScale::ThreeHalves); }); m_pBpmResetAction = new QAction(tr("Reset BPM"), m_pBPMMenu); @@ -1192,7 +1192,7 @@ namespace { class ScaleBpmTrackPointerOperation : public mixxx::TrackPointerOperation { public: - explicit ScaleBpmTrackPointerOperation(mixxx::Beats::BPMScale bpmScale) + explicit ScaleBpmTrackPointerOperation(mixxx::Beats::BpmScale bpmScale) : m_bpmScale(bpmScale) { } @@ -1209,17 +1209,16 @@ class ScaleBpmTrackPointerOperation : public mixxx::TrackPointerOperation { pTrack->trySetBeats(pBeats->scale(m_bpmScale)); } - const mixxx::Beats::BPMScale m_bpmScale; + const mixxx::Beats::BpmScale m_bpmScale; }; } // anonymous namespace -void WTrackMenu::slotScaleBpm(int scale) { +void WTrackMenu::slotScaleBpm(mixxx::Beats::BpmScale scale) { const auto progressLabelText = tr("Scaling BPM of %n track(s)", "", getTrackCount()); const auto trackOperator = - ScaleBpmTrackPointerOperation( - static_cast(scale)); + ScaleBpmTrackPointerOperation(scale); applyTrackPointerOperation( progressLabelText, &trackOperator); diff --git a/src/widget/wtrackmenu.h b/src/widget/wtrackmenu.h index 71f5c841f0c..ced9c065546 100644 --- a/src/widget/wtrackmenu.h +++ b/src/widget/wtrackmenu.h @@ -9,6 +9,7 @@ #include "library/dao/playlistdao.h" #include "library/trackprocessing.h" #include "preferences/usersettings.h" +#include "track/beats.h" #include "track/trackref.h" #include "util/color/rgbcolor.h" #include "util/parented_ptr.h" @@ -102,7 +103,7 @@ class WTrackMenu : public QMenu { // BPM void slotLockBpm(); void slotUnlockBpm(); - void slotScaleBpm(int); + void slotScaleBpm(mixxx::Beats::BpmScale scale); // Info and metadata void slotShowDlgTagFetcher();