From 71f27975fb9b7de5651d9f075ab3056b5ec34080 Mon Sep 17 00:00:00 2001 From: Be Date: Mon, 12 Aug 2019 15:34:30 -0500 Subject: [PATCH] remove useless tracking of automatic vs manually placed cues This was introduced in PR #1242 but is no longer used. --- src/analyzer/analyzersilence.cpp | 24 +------ src/engine/controls/cuecontrol.cpp | 25 +++---- src/engine/controls/cuecontrol.h | 2 +- src/library/dao/cuedao.cpp | 6 +- src/library/dao/trackdao.cpp | 2 +- src/mixer/basetrackplayer.cpp | 1 - src/test/analyzersilence_test.cpp | 104 +---------------------------- src/test/cuecontrol_test.cpp | 37 +++------- src/track/cue.cpp | 20 +----- src/track/cue.h | 33 ++------- src/track/track.cpp | 4 +- 11 files changed, 33 insertions(+), 225 deletions(-) diff --git a/src/analyzer/analyzersilence.cpp b/src/analyzer/analyzersilence.cpp index 49b2d16f9ef5..423ddef5881c 100644 --- a/src/analyzer/analyzersilence.cpp +++ b/src/analyzer/analyzersilence.cpp @@ -10,8 +10,7 @@ constexpr float kSilenceThreshold = 0.001; //constexpr float kSilenceThreshold = db2ratio(-60.0f); bool shouldUpdateMainCue(CuePosition mainCue) { - return mainCue.getSource() != Cue::Source::Manual || - mainCue.getPosition() == -1.0 || + return mainCue.getPosition() == -1.0 || mainCue.getPosition() == 0.0; } @@ -23,16 +22,6 @@ bool hasOutroCueEnd(const Cue& outroCue) { return outroCue.getEndPosition() > 0.0; } -bool needsIntroCueStart(const Cue& introCue) { - return introCue.getSource() != Cue::Source::Manual && - !hasIntroCueStart(introCue); -} - -bool needsOutroCueEnd(const Cue& outroCue) { - return outroCue.getSource() != Cue::Source::Manual && - !hasOutroCueEnd(outroCue); -} - bool shouldAnalyze(TrackPointer pTrack) { CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro); CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro); @@ -41,7 +30,7 @@ bool shouldAnalyze(TrackPointer pTrack) { if (!pIntroCue || !pOutroCue || !pAudibleSound || pAudibleSound->getLength() <= 0) { return true; } - return needsIntroCueStart(*pIntroCue) || needsOutroCueEnd(*pOutroCue); + return !hasIntroCueStart(*pIntroCue) || !hasOutroCueEnd(*pOutroCue); } } // anonymous namespace @@ -117,16 +106,13 @@ void AnalyzerSilence::storeResults(TrackPointer pTrack) { double outroEnd = mixxx::kAnalysisChannels * m_iSignalEnd; if (shouldUpdateMainCue(pTrack->getCuePoint())) { - pTrack->setCuePoint(CuePosition(introStart, Cue::Source::Automatic)); + pTrack->setCuePoint(CuePosition(introStart)); } CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro); if (!pIntroCue) { pIntroCue = pTrack->createAndAddCue(); pIntroCue->setType(Cue::Type::Intro); - pIntroCue->setSource(Cue::Source::Automatic); - } - if (pIntroCue->getSource() != Cue::Source::Manual) { pIntroCue->setPosition(introStart); pIntroCue->setLength(0.0); } @@ -135,9 +121,6 @@ void AnalyzerSilence::storeResults(TrackPointer pTrack) { if (!pOutroCue) { pOutroCue = pTrack->createAndAddCue(); pOutroCue->setType(Cue::Type::Outro); - pOutroCue->setSource(Cue::Source::Automatic); - } - if (pOutroCue->getSource() != Cue::Source::Manual) { pOutroCue->setPosition(-1.0); pOutroCue->setLength(outroEnd); } @@ -146,7 +129,6 @@ void AnalyzerSilence::storeResults(TrackPointer pTrack) { if (pAudibleSound == nullptr || pAudibleSound->getLength() <= 0) { pAudibleSound = pTrack->createAndAddCue(); pAudibleSound->setType(Cue::Type::AudibleSound); - pAudibleSound->setSource(Cue::Source::Automatic); pAudibleSound->setPosition(introStart); pAudibleSound->setLength(outroEnd - introStart); } diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index 0c1cafe804f9..c37e17d898d6 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -443,9 +443,7 @@ void CueControl::loadCuesFromTrack() { if (pLoadCue) { double position = pLoadCue->getPosition(); - Cue::Source source = pLoadCue->getSource(); - - m_pCuePoint->set(quantizeCuePoint(position, source, QuantizeMode::ClosestBeat)); + m_pCuePoint->set(quantizeCuePoint(position, QuantizeMode::ClosestBeat)); } else { m_pCuePoint->set(-1.0); } @@ -453,11 +451,10 @@ void CueControl::loadCuesFromTrack() { if (pIntroCue) { double startPosition = pIntroCue->getPosition(); double endPosition = pIntroCue->getEndPosition(); - Cue::Source source = pIntroCue->getSource(); - m_pIntroStartPosition->set(quantizeCuePoint(startPosition, source, QuantizeMode::PreviousBeat)); + m_pIntroStartPosition->set(quantizeCuePoint(startPosition, QuantizeMode::PreviousBeat)); m_pIntroStartEnabled->forceSet(startPosition == -1.0 ? 0.0 : 1.0); - m_pIntroEndPosition->set(quantizeCuePoint(endPosition, source, QuantizeMode::NextBeat)); + m_pIntroEndPosition->set(quantizeCuePoint(endPosition, QuantizeMode::NextBeat)); m_pIntroEndEnabled->forceSet(endPosition == -1.0 ? 0.0 : 1.0); } else { m_pIntroStartPosition->set(-1.0); @@ -469,11 +466,10 @@ void CueControl::loadCuesFromTrack() { if (pOutroCue) { double startPosition = pOutroCue->getPosition(); double endPosition = pOutroCue->getEndPosition(); - Cue::Source source = pOutroCue->getSource(); - m_pOutroStartPosition->set(quantizeCuePoint(startPosition, source, QuantizeMode::PreviousBeat)); + m_pOutroStartPosition->set(quantizeCuePoint(startPosition, QuantizeMode::PreviousBeat)); m_pOutroStartEnabled->forceSet(startPosition == -1.0 ? 0.0 : 1.0); - m_pOutroEndPosition->set(quantizeCuePoint(endPosition, source, QuantizeMode::NextBeat)); + m_pOutroEndPosition->set(quantizeCuePoint(endPosition, QuantizeMode::NextBeat)); m_pOutroEndEnabled->forceSet(endPosition == -1.0 ? 0.0 : 1.0); } else { m_pOutroStartPosition->set(-1.0); @@ -560,7 +556,6 @@ void CueControl::hotcueSet(HotcueControl* pControl, double v) { pCue->setHotCue(hotcue); pCue->setLabel(""); pCue->setType(Cue::Type::Hotcue); - pCue->setSource(Cue::Source::Manual); // TODO(XXX) deal with spurious signals attachCue(pCue, hotcue); @@ -810,7 +805,7 @@ void CueControl::cueSet(double v) { // Store cue point in loaded track if (pLoadedTrack) { - pLoadedTrack->setCuePoint(CuePosition(cue, Cue::Source::Manual)); + pLoadedTrack->setCuePoint(CuePosition(cue)); } } @@ -1127,7 +1122,6 @@ void CueControl::introStartSet(double v) { pCue = pLoadedTrack->createAndAddCue(); pCue->setType(Cue::Type::Intro); } - pCue->setSource(Cue::Source::Manual); pCue->setPosition(position); pCue->setLength(introEnd != -1.0 ? introEnd - position : 0.0); } @@ -1206,7 +1200,6 @@ void CueControl::introEndSet(double v) { pCue = pLoadedTrack->createAndAddCue(); pCue->setType(Cue::Type::Intro); } - pCue->setSource(Cue::Source::Manual); if (introStart != -1.0) { pCue->setPosition(introStart); pCue->setLength(position - introStart); @@ -1290,7 +1283,6 @@ void CueControl::outroStartSet(double v) { pCue = pLoadedTrack->createAndAddCue(); pCue->setType(Cue::Type::Outro); } - pCue->setSource(Cue::Source::Manual); pCue->setPosition(position); pCue->setLength(outroEnd != -1.0 ? outroEnd - position : 0.0); } @@ -1369,7 +1361,6 @@ void CueControl::outroEndSet(double v) { pCue = pLoadedTrack->createAndAddCue(); pCue->setType(Cue::Type::Outro); } - pCue->setSource(Cue::Source::Manual); if (outroStart != -1.0) { pCue->setPosition(outroStart); pCue->setLength(position - outroStart); @@ -1605,9 +1596,9 @@ double CueControl::quantizeCurrentPosition(QuantizeMode mode) { } } -double CueControl::quantizeCuePoint(double position, Cue::Source source, QuantizeMode mode) { +double CueControl::quantizeCuePoint(double position, QuantizeMode mode) { // Don't quantize unset cues, manual cues or when quantization is disabled. - if (position == -1.0 || source == Cue::Source::Manual || !m_pQuantizeEnabled->toBool()) { + if (position == -1.0 || !m_pQuantizeEnabled->toBool()) { return position; } diff --git a/src/engine/controls/cuecontrol.h b/src/engine/controls/cuecontrol.h index 402b84c75569..86b2c95e3451 100644 --- a/src/engine/controls/cuecontrol.h +++ b/src/engine/controls/cuecontrol.h @@ -183,7 +183,7 @@ class CueControl : public EngineControl { void detachCue(int hotcueNumber); void loadCuesFromTrack(); void reloadCuesFromTrack(); - double quantizeCuePoint(double position, Cue::Source source, QuantizeMode mode); + double quantizeCuePoint(double position, QuantizeMode mode); double quantizeCurrentPosition(QuantizeMode mode); TrackAt getTrackAt() const; diff --git a/src/library/dao/cuedao.cpp b/src/library/dao/cuedao.cpp index 89d4176449d7..c250c42f1122 100644 --- a/src/library/dao/cuedao.cpp +++ b/src/library/dao/cuedao.cpp @@ -48,7 +48,6 @@ CuePointer CueDAO::cueFromRow(const QSqlQuery& query) const { QSqlRecord record = query.record(); int id = record.value(record.indexOf("id")).toInt(); TrackId trackId(record.value(record.indexOf("track_id"))); - int source = record.value(record.indexOf("source")).toInt(); int type = record.value(record.indexOf("type")).toInt(); int position = record.value(record.indexOf("position")).toInt(); int length = record.value(record.indexOf("length")).toInt(); @@ -56,7 +55,7 @@ CuePointer CueDAO::cueFromRow(const QSqlQuery& query) const { QString label = record.value(record.indexOf("label")).toString(); int iColorId = record.value(record.indexOf("color")).toInt(); PredefinedColorPointer color = Color::kPredefinedColorsSet.predefinedColorFromId(iColorId); - CuePointer pCue(new Cue(id, trackId, (Cue::Source)source, (Cue::Type)type, position, length, hotcue, label, color)); + CuePointer pCue(new Cue(id, trackId, (Cue::Type)type, position, length, hotcue, label, color)); m_cues[id] = pCue; return pCue; } @@ -143,8 +142,6 @@ bool CueDAO::saveCue(Cue* cue) { QSqlQuery query(m_database); query.prepare("INSERT INTO " CUE_TABLE " (track_id, source, type, position, length, hotcue, label, color) VALUES (:track_id, :source, :type, :position, :length, :hotcue, :label, :color)"); query.bindValue(":track_id", cue->getTrackId().toVariant()); - query.bindValue(":source", static_cast(cue->getSource())); - query.bindValue(":type", static_cast(cue->getType())); query.bindValue(":position", cue->getPosition()); query.bindValue(":length", cue->getLength()); query.bindValue(":hotcue", cue->getHotCue()); @@ -173,7 +170,6 @@ bool CueDAO::saveCue(Cue* cue) { " WHERE id = :id"); query.bindValue(":id", cue->getId()); query.bindValue(":track_id", cue->getTrackId().toVariant()); - query.bindValue(":source", static_cast(cue->getSource())); query.bindValue(":type", static_cast(cue->getType())); query.bindValue(":position", cue->getPosition()); query.bindValue(":length", cue->getLength()); diff --git a/src/library/dao/trackdao.cpp b/src/library/dao/trackdao.cpp index afcaa07be583..b4eeefb2d53c 100644 --- a/src/library/dao/trackdao.cpp +++ b/src/library/dao/trackdao.cpp @@ -1039,7 +1039,7 @@ bool setTrackSampleRate(const QSqlRecord& record, const int column, bool setTrackCuePoint(const QSqlRecord& record, const int column, TrackPointer pTrack) { - pTrack->setCuePoint(CuePosition(record.value(column).toDouble(), Cue::Source::Manual)); + pTrack->setCuePoint(CuePosition(record.value(column).toDouble())); return false; } diff --git a/src/mixer/basetrackplayer.cpp b/src/mixer/basetrackplayer.cpp index 36a851afeb5d..bb946899f89d 100644 --- a/src/mixer/basetrackplayer.cpp +++ b/src/mixer/basetrackplayer.cpp @@ -226,7 +226,6 @@ TrackPointer BaseTrackPlayerImpl::unloadTrack() { } if (!pLoopCue) { pLoopCue = m_pLoadedTrack->createAndAddCue(); - pLoopCue->setSource(Cue::Source::Manual); pLoopCue->setType(Cue::Type::Loop); } pLoopCue->setPosition(loopStart); diff --git a/src/test/analyzersilence_test.cpp b/src/test/analyzersilence_test.cpp index 0140dc279138..265c57fad80d 100644 --- a/src/test/analyzersilence_test.cpp +++ b/src/test/analyzersilence_test.cpp @@ -53,17 +53,14 @@ TEST_F(AnalyzerSilenceTest, SilenceTrack) { CuePosition cue = pTrack->getCuePoint(); EXPECT_DOUBLE_EQ(0.0, cue.getPosition()); - EXPECT_EQ(Cue::Source::Automatic, cue.getSource()); CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro); EXPECT_DOUBLE_EQ(0.0, pIntroCue->getPosition()); EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pIntroCue->getSource()); CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro); EXPECT_DOUBLE_EQ(-1.0, pOutroCue->getPosition()); EXPECT_DOUBLE_EQ(nTrackSampleDataLength, pOutroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pOutroCue->getSource()); } TEST_F(AnalyzerSilenceTest, EndToEndToneTrack) { @@ -77,17 +74,14 @@ TEST_F(AnalyzerSilenceTest, EndToEndToneTrack) { CuePosition cue = pTrack->getCuePoint(); EXPECT_DOUBLE_EQ(0.0, cue.getPosition()); - EXPECT_EQ(Cue::Source::Automatic, cue.getSource()); CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro); EXPECT_DOUBLE_EQ(0.0, pIntroCue->getPosition()); EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pIntroCue->getSource()); CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro); EXPECT_DOUBLE_EQ(-1.0, pOutroCue->getPosition()); EXPECT_DOUBLE_EQ(nTrackSampleDataLength, pOutroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pOutroCue->getSource()); } TEST_F(AnalyzerSilenceTest, ToneTrackWithSilence) { @@ -111,17 +105,14 @@ TEST_F(AnalyzerSilenceTest, ToneTrackWithSilence) { CuePosition cue = pTrack->getCuePoint(); EXPECT_DOUBLE_EQ(nTrackSampleDataLength / 4, cue.getPosition()); - EXPECT_EQ(Cue::Source::Automatic, cue.getSource()); CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro); EXPECT_DOUBLE_EQ(nTrackSampleDataLength / 4, pIntroCue->getPosition()); EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pIntroCue->getSource()); CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro); EXPECT_DOUBLE_EQ(-1.0, pOutroCue->getPosition()); EXPECT_DOUBLE_EQ(3 * nTrackSampleDataLength / 4, pOutroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pOutroCue->getSource()); } TEST_F(AnalyzerSilenceTest, ToneTrackWithSilenceInTheMiddle) { @@ -157,102 +148,14 @@ TEST_F(AnalyzerSilenceTest, ToneTrackWithSilenceInTheMiddle) { CuePosition cue = pTrack->getCuePoint(); EXPECT_DOUBLE_EQ(oneFifthOfTrackLength, cue.getPosition()); - EXPECT_EQ(Cue::Source::Automatic, cue.getSource()); CuePointer pIntroCue = pTrack->findCueByType(Cue::Type::Intro); EXPECT_DOUBLE_EQ(oneFifthOfTrackLength, pIntroCue->getPosition()); EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pIntroCue->getSource()); CuePointer pOutroCue = pTrack->findCueByType(Cue::Type::Outro); EXPECT_DOUBLE_EQ(-1.0, pOutroCue->getPosition()); EXPECT_DOUBLE_EQ(4 * oneFifthOfTrackLength, pOutroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pOutroCue->getSource()); -} - -TEST_F(AnalyzerSilenceTest, UpdateNonUserAdjustedCues) { - int halfTrackLength = nTrackSampleDataLength / 2; - - pTrack->setCuePoint(CuePosition(100, Cue::Source::Automatic)); // Arbitrary value - - CuePointer pIntroCue = pTrack->createAndAddCue(); - pIntroCue->setType(Cue::Type::Intro); - pIntroCue->setSource(Cue::Source::Automatic); - pIntroCue->setPosition(1000); // Arbitrary value - pIntroCue->setLength(0.0); - - CuePointer pOutroCue = pTrack->createAndAddCue(); - pOutroCue->setType(Cue::Type::Outro); - pOutroCue->setSource(Cue::Source::Automatic); - pOutroCue->setPosition(-1.0); - pOutroCue->setLength(9000); // Arbitrary value - - // Fill the first half with silence - for (int i = 0; i < halfTrackLength; i++) { - pTrackSampleData[i] = 0.0; - } - - // Fill the second half with 1 kHz tone - double omega = 2.0 * M_PI * kTonePitchHz / pTrack->getSampleRate(); - for (int i = halfTrackLength; i < nTrackSampleDataLength; i++) { - pTrackSampleData[i] = sin(i / kChannelCount * omega); - } - - analyzeTrack(); - - CuePosition cue = pTrack->getCuePoint(); - EXPECT_DOUBLE_EQ(halfTrackLength, cue.getPosition()); - EXPECT_EQ(Cue::Source::Automatic, cue.getSource()); - - EXPECT_DOUBLE_EQ(halfTrackLength, pIntroCue->getPosition()); - EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pIntroCue->getSource()); - - EXPECT_DOUBLE_EQ(-1.0, pOutroCue->getPosition()); - EXPECT_DOUBLE_EQ(nTrackSampleDataLength, pOutroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pOutroCue->getSource()); -} - -TEST_F(AnalyzerSilenceTest, UpdateNonUserAdjustedRangeCues) { - int thirdTrackLength = nTrackSampleDataLength / 3; - - CuePointer pIntroCue = pTrack->createAndAddCue(); - pIntroCue->setType(Cue::Type::Intro); - pIntroCue->setSource(Cue::Source::Automatic); - pIntroCue->setPosition(1500.0); // Arbitrary value - pIntroCue->setLength(1000.0); // Arbitrary value - - CuePointer pOutroCue = pTrack->createAndAddCue(); - pOutroCue->setType(Cue::Type::Outro); - pOutroCue->setSource(Cue::Source::Automatic); - pOutroCue->setPosition(9000.0); // Arbitrary value - pOutroCue->setLength(1000.0); // Arbitrary value - - // Fill the first third with silence - for (int i = 0; i < thirdTrackLength; i++) { - pTrackSampleData[i] = 0.0; - } - - // Fill the second third with 1 kHz tone - double omega = 2.0 * M_PI * kTonePitchHz / pTrack->getSampleRate(); - for (int i = thirdTrackLength; i < 2 * thirdTrackLength; i++) { - pTrackSampleData[i] = sin(i / kChannelCount * omega); - } - - // Fill the last third with silence - for (int i = 2 * thirdTrackLength; i < nTrackSampleDataLength; i++) { - pTrackSampleData[i] = 0.0; - } - - analyzeTrack(); - - EXPECT_DOUBLE_EQ(thirdTrackLength, pIntroCue->getPosition()); - EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pIntroCue->getSource()); - - EXPECT_DOUBLE_EQ(-1.0, pOutroCue->getPosition()); - EXPECT_DOUBLE_EQ(2 * thirdTrackLength, pOutroCue->getLength()); - EXPECT_EQ(Cue::Source::Automatic, pOutroCue->getSource()); } TEST_F(AnalyzerSilenceTest, RespectUserEdits) { @@ -261,17 +164,15 @@ TEST_F(AnalyzerSilenceTest, RespectUserEdits) { const double kManualIntroPosition = 0.1 * nTrackSampleDataLength; const double kManualOutroPosition = 0.9 * nTrackSampleDataLength; - pTrack->setCuePoint(CuePosition(kManualCuePosition, Cue::Source::Manual)); + pTrack->setCuePoint(CuePosition(kManualCuePosition)); CuePointer pIntroCue = pTrack->createAndAddCue(); pIntroCue->setType(Cue::Type::Intro); - pIntroCue->setSource(Cue::Source::Manual); pIntroCue->setPosition(kManualIntroPosition); pIntroCue->setLength(0.0); CuePointer pOutroCue = pTrack->createAndAddCue(); pOutroCue->setType(Cue::Type::Outro); - pOutroCue->setSource(Cue::Source::Manual); pOutroCue->setPosition(-1.0); pOutroCue->setLength(kManualOutroPosition); @@ -290,15 +191,12 @@ TEST_F(AnalyzerSilenceTest, RespectUserEdits) { CuePosition cue = pTrack->getCuePoint(); EXPECT_DOUBLE_EQ(kManualCuePosition, cue.getPosition()); - EXPECT_EQ(Cue::Source::Manual, cue.getSource()); EXPECT_DOUBLE_EQ(kManualIntroPosition, pIntroCue->getPosition()); EXPECT_DOUBLE_EQ(0.0, pIntroCue->getLength()); - EXPECT_EQ(Cue::Source::Manual, pIntroCue->getSource()); EXPECT_DOUBLE_EQ(-1.0, pOutroCue->getPosition()); EXPECT_DOUBLE_EQ(kManualOutroPosition, pOutroCue->getLength()); - EXPECT_EQ(Cue::Source::Manual, pOutroCue->getSource()); } } // namespace diff --git a/src/test/cuecontrol_test.cpp b/src/test/cuecontrol_test.cpp index 0a7a7c9d77da..f89459f9858b 100644 --- a/src/test/cuecontrol_test.cpp +++ b/src/test/cuecontrol_test.cpp @@ -75,15 +75,13 @@ class CueControlTest : public BaseSignalPathTest { TEST_F(CueControlTest, LoadUnloadTrack) { TrackPointer pTrack = createTestTrack(); - pTrack->setCuePoint(CuePosition(100.0, Cue::Source::Manual)); + pTrack->setCuePoint(CuePosition(100.0)); auto pIntro = pTrack->createAndAddCue(); pIntro->setType(Cue::Type::Intro); - pIntro->setSource(Cue::Source::Manual); pIntro->setPosition(150.0); pIntro->setLength(50.0); auto pOutro = pTrack->createAndAddCue(); pOutro->setType(Cue::Type::Outro); - pOutro->setSource(Cue::Source::Manual); pOutro->setPosition(250.0); pOutro->setLength(50.0); @@ -114,15 +112,13 @@ TEST_F(CueControlTest, LoadUnloadTrack) { TEST_F(CueControlTest, LoadTrackWithDetectedCues) { TrackPointer pTrack = createTestTrack(); - pTrack->setCuePoint(CuePosition(100.0, Cue::Source::Automatic)); + pTrack->setCuePoint(CuePosition(100.0)); auto pIntro = pTrack->createAndAddCue(); pIntro->setType(Cue::Type::Intro); - pIntro->setSource(Cue::Source::Automatic); pIntro->setPosition(100.0); pIntro->setLength(0.0); auto pOutro = pTrack->createAndAddCue(); pOutro->setType(Cue::Type::Outro); - pOutro->setSource(Cue::Source::Automatic); pOutro->setPosition(-1.0); pOutro->setLength(200.0); @@ -143,12 +139,10 @@ TEST_F(CueControlTest, LoadTrackWithIntroEndAndOutroStart) { TrackPointer pTrack = createTestTrack(); auto pIntro = pTrack->createAndAddCue(); pIntro->setType(Cue::Type::Intro); - pIntro->setSource(Cue::Source::Manual); pIntro->setPosition(-1.0); pIntro->setLength(150.0); auto pOutro = pTrack->createAndAddCue(); pOutro->setType(Cue::Type::Outro); - pOutro->setSource(Cue::Source::Manual); pOutro->setPosition(250.0); pOutro->setLength(0.0); @@ -177,17 +171,15 @@ TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeEnabled) { const double bpm = pTrack->getBpm(); const double beatLength = (60.0 * sampleRate / bpm) * frameSize; - pTrack->setCuePoint(CuePosition(1.9 * beatLength, Cue::Source::Automatic)); + pTrack->setCuePoint(CuePosition(1.9 * beatLength)); auto pIntro = pTrack->createAndAddCue(); pIntro->setType(Cue::Type::Intro); - pIntro->setSource(Cue::Source::Automatic); pIntro->setPosition(2.1 * beatLength); pIntro->setLength(1.2 * beatLength); auto pOutro = pTrack->createAndAddCue(); pOutro->setType(Cue::Type::Outro); - pOutro->setSource(Cue::Source::Automatic); pOutro->setPosition(11.1 * beatLength); pOutro->setLength(4.4 * beatLength); @@ -207,17 +199,15 @@ TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeEnabledNoBeats) { pTrack->setSampleRate(44100); pTrack->setBpm(0.0); - pTrack->setCuePoint(CuePosition(100.0, Cue::Source::Automatic)); + pTrack->setCuePoint(CuePosition(100.0)); auto pIntro = pTrack->createAndAddCue(); pIntro->setType(Cue::Type::Intro); - pIntro->setSource(Cue::Source::Automatic); pIntro->setPosition(250.0); pIntro->setLength(150.0); auto pOutro = pTrack->createAndAddCue(); pOutro->setType(Cue::Type::Outro); - pOutro->setSource(Cue::Source::Automatic); pOutro->setPosition(550.0); pOutro->setLength(250.0); @@ -237,17 +227,15 @@ TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeDisabled) { pTrack->setSampleRate(44100); pTrack->setBpm(120.0); - pTrack->setCuePoint(CuePosition(240.0, Cue::Source::Automatic)); + pTrack->setCuePoint(CuePosition(240.0)); auto pIntro = pTrack->createAndAddCue(); pIntro->setType(Cue::Type::Intro); - pIntro->setSource(Cue::Source::Automatic); pIntro->setPosition(210.0); pIntro->setLength(120.0); auto pOutro = pTrack->createAndAddCue(); pOutro->setType(Cue::Type::Outro); - pOutro->setSource(Cue::Source::Automatic); pOutro->setPosition(770.0); pOutro->setLength(220.0); @@ -265,7 +253,6 @@ TEST_F(CueControlTest, SeekOnLoadDefault) { TrackPointer pTrack = createTestTrack(); auto pIntro = pTrack->createAndAddCue(); pIntro->setType(Cue::Type::Intro); - pIntro->setSource(Cue::Source::Automatic); pIntro->setPosition(250.0); pIntro->setLength(150.0); @@ -279,7 +266,7 @@ TEST_F(CueControlTest, SeekOnLoadMainCue) { config()->set(ConfigKey("[Controls]", "CueRecall"), ConfigValue(static_cast(SeekOnLoadMode::MainCue))); TrackPointer pTrack = createTestTrack(); - pTrack->setCuePoint(CuePosition(100.0, Cue::Source::Manual)); + pTrack->setCuePoint(CuePosition(100.0)); loadTrack(pTrack); @@ -287,7 +274,7 @@ TEST_F(CueControlTest, SeekOnLoadMainCue) { EXPECT_DOUBLE_EQ(100.0, getCurrentSample()); // Move cue and check if track is following it. - pTrack->setCuePoint(CuePosition(200.0, Cue::Source::Manual)); + pTrack->setCuePoint(CuePosition(200.0)); ProcessBuffer(); EXPECT_DOUBLE_EQ(200.0, m_pCuePoint->get()); @@ -298,7 +285,7 @@ TEST_F(CueControlTest, SeekOnLoadDefault_CueInPreroll) { config()->set(ConfigKey("[Controls]", "CueRecall"), ConfigValue(static_cast(SeekOnLoadMode::MainCue))); TrackPointer pTrack = createTestTrack(); - pTrack->setCuePoint(CuePosition(-100.0, Cue::Source::Manual)); + pTrack->setCuePoint(CuePosition(-100.0)); loadTrack(pTrack); @@ -306,7 +293,7 @@ TEST_F(CueControlTest, SeekOnLoadDefault_CueInPreroll) { EXPECT_DOUBLE_EQ(-100.0, getCurrentSample()); // Move cue and check if track is following it. - pTrack->setCuePoint(CuePosition(-200.0, Cue::Source::Manual)); + pTrack->setCuePoint(CuePosition(-200.0)); ProcessBuffer(); EXPECT_DOUBLE_EQ(-200.0, m_pCuePoint->get()); @@ -330,7 +317,6 @@ TEST_F(CueControlTest, IntroCue_SetStartEnd_ClearStartEnd) { if (pCue != nullptr) { EXPECT_DOUBLE_EQ(100.0, pCue->getPosition()); EXPECT_DOUBLE_EQ(0.0, pCue->getLength()); - EXPECT_EQ(Cue::Source::Manual, pCue->getSource()); } // Set intro end cue @@ -347,7 +333,6 @@ TEST_F(CueControlTest, IntroCue_SetStartEnd_ClearStartEnd) { if (pCue != nullptr) { EXPECT_DOUBLE_EQ(100.0, pCue->getPosition()); EXPECT_DOUBLE_EQ(400.0, pCue->getLength()); - EXPECT_EQ(Cue::Source::Manual, pCue->getSource()); } // Clear intro start cue @@ -363,7 +348,6 @@ TEST_F(CueControlTest, IntroCue_SetStartEnd_ClearStartEnd) { if (pCue != nullptr) { EXPECT_DOUBLE_EQ(-1.0, pCue->getPosition()); EXPECT_DOUBLE_EQ(500.0, pCue->getLength()); - EXPECT_EQ(Cue::Source::Manual, pCue->getSource()); } // Clear intro end cue @@ -394,7 +378,6 @@ TEST_F(CueControlTest, OutroCue_SetStartEnd_ClearStartEnd) { if (pCue != nullptr) { EXPECT_DOUBLE_EQ(750.0, pCue->getPosition()); EXPECT_DOUBLE_EQ(0.0, pCue->getLength()); - EXPECT_EQ(Cue::Source::Manual, pCue->getSource()); } // Set outro end cue @@ -411,7 +394,6 @@ TEST_F(CueControlTest, OutroCue_SetStartEnd_ClearStartEnd) { if (pCue != nullptr) { EXPECT_DOUBLE_EQ(750.0, pCue->getPosition()); EXPECT_DOUBLE_EQ(250.0, pCue->getLength()); - EXPECT_EQ(Cue::Source::Manual, pCue->getSource()); } // Clear outro start cue @@ -427,7 +409,6 @@ TEST_F(CueControlTest, OutroCue_SetStartEnd_ClearStartEnd) { if (pCue != nullptr) { EXPECT_DOUBLE_EQ(-1.0, pCue->getPosition()); EXPECT_DOUBLE_EQ(1000.0, pCue->getLength()); - EXPECT_EQ(Cue::Source::Manual, pCue->getSource()); } // Clear outro end cue diff --git a/src/track/cue.cpp b/src/track/cue.cpp index 14ddf3a40117..dec0d8f1c4c9 100644 --- a/src/track/cue.cpp +++ b/src/track/cue.cpp @@ -23,7 +23,6 @@ Cue::Cue(TrackId trackId) : m_bDirty(false), m_iId(-1), m_trackId(trackId), - m_source(Cue::Source::Unknown), m_type(Cue::Type::Invalid), m_samplePosition(-1.0), m_length(0.0), @@ -33,12 +32,11 @@ Cue::Cue(TrackId trackId) DEBUG_ASSERT(!m_label.isNull()); } -Cue::Cue(int id, TrackId trackId, Cue::Source source, Cue::Type type, double position, double length, +Cue::Cue(int id, TrackId trackId, Cue::Type type, double position, double length, int hotCue, QString label, PredefinedColorPointer color) : m_bDirty(false), m_iId(id), m_trackId(trackId), - m_source(source), m_type(type), m_samplePosition(position), m_length(length), @@ -74,19 +72,6 @@ void Cue::setTrackId(TrackId trackId) { emit(updated()); } -Cue::Source Cue::getSource() const { - QMutexLocker lock(&m_mutex); - return m_source; -} - -void Cue::setSource(Cue::Source source) { - QMutexLocker lock(&m_mutex); - m_source = source; - m_bDirty = true; - lock.unlock(); - emit(updated()); -} - Cue::Type Cue::getType() const { QMutexLocker lock(&m_mutex); return m_type; @@ -190,6 +175,5 @@ double Cue::getEndPosition() const { } bool operator==(const CuePosition& lhs, const CuePosition& rhs) { - return lhs.getPosition() == rhs.getPosition() && - lhs.getSource() == rhs.getSource(); + return lhs.getPosition() == rhs.getPosition(); } diff --git a/src/track/cue.h b/src/track/cue.h index fd38d13a5708..3dfefa126324 100644 --- a/src/track/cue.h +++ b/src/track/cue.h @@ -17,12 +17,6 @@ class Cue : public QObject { Q_OBJECT public: - enum class Source { - Unknown = 0, - Automatic = 1, - Manual = 2, - }; - enum class Type { Invalid = 0, Hotcue = 1, @@ -42,9 +36,6 @@ class Cue : public QObject { int getId() const; TrackId getTrackId() const; - Cue::Source getSource() const; - void setSource(Cue::Source source); - Cue::Type getType() const; void setType(Cue::Type type); @@ -70,7 +61,7 @@ class Cue : public QObject { private: explicit Cue(TrackId trackId); - Cue(int id, TrackId trackId, Cue::Source source, Cue::Type type, double position, double length, + Cue(int id, TrackId trackId, Cue::Type type, double position, double length, int hotCue, QString label, PredefinedColorPointer color); void setDirty(bool dirty); void setId(int id); @@ -81,7 +72,6 @@ class Cue : public QObject { bool m_bDirty; int m_iId; TrackId m_trackId; - Cue::Source m_source; Cue::Type m_type; double m_samplePosition; double m_length; @@ -107,9 +97,9 @@ class CuePointer: public std::shared_ptr { class CuePosition { public: CuePosition() - : m_position(0.0), m_source(Cue::Source::Unknown) {} - CuePosition(double position, Cue::Source source) - : m_position(position), m_source(source) {} + : m_position(0.0) {} + CuePosition(double position) + : m_position(position) {} double getPosition() const { return m_position; @@ -119,27 +109,16 @@ class CuePosition { m_position = position; } - Cue::Source getSource() const { - return m_source; - } - - void setSource(Cue::Source source) { - m_source = source; - } - - void set(double position, Cue::Source source) { + void set(double position) { m_position = position; - m_source = source; } void reset() { m_position = 0.0; - m_source = Cue::Source::Unknown; } private: double m_position; - Cue::Source m_source; }; bool operator==(const CuePosition& lhs, const CuePosition& rhs); @@ -151,7 +130,7 @@ bool operator!=(const CuePosition& lhs, const CuePosition& rhs) { inline QDebug operator<<(QDebug dbg, const CuePosition& arg) { - return dbg << "position =" << arg.getPosition() << "/" << "source =" << static_cast(arg.getSource()); + return dbg << "position =" << arg.getPosition(); } #endif // MIXXX_CUE_H diff --git a/src/track/track.cpp b/src/track/track.cpp index a191e6ba2242..d9ee885858c1 100644 --- a/src/track/track.cpp +++ b/src/track/track.cpp @@ -653,7 +653,6 @@ void Track::setCuePoint(CuePosition cue) { // Store the cue point in a load cue CuePointer pLoadCue = findCueByType(Cue::Type::MainCue); - Cue::Source source = cue.getSource(); double position = cue.getPosition(); if (position != 0.0 && position != -1.0) { if (!pLoadCue) { @@ -666,7 +665,6 @@ void Track::setCuePoint(CuePosition cue) { m_cuePoints.push_back(pLoadCue); } pLoadCue->setPosition(position); - pLoadCue->setSource(source); } else if (pLoadCue) { disconnect(pLoadCue.get(), 0, this, 0); m_cuePoints.removeOne(pLoadCue); @@ -764,7 +762,7 @@ void Track::setCuePoints(const QList& cuePoints) { connect(pCue.get(), &Cue::updated, this, &Track::slotCueUpdated); // update main cue point if (pCue->getType() == Cue::Type::MainCue) { - m_record.setCuePoint(CuePosition(pCue->getPosition(), pCue->getSource())); + m_record.setCuePoint(CuePosition(pCue->getPosition())); } } markDirtyAndUnlock(&lock);