summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-03-02 10:22:57 +0100
committerJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-03-02 10:22:57 +0100
commitfa6dba8f86420a6eb9979b51f8c10629b4b72466 (patch)
tree0bec26b36e5f9624f4c4dee5b6e5b1ad165261b1 /src
parent8d3672390c77b1199171517422149f623ab00d6a (diff)
parent18a134faba514f60a273a9b0aa2f3c9a6a09f214 (diff)
Merge branch 'master' of github.com:mixxxdj/mixxx into hotcue-rgb-colors
Diffstat (limited to 'src')
-rw-r--r--src/analyzer/analyzersilence.cpp18
-rw-r--r--src/engine/controls/cuecontrol.cpp42
-rw-r--r--src/engine/controls/vinylcontrolcontrol.cpp2
-rw-r--r--src/library/autodj/autodjprocessor.cpp4
-rw-r--r--src/library/dao/cuedao.cpp2
-rw-r--r--src/library/rekordbox/rekordboxfeature.cpp6
-rw-r--r--src/mixer/basetrackplayer.cpp6
-rw-r--r--src/test/analyzersilence_test.cpp20
-rw-r--r--src/test/cuecontrol_test.cpp42
-rw-r--r--src/track/cue.cpp43
-rw-r--r--src/track/cue.h29
-rw-r--r--src/track/cueinfo.cpp86
-rw-r--r--src/track/cueinfo.h61
-rw-r--r--src/track/track.cpp43
-rw-r--r--src/track/track.h5
-rw-r--r--src/widget/woverview.cpp2
-rw-r--r--src/widget/wtracktableview.cpp10
17 files changed, 307 insertions, 114 deletions
diff --git a/src/analyzer/analyzersilence.cpp b/src/analyzer/analyzersilence.cpp
index bde8445bef..556f2be6ba 100644
--- a/src/analyzer/analyzersilence.cpp
+++ b/src/analyzer/analyzersilence.cpp
@@ -10,9 +10,9 @@ constexpr float kSilenceThreshold = 0.001;
//constexpr float kSilenceThreshold = db2ratio(-60.0f);
bool shouldAnalyze(TrackPointer pTrack) {
- CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro);
- CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro);
- CuePointer pAudibleSound = pTrack->findCueByType(Cue::Type::AudibleSound);
+ CuePointer pIntroCue = pTrack->findCueByType(mixxx::CueType::Intro);
+ CuePointer pOutroCue = pTrack->findCueByType(mixxx::CueType::Outro);
+ CuePointer pAudibleSound = pTrack->findCueByType(mixxx::CueType::AudibleSound);
if (!pIntroCue || !pOutroCue || !pAudibleSound || pAudibleSound->getLength() <= 0) {
return true;
@@ -92,10 +92,10 @@ void AnalyzerSilence::storeResults(TrackPointer pTrack) {
double firstSound = mixxx::kAnalysisChannels * m_iSignalStart;
double lastSound = mixxx::kAnalysisChannels * m_iSignalEnd;
- CuePointer pAudibleSound = pTrack->findCueByType(Cue::Type::AudibleSound);
+ CuePointer pAudibleSound = pTrack->findCueByType(mixxx::CueType::AudibleSound);
if (pAudibleSound == nullptr) {
pAudibleSound = pTrack->createAndAddCue();
- pAudibleSound->setType(Cue::Type::AudibleSound);
+ pAudibleSound->setType(mixxx::CueType::AudibleSound);
}
// The user has no way to directly edit the AudibleSound cue. If the user
// has deleted the Intro or Outro Cue, this analysis will be rerun when
@@ -106,7 +106,7 @@ void AnalyzerSilence::storeResults(TrackPointer pTrack) {
pAudibleSound->setStartPosition(firstSound);
pAudibleSound->setEndPosition(lastSound);
- CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pIntroCue = pTrack->findCueByType(mixxx::CueType::Intro);
double mainCue = pTrack->getCuePoint().getPosition();
double introStart = firstSound;
@@ -126,15 +126,15 @@ void AnalyzerSilence::storeResults(TrackPointer pTrack) {
if (pIntroCue == nullptr) {
pIntroCue = pTrack->createAndAddCue();
- pIntroCue->setType(Cue::Type::Intro);
+ pIntroCue->setType(mixxx::CueType::Intro);
pIntroCue->setStartPosition(introStart);
pIntroCue->setEndPosition(Cue::kNoPosition);
}
- CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pOutroCue = pTrack->findCueByType(mixxx::CueType::Outro);
if (pOutroCue == nullptr) {
pOutroCue = pTrack->createAndAddCue();
- pOutroCue->setType(Cue::Type::Outro);
+ pOutroCue->setType(mixxx::CueType::Outro);
pOutroCue->setStartPosition(Cue::kNoPosition);
pOutroCue->setEndPosition(lastSound);
}
diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp
index 103092d011..09070e4072 100644
--- a/src/engine/controls/cuecontrol.cpp
+++ b/src/engine/controls/cuecontrol.cpp
@@ -376,7 +376,7 @@ void CueControl::trackLoaded(TrackPointer pNewTrack) {
CuePointer pMainCue;
for (const CuePointer& pCue : m_pLoadedTrack->getCuePoints()) {
- if (pCue->getType() == Cue::Type::MainCue) {
+ if (pCue->getType() == mixxx::CueType::MainCue) {
DEBUG_ASSERT(!pMainCue);
pMainCue = pCue;
}
@@ -389,7 +389,7 @@ void CueControl::trackLoaded(TrackPointer pNewTrack) {
// Because of legacy, we store the (load) cue point twice and need to
// sync both values.
- // The Cue::Type::MainCue from getCuePoints() has the priority
+ // The mixxx::CueType::MainCue from getCuePoints() has the priority
CuePosition mainCuePoint;
if (pMainCue) {
mainCuePoint.setPosition(pMainCue->getPosition());
@@ -403,7 +403,7 @@ void CueControl::trackLoaded(TrackPointer pNewTrack) {
CuePointer pCue(pNewTrack->createAndAddCue());
pCue->setStartPosition(mainCuePoint.getPosition());
pCue->setHotCue(Cue::kNoHotCue);
- pCue->setType(Cue::Type::MainCue);
+ pCue->setType(mixxx::CueType::MainCue);
}
m_pCuePoint->set(mainCuePoint.getPosition());
@@ -413,7 +413,7 @@ void CueControl::trackLoaded(TrackPointer pNewTrack) {
// Seek track according to SeekOnLoadMode.
SeekOnLoadMode seekOnLoadMode = getSeekOnLoadPreference();
- CuePointer pAudibleSound = pNewTrack->findCueByType(Cue::Type::AudibleSound);
+ CuePointer pAudibleSound = pNewTrack->findCueByType(mixxx::CueType::AudibleSound);
double firstSound = Cue::kNoPosition;
if (pAudibleSound) {
firstSound = pAudibleSound->getPosition();
@@ -470,16 +470,16 @@ void CueControl::loadCuesFromTrack() {
return;
for (const CuePointer& pCue: m_pLoadedTrack->getCuePoints()) {
- if (pCue->getType() == Cue::Type::MainCue) {
+ if (pCue->getType() == mixxx::CueType::MainCue) {
DEBUG_ASSERT(!pLoadCue); // There should be only one MainCue cue
pLoadCue = pCue;
- } else if (pCue->getType() == Cue::Type::Intro) {
+ } else if (pCue->getType() == mixxx::CueType::Intro) {
DEBUG_ASSERT(!pIntroCue); // There should be only one Intro cue
pIntroCue = pCue;
- } else if (pCue->getType() == Cue::Type::Outro) {
+ } else if (pCue->getType() == mixxx::CueType::Outro) {
DEBUG_ASSERT(!pOutroCue); // There should be only one Outro cue
pOutroCue = pCue;
- } else if (pCue->getType() == Cue::Type::HotCue && pCue->getHotCue() != Cue::kNoHotCue) {
+ } else if (pCue->getType() == mixxx::CueType::HotCue && pCue->getHotCue() != Cue::kNoHotCue) {
int hotcue = pCue->getHotCue();
HotcueControl* pControl = m_hotcueControls.value(hotcue, NULL);
@@ -616,7 +616,7 @@ void CueControl::hotcueSet(HotcueControl* pControl, double v) {
pCue->setStartPosition(cuePosition);
pCue->setHotCue(hotcue);
pCue->setLabel("");
- pCue->setType(Cue::Type::HotCue);
+ pCue->setType(mixxx::CueType::HotCue);
auto hotcueColorPalette = m_colorPaletteSettings.getHotcueColorPalette();
ConfigKey autoHotcueColorsKey("[Controls]", "auto_hotcue_colors");
@@ -1186,10 +1186,10 @@ void CueControl::introStartSet(double v) {
lock.unlock();
if (pLoadedTrack) {
- CuePointer pCue = pLoadedTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pCue = pLoadedTrack->findCueByType(mixxx::CueType::Intro);
if (!pCue) {
pCue = pLoadedTrack->createAndAddCue();
- pCue->setType(Cue::Type::Intro);
+ pCue->setType(mixxx::CueType::Intro);
}
pCue->setStartPosition(position);
pCue->setEndPosition(introEnd);
@@ -1207,7 +1207,7 @@ void CueControl::introStartClear(double v) {
lock.unlock();
if (pLoadedTrack) {
- CuePointer pCue = pLoadedTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pCue = pLoadedTrack->findCueByType(mixxx::CueType::Intro);
if (introEnd != Cue::kNoPosition) {
pCue->setStartPosition(Cue::kNoPosition);
pCue->setEndPosition(introEnd);
@@ -1262,10 +1262,10 @@ void CueControl::introEndSet(double v) {
lock.unlock();
if (pLoadedTrack) {
- CuePointer pCue = pLoadedTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pCue = pLoadedTrack->findCueByType(mixxx::CueType::Intro);
if (!pCue) {
pCue = pLoadedTrack->createAndAddCue();
- pCue->setType(Cue::Type::Intro);
+ pCue->setType(mixxx::CueType::Intro);
}
pCue->setStartPosition(introStart);
pCue->setEndPosition(position);
@@ -1283,7 +1283,7 @@ void CueControl::introEndClear(double v) {
lock.unlock();
if (pLoadedTrack) {
- CuePointer pCue = pLoadedTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pCue = pLoadedTrack->findCueByType(mixxx::CueType::Intro);
if (introStart != Cue::kNoPosition) {
pCue->setStartPosition(introStart);
pCue->setEndPosition(Cue::kNoPosition);
@@ -1338,10 +1338,10 @@ void CueControl::outroStartSet(double v) {
lock.unlock();
if (pLoadedTrack) {
- CuePointer pCue = pLoadedTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pCue = pLoadedTrack->findCueByType(mixxx::CueType::Outro);
if (!pCue) {
pCue = pLoadedTrack->createAndAddCue();
- pCue->setType(Cue::Type::Outro);
+ pCue->setType(mixxx::CueType::Outro);
}
pCue->setStartPosition(position);
pCue->setEndPosition(outroEnd);
@@ -1359,7 +1359,7 @@ void CueControl::outroStartClear(double v) {
lock.unlock();
if (pLoadedTrack) {
- CuePointer pCue = pLoadedTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pCue = pLoadedTrack->findCueByType(mixxx::CueType::Outro);
if (outroEnd != Cue::kNoPosition) {
pCue->setStartPosition(Cue::kNoPosition);
pCue->setEndPosition(outroEnd);
@@ -1414,10 +1414,10 @@ void CueControl::outroEndSet(double v) {
lock.unlock();
if (pLoadedTrack) {
- CuePointer pCue = pLoadedTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pCue = pLoadedTrack->findCueByType(mixxx::CueType::Outro);
if (!pCue) {
pCue = pLoadedTrack->createAndAddCue();
- pCue->setType(Cue::Type::Outro);
+ pCue->setType(mixxx::CueType::Outro);
}
pCue->setStartPosition(outroStart);
pCue->setEndPosition(position);
@@ -1435,7 +1435,7 @@ void CueControl::outroEndClear(double v) {
lock.unlock();
if (pLoadedTrack) {
- CuePointer pCue = pLoadedTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pCue = pLoadedTrack->findCueByType(mixxx::CueType::Outro);
if (outroStart != Cue::kNoPosition) {
pCue->setStartPosition(outroStart);
pCue->setEndPosition(Cue::kNoPosition);
diff --git a/src/engine/controls/vinylcontrolcontrol.cpp b/src/engine/controls/vinylcontrolcontrol.cpp
index fbd3d12945..bece0ae145 100644
--- a/src/engine/controls/vinylcontrolcontrol.cpp
+++ b/src/engine/controls/vinylcontrolcontrol.cpp
@@ -123,7 +123,7 @@ void VinylControlControl::slotControlVinylSeek(double fractionalPos) {
QListIterator<CuePointer> it(cuePoints);
while (it.hasNext()) {
CuePointer pCue(it.next());
- if (pCue->getType() != Cue::Type::HotCue || pCue->getHotCue() == -1) {
+ if (pCue->getType() != mixxx::CueType::HotCue || pCue->getHotCue() == -1) {
continue;
}
diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp
index 8151c02a83..13ba0bef5c 100644
--- a/src/library/autodj/autodjprocessor.cpp
+++ b/src/library/autodj/autodjprocessor.cpp
@@ -1068,7 +1068,7 @@ double AutoDJProcessor::getFirstSoundSecond(DeckAttributes* pDeck) {
return 0.0;
}
- CuePointer pFromTrackAudibleSound = pTrack->findCueByType(Cue::Type::AudibleSound);
+ CuePointer pFromTrackAudibleSound = pTrack->findCueByType(mixxx::CueType::AudibleSound);
if (pFromTrackAudibleSound) {
double firstSound = pFromTrackAudibleSound->getPosition();
if (firstSound > 0.0) {
@@ -1084,7 +1084,7 @@ double AutoDJProcessor::getLastSoundSecond(DeckAttributes* pDeck) {
return 0.0;
}
- CuePointer pFromTrackAudibleSound = pTrack->findCueByType(Cue::Type::AudibleSound);
+ CuePointer pFromTrackAudibleSound = pTrack->findCueByType(mixxx::CueType::AudibleSound);
if (pFromTrackAudibleSound && pFromTrackAudibleSound->getLength() > 0) {
double lastSound = pFromTrackAudibleSound->getEndPosition();
if (lastSound > 0) {
diff --git a/src/library/dao/cuedao.cpp b/src/library/dao/cuedao.cpp
index 3111a88bb2..4a746d75c8 100644
--- a/src/library/dao/cuedao.cpp
+++ b/src/library/dao/cuedao.cpp
@@ -59,7 +59,7 @@ CuePointer CueDAO::cueFromRow(const QSqlQuery& query) const {
}
CuePointer pCue(new Cue(id,
trackId,
- (Cue::Type)type,
+ static_cast<mixxx::CueType>(type),
position,
length,
hotcue,
diff --git a/src/library/rekordbox/rekordboxfeature.cpp b/src/library/rekordbox/rekordboxfeature.cpp
index 872d8ae937..d107bfee48 100644
--- a/src/library/rekordbox/rekordboxfeature.cpp
+++ b/src/library/rekordbox/rekordboxfeature.cpp
@@ -672,7 +672,7 @@ void setHotCue(TrackPointer track, double position, int id, QString label, int /
pCue = CuePointer(track->createAndAddCue());
}
- pCue->setType(Cue::Type::HotCue);
+ pCue->setType(mixxx::CueType::HotCue);
pCue->setStartPosition(position);
pCue->setHotCue(id);
@@ -867,7 +867,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i
if (cueLoadPosition < kLongestPosition) {
track->setCuePoint(CuePosition(cueLoadPosition));
- CuePointer pLoadCue = track->findCueByType(Cue::Type::MainCue);
+ CuePointer pLoadCue = track->findCueByType(mixxx::CueType::MainCue);
if (!cueLoadComment.isNull()) {
pLoadCue->setLabel(cueLoadComment);
}
@@ -876,7 +876,7 @@ void readAnalyze(TrackPointer track, double sampleRate, int timingOffset, bool i
CuePointer pCue(track->createAndAddCue());
pCue->setStartPosition(cueLoopStartPosition);
pCue->setEndPosition(cueLoopEndPosition);
- pCue->setType(Cue::Type::Loop);
+ pCue->setType(mixxx::CueType::Loop);
}
}
diff --git a/src/mixer/basetrackplayer.cpp b/src/mixer/basetrackplayer.cpp
index e18a0355af..74ccc9a7c6 100644
--- a/src/mixer/basetrackplayer.cpp
+++ b/src/mixer/basetrackplayer.cpp
@@ -179,7 +179,7 @@ void BaseTrackPlayerImpl::loadTrack(TrackPointer pTrack) {
QListIterator<CuePointer> it(trackCues);
while (it.hasNext()) {
CuePointer pCue(it.next());
- if (pCue->getType() == Cue::Type::Loop) {
+ if (pCue->getType() == mixxx::CueType::Loop) {
double loopStart = pCue->getPosition();
double loopEnd = loopStart + pCue->getLength();
if (loopStart != kNoTrigger && loopEnd != kNoTrigger && loopStart <= loopEnd) {
@@ -218,13 +218,13 @@ TrackPointer BaseTrackPlayerImpl::unloadTrack() {
QListIterator<CuePointer> it(cuePoints);
while (it.hasNext()) {
CuePointer pCue(it.next());
- if (pCue->getType() == Cue::Type::Loop) {
+ if (pCue->getType() == mixxx::CueType::Loop) {
pLoopCue = pCue;
}
}
if (!pLoopCue) {
pLoopCue = m_pLoadedTrack->createAndAddCue();
- pLoopCue->setType(Cue::Type::Loop);
+ pLoopCue->setType(mixxx::CueType::Loop);
}
pLoopCue->setStartPosition(loopStart);
pLoopCue->setEndPosition(loopEnd);
diff --git a/src/test/analyzersilence_test.cpp b/src/test/analyzersilence_test.cpp
index 3f4c117d8f..26224002ff 100644
--- a/src/test/analyzersilence_test.cpp
+++ b/src/test/analyzersilence_test.cpp
@@ -54,11 +54,11 @@ TEST_F(AnalyzerSilenceTest, SilenceTrack) {
CuePosition cue = pTrack->getCuePoint();
EXPECT_DOUBLE_EQ(0.0, cue.getPosition());
- CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pIntroCue = pTrack->findCueByType(mixxx::CueType::Intro);
EXPECT_DOUBLE_EQ(0.0, pIntroCue->getPosition());
EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength());
- CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pOutroCue = pTrack->findCueByType(mixxx::CueType::Outro);
EXPECT_DOUBLE_EQ(Cue::kNoPosition, pOutroCue->getPosition());
EXPECT_DOUBLE_EQ(nTrackSampleDataLength, pOutroCue->getLength());
}
@@ -75,11 +75,11 @@ TEST_F(AnalyzerSilenceTest, EndToEndToneTrack) {
CuePosition cue = pTrack->getCuePoint();
EXPECT_DOUBLE_EQ(0.0, cue.getPosition());
- CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pIntroCue = pTrack->findCueByType(mixxx::CueType::Intro);
EXPECT_DOUBLE_EQ(0.0, pIntroCue->getPosition());
EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength());
- CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pOutroCue = pTrack->findCueByType(mixxx::CueType::Outro);
EXPECT_DOUBLE_EQ(Cue::kNoPosition, pOutroCue->getPosition());
EXPECT_DOUBLE_EQ(nTrackSampleDataLength, pOutroCue->getLength());
}
@@ -106,11 +106,11 @@ TEST_F(AnalyzerSilenceTest, ToneTrackWithSilence) {
CuePosition cue = pTrack->getCuePoint();
EXPECT_DOUBLE_EQ(nTrackSampleDataLength / 4, cue.getPosition());
- CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pIntroCue = pTrack->findCueByType(mixxx::CueType::Intro);
EXPECT_DOUBLE_EQ(nTrackSampleDataLength / 4, pIntroCue->getPosition());
EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength());
- CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pOutroCue = pTrack->findCueByType(mixxx::CueType::Outro);
EXPECT_DOUBLE_EQ(Cue::kNoPosition, pOutroCue->getPosition());
EXPECT_DOUBLE_EQ(3 * nTrackSampleDataLength / 4, pOutroCue->getLength());
}
@@ -149,11 +149,11 @@ TEST_F(AnalyzerSilenceTest, ToneTrackWithSilenceInTheMiddle) {
CuePosition cue = pTrack->getCuePoint();
EXPECT_DOUBLE_EQ(oneFifthOfTrackLength, cue.getPosition());
- CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pIntroCue = pTrack->findCueByType(mixxx::CueType::Intro);
EXPECT_DOUBLE_EQ(oneFifthOfTrackLength, pIntroCue->getPosition());
EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength());
- CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pOutroCue = pTrack->findCueByType(mixxx::CueType::Outro);
EXPECT_DOUBLE_EQ(Cue::kNoPosition, pOutroCue->getPosition());
EXPECT_DOUBLE_EQ(4 * oneFifthOfTrackLength, pOutroCue->getLength());
}
@@ -167,12 +167,12 @@ TEST_F(AnalyzerSilenceTest, RespectUserEdits) {
pTrack->setCuePoint(CuePosition(kManualCuePosition));
CuePointer pIntroCue = pTrack->createAndAddCue();
- pIntroCue->setType(Cue::Type::Intro);
+ pIntroCue->setType(mixxx::CueType::Intro);
pIntroCue->setStartPosition(kManualIntroPosition);
pIntroCue->setEndPosition(Cue::kNoPosition);
CuePointer pOutroCue = pTrack->createAndAddCue();
- pOutroCue->setType(Cue::Type::Outro);
+ pOutroCue->setType(mixxx::CueType::Outro);
pOutroCue->setStartPosition(Cue::kNoPosition);
pOutroCue->setEndPosition(kManualOutroPosition);
diff --git a/src/test/cuecontrol_test.cpp b/src/test/cuecontrol_test.cpp
index aa39c655b4..de18a0eb64 100644
--- a/src/test/cuecontrol_test.cpp
+++ b/src/test/cuecontrol_test.cpp
@@ -77,11 +77,11 @@ TEST_F(CueControlTest, LoadUnloadTrack) {
TrackPointer pTrack = createTestTrack();
pTrack->setCuePoint(CuePosition(100.0));
auto pIntro = pTrack->createAndAddCue();
- pIntro->setType(Cue::Type::Intro);
+ pIntro->setType(mixxx::CueType::Intro);
pIntro->setStartPosition(150.0);
pIntro->setEndPosition(200.0);
auto pOutro = pTrack->createAndAddCue();
- pOutro->setType(Cue::Type::Outro);
+ pOutro->setType(mixxx::CueType::Outro);
pOutro->setStartPosition(250.0);
pOutro->setEndPosition(300.0);
@@ -114,11 +114,11 @@ TEST_F(CueControlTest, LoadTrackWithDetectedCues) {
TrackPointer pTrack = createTestTrack();
pTrack->setCuePoint(CuePosition(100.0));
auto pIntro = pTrack->createAndAddCue();
- pIntro->setType(Cue::Type::Intro);
+ pIntro->setType(mixxx::CueType::Intro);
pIntro->setStartPosition(100.0);
pIntro->setEndPosition(Cue::kNoPosition);
auto pOutro = pTrack->createAndAddCue();
- pOutro->setType(Cue::Type::Outro);
+ pOutro->setType(mixxx::CueType::Outro);
pOutro->setStartPosition(Cue::kNoPosition);
pOutro->setEndPosition(200.0);
@@ -138,11 +138,11 @@ TEST_F(CueControlTest, LoadTrackWithDetectedCues) {
TEST_F(CueControlTest, LoadTrackWithIntroEndAndOutroStart) {
TrackPointer pTrack = createTestTrack();
auto pIntro = pTrack->createAndAddCue();
- pIntro->setType(Cue::Type::Intro);
+ pIntro->setType(mixxx::CueType::Intro);
pIntro->setStartPosition(Cue::kNoPosition);
pIntro->setEndPosition(150.0);
auto pOutro = pTrack->createAndAddCue();
- pOutro->setType(Cue::Type::Outro);
+ pOutro->setType(mixxx::CueType::Outro);
pOutro->setStartPosition(250.0);
pOutro->setEndPosition(Cue::kNoPosition);
@@ -174,12 +174,12 @@ TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeEnabled) {
pTrack->setCuePoint(CuePosition(1.9 * beatLength));
auto pIntro = pTrack->createAndAddCue();
- pIntro->setType(Cue::Type::Intro);
+ pIntro->setType(mixxx::CueType::Intro);
pIntro->setStartPosition(2.1 * beatLength);
pIntro->setEndPosition(3.7 * beatLength);
auto pOutro = pTrack->createAndAddCue();
- pOutro->setType(Cue::Type::Outro);
+ pOutro->setType(mixxx::CueType::Outro);
pOutro->setStartPosition(11.1 * beatLength);
pOutro->setEndPosition(15.5 * beatLength);
@@ -202,12 +202,12 @@ TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeEnabledNoBeats) {
pTrack->setCuePoint(CuePosition(100.0));
auto pIntro = pTrack->createAndAddCue();
- pIntro->setType(Cue::Type::Intro);
+ pIntro->setType(mixxx::CueType::Intro);
pIntro->setStartPosition(250.0);
pIntro->setEndPosition(400.0);
auto pOutro = pTrack->createAndAddCue();
- pOutro->setType(Cue::Type::Outro);
+ pOutro->setType(mixxx::CueType::Outro);
pOutro->setStartPosition(550.0);
pOutro->setEndPosition(800.0);
@@ -230,12 +230,12 @@ TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeDisabled) {
pTrack->setCuePoint(CuePosition(240.0));
auto pIntro = pTrack->createAndAddCue();
- pIntro->setType(Cue::Type::Intro);
+ pIntro->setType(mixxx::CueType::Intro);
pIntro->setStartPosition(210.0);
pIntro->setEndPosition(330.0);
auto pOutro = pTrack->createAndAddCue();
- pOutro->setType(Cue::Type::Outro);
+ pOutro->setType(mixxx::CueType::Outro);
pOutro->setStartPosition(770.0);
pOutro->setEndPosition(990.0);
@@ -252,7 +252,7 @@ TEST_F(CueControlTest, SeekOnLoadDefault) {
// Default is to load at the intro start
TrackPointer pTrack = createTestTrack();
auto pIntro = pTrack->createAndAddCue();
- pIntro->setType(Cue::Type::Intro);
+ pIntro->setType(mixxx::CueType::Intro);
pIntro->setStartPosition(250.0);
pIntro->setEndPosition(400.0);
@@ -312,7 +312,7 @@ TEST_F(CueControlTest, IntroCue_SetStartEnd_ClearStartEnd) {
EXPECT_DOUBLE_EQ(Cue::kNoPosition, m_pIntroEndPosition->get());
EXPECT_FALSE(m_pIntroEndEnabled->toBool());
- CuePointer pCue = pTrack->findCueByType(Cue::Type::Intro);
+ CuePointer pCue = pTrack->findCueByType(mixxx::CueType::Intro);
EXPECT_NE(nullptr, pCue);
if (pCue != nullptr) {
EXPECT_DOUBLE_EQ(100.0, pCue->getPosition());
@@ -328,7 +328,7 @@ TEST_F(CueControlTest, IntroCue_SetStartEnd_ClearStartEnd) {
EXPECT_DOUBLE_EQ(500.0, m_pIntroEndPosition->get());
EXPECT_TRUE(m_pIntroEndEnabled->toBool());
- pCue = pTrack->findCueByType(Cue::Type::Intro);
+ pCue = pTrack->findCueByType(mixxx::CueType::Intro);
EXPECT_NE(nullptr, pCue);
if (pCue != nullptr) {
EXPECT_DOUBLE_EQ(100.0, pCue->getPosition());
@@ -343,7 +343,7 @@ TEST_F(CueControlTest, IntroCue_SetStartEnd_ClearStartEnd) {
EXPECT_DOUBLE_EQ(500.0, m_pIntroEndPosition->get());
EXPECT_TRUE(m_pIntroEndEnabled->toBool());
- pCue = pTrack->findCueByType(Cue::Type::Intro);
+ pCue = pTrack->findCueByType(mixxx::CueType::Intro);
EXPECT_NE(nullptr, pCue);
if (pCue != nullptr) {
EXPECT_DOUBLE_EQ(Cue::kNoPosition, pCue->getPosition());
@@ -358,7 +358,7 @@ TEST_F(CueControlTest, IntroCue_SetStartEnd_ClearStartEnd) {
EXPECT_DOUBLE_EQ(Cue::kNoPosition, m_pIntroEndPosition->get());
EXPECT_FALSE(m_pIntroEndEnabled->toBool());
- EXPECT_EQ(nullptr, pTrack->findCueByType(Cue::Type::Intro));
+ EXPECT_EQ(nullptr, pTrack->findCueByType(mixxx::CueType::Intro));
}
TEST_F(CueControlTest, OutroCue_SetStartEnd_ClearStartEnd) {
@@ -373,7 +373,7 @@ TEST_F(CueControlTest, OutroCue_SetStartEnd_ClearStartEnd) {
EXPECT_DOUBLE_EQ(Cue::kNoPosition, m_pOutroEndPosition->get());
EXPECT_FALSE(m_pOutroEndEnabled->toBool());
- CuePointer pCue = pTrack->findCueByType(Cue::Type::Outro);
+ CuePointer pCue = pTrack->findCueByType(mixxx::CueType::Outro);
EXPECT_NE(nullptr, pCue);
if (pCue != nullptr) {
EXPECT_DOUBLE_EQ(750.0, pCue->getPosition());
@@ -389,7 +389,7 @@ TEST_F(CueControlTest, OutroCue_SetStartEnd_ClearStartEnd) {
EXPECT_DOUBLE_EQ(1000.0, m_pOutroEndPosition->get());
EXPECT_TRUE(m_pOutroEndEnabled->toBool());
- pCue = pTrack->findCueByType(Cue::Type::Outro);
+ pCue = pTrack->findCueByType(mixxx::CueType::Outro);
EXPECT_NE(nullptr, pCue);
if (pCue != nullptr) {
EXPECT_DOUBLE_EQ(750.0, pCue->getPosition());
@@ -404,7 +404,7 @@ TEST_F(CueControlTest, OutroCue_SetStartEnd_ClearStartEnd) {
EXPECT_DOUBLE_EQ(1000.0, m_pOutroEndPosition->get());
EXPECT_TRUE(m_pOutroEndEnabled->toBool());
- pCue = pTrack->findCueByType(Cue::Type::Outro);
+ pCue = pTrack->findCueByType(mixxx::CueType::Outro);
EXPECT_NE(nullptr, pCue);
if (pCue != nullptr) {
EXPECT_DOUBLE_EQ(Cue::kNoPosition, pCue->getPosition());
@@ -419,5 +419,5 @@ TEST_F(CueControlTest, OutroCue_SetStartEnd_ClearStartEnd) {
EXPECT_DOUBLE_EQ(Cue::kNoPosition, m_pOutroEndPosition->get());
EXPECT_FALSE(m_pOutroEndEnabled->toBool());
- EXPECT_EQ(nullptr, pTrack->findCueByType(Cue::Type::Outro));
+ EXPECT_EQ(nullptr, pTrack->findCueByType(mixxx::CueType::Outro));
}
diff --git a/src/track/cue.cpp b/src/track/cue.cpp
index 57406665e8..f39f84ceb6 100644
--- a/src/track/cue.cpp
+++ b/src/track/cue.cpp
@@ -1,10 +1,12 @@
// cue.cpp
// Created 10/26/2009 by RJ Ryan (rryan@mit.edu)
+#include "track/cue.h"
+
#include <QMutexLocker>
#include <QtDebug>
-#include "track/cue.h"
+#include "engine/engine.h"
#include "util/assert.h"
#include "util/color/color.h"
@@ -24,7 +26,7 @@ Cue::Cue(TrackId trackId)
: m_bDirty(false),
m_iId(-1),
m_trackId(trackId),
- m_type(Cue::Type::Invalid),
+ m_type(mixxx::CueType::Invalid),
m_sampleStartPosition(Cue::kNoPosition),
m_sampleEndPosition(Cue::kNoPosition),
m_iHotCue(-1),
@@ -35,7 +37,7 @@ Cue::Cue(TrackId trackId)
Cue::Cue(int id,
TrackId trackId,
- Cue::Type type,
+ mixxx::CueType type,
double position,
double length,
int hotCue,
@@ -60,6 +62,37 @@ Cue::Cue(int id,
m_sampleEndPosition = Cue::kNoPosition;
}
}
+
+Cue::Cue(TrackId trackId, mixxx::AudioSignal::SampleRate sampleRate, const mixxx::CueInfo& cueInfo)
+ : m_bDirty(false),
+ m_iId(-1),
+ m_trackId(trackId),
+ m_type(cueInfo.getType()),
+ m_sampleStartPosition(Cue::kNoPosition),
+ m_sampleEndPosition(Cue::kNoPosition),
+ m_iHotCue(Cue::kNoHotCue),
+ m_label(cueInfo.getLabel()),
+ m_color(cueInfo.getColor().value_or(kDefaultCueColor)) {
+ DEBUG_ASSERT(!m_label.isNull());
+ DEBUG_ASSERT(sampleRate.valid());
+
+ const double sampleRateKhz = sampleRate / 1000.0;
+ const double millisecsToSamplesFactor = sampleRateKhz * mixxx::kEngineChannelCount;
+ DEBUG_ASSERT(millisecsToSamplesFactor > 0);
+
+ if (cueInfo.getStartPositionMillis()) {
+ m_sampleStartPosition = (*cueInfo.getStartPositionMillis()) * millisecsToSamplesFactor;
+ }
+
+ if (cueInfo.getEndPositionMillis()) {
+ m_sampleEndPosition = (*cueInfo.getEndPositionMillis()) * millisecsToSamplesFactor;
+ }
+
+ if (cueInfo.getHotCueNumber()) {
+ m_iHotCue = *cueInfo.getHotCueNumber();
+ }
+}
+
int Cue::getId() const {
QMutexLocker lock(&m_mutex);
return m_iId;
@@ -86,12 +119,12 @@ void Cue::setTrackId(TrackId trackId) {
emit updated();
}
-Cue::Type Cue::getType() const {
+mixxx::CueType Cue::getType() const {
QMutexLocker lock(&m_mutex);
return m_type;
}
-void Cue::setType(Cue::Type type) {
+void Cue::setType(mixxx::CueType type) {
QMutexLocker lock(&m_mutex);
m_type = type;
m_bDirty = true;
diff --git a/src/track/cue.h b/src/track/cue.h
index 34631127fa..71e1387e03 100644
--- a/src/track/cue.h
+++ b/src/track/cue.h
@@ -5,7 +5,9 @@
#include <QMutex>
#include <QObject>
+#include "track/cueinfo.h"
#include "track/trackid.h"
+#include "util/audiosignal.h"
#include "util/color/rgbcolor.h"
#include "util/memory.h"
@@ -17,21 +19,8 @@ class Cue : public QObject {
Q_OBJECT
public:
- enum class Type {
- Invalid = 0,
- HotCue = 1,
- MainCue = 2,
- Beat = 3, // unused (what is this for?)
- Loop = 4,
- Jump = 5,
- Intro = 6,
- Outro = 7,
- AudibleSound = 8, // range that covers beginning and end of audible sound;
- // not shown to user
- };
-
static constexpr double kNoPosition = -1.0;
- static const int kNoHotCue = -1;
+ static constexpr int kNoHotCue = -1;
~Cue() override = default;
@@ -39,8 +28,8 @@ class Cue : public QObject {
int getId() const;
TrackId getTrackId() const;
- Cue::Type getType() const;
- void setType(Cue::Type type);
+ mixxx::CueType getType() const;
+ void setType(mixxx::CueType type);
double getPosition() const;
void setStartPosition(double samplePosition);
@@ -64,9 +53,13 @@ class Cue : public QObject {
private:
explicit Cue(TrackId trackId);
+ explicit Cue(
+ TrackId trackId,
+ mixxx::AudioSignal::SampleRate sampleRate,
+ const mixxx::CueInfo& cueInfo);
Cue(int id,
TrackId trackId,
- Cue::Type type,
+ mixxx::CueType type,
double position,
double length,
int hotCue,
@@ -81,7 +74,7 @@ class Cue : public QObject {
bool m_bDirty;
int m_iId;
TrackId m_trackId;
- Cue::Type m_type;
+ mixxx::CueType m_type;
double m_sampleStartPosition;
double m_sampleEndPosition;
int m_iHotCue;
diff --git a/src/track/cueinfo.cpp b/src/track/cueinfo.cpp
new file mode 100644
index 0000000000..66e092a2b6
--- /dev/null
+++ b/src/track/cueinfo.cpp
@@ -0,0 +1,86 @@
+#include "track/cueinfo.h"
+
+#include "util/assert.h"
+
+namespace {
+const QString kDefaultLabel = QStringLiteral(""); // empty string, not null
+} // anonymous namespace
+
+namespace mixxx {
+
+CueInfo::CueInfo()
+ : m_type(CueType::Invalid),
+ m_startPositionMillis(std::nullopt),
+ m_endPositionMillis(std::nullopt),
+ m_hotCueNumber(std::nullopt),
+ m_label(kDefaultLabel),
+ m_color(std::nullopt) {
+ DEBUG_ASSERT(!m_label.isNull());
+}
+
+CueInfo::CueInfo(
+ CueType type,
+ std::optional<double> startPositionMillis,
+ std::optional<double> endPositionMillis,
+ std::optional<int> hotCueNumber,
+ QString label,
+ mixxx::RgbColor::optional_t color)
+ : m_type(type),
+ m_startPositionMillis(startPositionMillis),
+ m_endPositionMillis(endPositionMillis),
+ m_hotCueNumber(hotCueNumber),
+ m_label(label),
+ m_color(color) {
+ DEBUG_ASSERT(!m_label.isNull());
+}
+
+CueType CueInfo