diff options
24 files changed, 446 insertions, 296 deletions
diff --git a/src/analyzer/analyzerbeats.cpp b/src/analyzer/analyzerbeats.cpp index e6f8fbab53..7d9339c9c9 100644 --- a/src/analyzer/analyzerbeats.cpp +++ b/src/analyzer/analyzerbeats.cpp @@ -164,14 +164,20 @@ bool AnalyzerBeats::shouldAnalyze(TrackPointer pTrack) const { qDebug() << "Re-analyzing track with invalid BPM despite preference settings."; return true; } - if (pBeats->findNextBeat(0) <= 0.0) { + + QString subVersion = pBeats->getSubVersion(); + if (subVersion == mixxx::rekordboxconstants::beatsSubversion) { + return m_bPreferencesReanalyzeImported; + } + + if (subVersion.isEmpty() && pBeats->findNextBeat(0) <= 0.0 && + m_pluginId != mixxx::AnalyzerSoundTouchBeats::pluginInfo().id) { + // This happens if the beat grid was created from the metadata BPM value. qDebug() << "First beat is 0 for grid so analyzing track to find first beat."; return true; } - // Version check QString version = pBeats->getVersion(); - QString subVersion = pBeats->getSubVersion(); QHash<QString, QString> extraVersionInfo = getExtraVersionInfo( pluginID, m_bPreferencesFastAnalysis); @@ -183,9 +189,7 @@ bool AnalyzerBeats::shouldAnalyze(TrackPointer pTrack) const { iMinBpm, iMaxBpm, extraVersionInfo); - if (subVersion == mixxx::rekordboxconstants::beatsSubversion) { - return m_bPreferencesReanalyzeImported; - } + if (version == newVersion && subVersion == newSubVersion) { // If the version and settings have not changed then if the world is // sane, re-analyzing will do nothing. @@ -251,41 +255,7 @@ void AnalyzerBeats::storeResults(TrackPointer pTrack) { pBeats = BeatFactory::makeBeatGrid(m_sampleRate, bpm, 0.0f); } - mixxx::BeatsPointer pCurrentBeats = pTrack->getBeats(); - - // If the track has no beats object then set our newly generated one - // regardless of beat lock. - if (!pCurrentBeats) { - pTrack->setBeats(pBeats); - return; - } - - // If the track received the beat lock while we were analyzing it then we - // abort setting it. - if (pTrack->isBpmLocked()) { - qDebug() << "Track was BPM-locked as we were analyzing it. Aborting analysis."; - return; - } - - // If the user prefers to replace old beatgrids with newly generated ones or - // the old beatgrid has 0-bpm then we replace it. - bool zeroCurrentBpm = pCurrentBeats->getBpm() == 0.0; - if (m_bPreferencesReanalyzeOldBpm || zeroCurrentBpm) { - if (zeroCurrentBpm) { - qDebug() << "Replacing 0-BPM beatgrid with a" << pBeats->getBpm() - << "beatgrid."; - } - pTrack->setBeats(pBeats); - return; - } - - // If we got here then the user doesn't want to replace the beatgrid but - // since the first beat is zero we'll apply the offset we just detected. - double currentFirstBeat = pCurrentBeats->findNextBeat(0); - double newFirstBeat = pBeats->findNextBeat(0); - if (currentFirstBeat == 0.0 && newFirstBeat > 0) { - pTrack->setBeats(pCurrentBeats->translate(newFirstBeat)); - } + pTrack->trySetBeats(pBeats); } // static diff --git a/src/audio/signalinfo.h b/src/audio/signalinfo.h index 5805f8ade0..685dab1698 100644 --- a/src/audio/signalinfo.h +++ b/src/audio/signalinfo.h @@ -43,6 +43,12 @@ class SignalInfo final { return samples / getChannelCount(); } + // Conversion: #samples / sample offset -> #frames / frame offset + double samples2framesFractional(double samples) const { + DEBUG_ASSERT(getChannelCount().isValid()); + return samples / getChannelCount(); + } + // Conversion: #frames / frame offset -> #samples / sample offset SINT frames2samples(SINT frames) const { DEBUG_ASSERT(getChannelCount().isValid()); @@ -50,9 +56,14 @@ class SignalInfo final { } // Conversion: #frames / frame offset -> second offset - double frames2secs(SINT frames) const { + double frames2secsFractional(double frames) const { DEBUG_ASSERT(getSampleRate().isValid()); - return static_cast<double>(frames) / getSampleRate(); + return frames / getSampleRate(); + } + + // Conversion: #frames / frame offset -> second offset + double frames2secs(SINT frames) const { + return frames2secsFractional(static_cast<double>(frames)); } // Conversion: second offset -> #frames / frame offset diff --git a/src/engine/controls/bpmcontrol.cpp b/src/engine/controls/bpmcontrol.cpp index babd2b7dd6..561a9567f4 100644 --- a/src/engine/controls/bpmcontrol.cpp +++ b/src/engine/controls/bpmcontrol.cpp @@ -172,7 +172,7 @@ void BpmControl::slotAdjustBeatsFaster(double v) { if (pBeats && (pBeats->getCapabilities() & mixxx::Beats::BEATSCAP_SETBPM)) { double bpm = pBeats->getBpm(); double adjustedBpm = bpm + kBpmAdjustStep; - pTrack->setBeats(pBeats->setBpm(adjustedBpm)); + pTrack->trySetBeats(pBeats->setBpm(adjustedBpm)); } } @@ -188,7 +188,7 @@ void BpmControl::slotAdjustBeatsSlower(double v) { if (pBeats && (pBeats->getCapabilities() & mixxx::Beats::BEATSCAP_SETBPM)) { double bpm = pBeats->getBpm(); double adjustedBpm = math_max(kBpmAdjustMin, bpm - kBpmAdjustStep); - pTrack->setBeats(pBeats->setBpm(adjustedBpm)); + pTrack->trySetBeats(pBeats->setBpm(adjustedBpm)); } } @@ -204,7 +204,7 @@ void BpmControl::slotTranslateBeatsEarlier(double v) { if (pBeats && (pBeats->getCapabilities() & mixxx::Beats::BEATSCAP_TRANSLATE)) { const double translate_dist = getSampleOfTrack().rate * -.01; - pTrack->setBeats(pBeats->translate(translate_dist)); + pTrack->trySetBeats(pBeats->translate(translate_dist)); } } @@ -221,7 +221,7 @@ void BpmControl::slotTranslateBeatsLater(double v) { (pBeats->getCapabilities() & mixxx::Beats::BEATSCAP_TRANSLATE)) { // TODO(rryan): Track::getSampleRate is possibly inaccurate! const double translate_dist = getSampleOfTrack().rate * .01; - pTrack->setBeats(pBeats->translate(translate_dist)); + pTrack->trySetBeats(pBeats->translate(translate_dist)); } } @@ -255,7 +255,7 @@ void BpmControl::slotTapFilter(double averageLength, int numSamples) { // (60 seconds per minute) * (1000 milliseconds per second) / (X millis per // beat) = Y beats/minute double averageBpm = 60.0 * 1000.0 / averageLength / rateRatio; - pTrack->setBeats(pBeats->setBpm(averageBpm)); + pTrack->trySetBeats(pBeats->setBpm(averageBpm)); } void BpmControl::slotControlBeatSyncPhase(double value) { @@ -1023,7 +1023,7 @@ void BpmControl::slotBeatsTranslate(double v) { if (delta % 2 != 0) { delta--; } - pTrack->setBeats(pBeats->translate(delta)); + pTrack->trySetBeats(pBeats->translate(delta)); } } @@ -1042,7 +1042,7 @@ void BpmControl::slotBeatsTranslateMatchAlignment(double v) { m_dUserOffset.setValue(0.0); double offset = getPhaseOffset(getSampleOfTrack().current); - pTrack->setBeats(pBeats->translate(-offset)); + pTrack->trySetBeats(pBeats->translate(-offset)); } } diff --git a/src/library/banshee/bansheeplaylistmodel.cpp b/src/library/banshee/bansheeplaylistmodel.cpp index 9b530a260a..f0eca64c68 100644 --- a/src/library/banshee/bansheeplaylistmodel.cpp +++ b/src/library/banshee/bansheeplaylistmodel.cpp @@ -271,7 +271,7 @@ TrackPointer BansheePlaylistModel::getTrack(const QModelIndex& index) const { pTrack->setRating(getFieldString(index, CLM_RATING).toInt()); pTrack->setTrackNumber(getFieldString(index, CLM_TRACKNUMBER)); double bpm = getFieldString(index, CLM_BPM).toDouble(); - bpm = pTrack->setBpm(bpm); + pTrack->trySetBpm(bpm); pTrack->setBitrate(getFieldString(index, CLM_BITRATE).toInt()); pTrack->setComment(getFieldString(index, CLM_COMMENT)); pTrack->setComposer(getFieldString(index, CLM_COMPOSER)); diff --git a/src/library/baseexternalplaylistmodel.cpp b/src/library/baseexternalplaylistmodel.cpp index b60910959b..30762d468a 100644 --- a/src/library/baseexternalplaylistmodel.cpp +++ b/src/library/baseexternalplaylistmodel.cpp @@ -56,8 +56,9 @@ TrackPointer BaseExternalPlaylistModel::getTrack(const QModelIndex& index) const QString genre = index.sibling(index.row(), fieldIndex("genre")).data().toString(); pTrack->setGenre(genre); - float bpm = index.sibling(index.row(), fieldIndex("bpm")).data().toString().toFloat(); - pTrack->setBpm(bpm); + float bpm = index.sibling( + index.row(), fieldIndex("bpm")).data().toString().toFloat(); + pTrack->trySetBpm(bpm); } return pTrack; } diff --git a/src/library/baseexternaltrackmodel.cpp b/src/library/baseexternaltrackmodel.cpp index 3795ffe894..1f4649e333 100644 --- a/src/library/baseexternaltrackmodel.cpp +++ b/src/library/baseexternaltrackmodel.cpp @@ -73,7 +73,7 @@ TrackPointer BaseExternalTrackModel::getTrack(const QModelIndex& index) const { pTrack->setAlbum(album); pTrack->setYear(year); pTrack->setGenre(genre); - pTrack->setBpm(bpm); + pTrack->trySetBpm(bpm); } } else { qWarning() << "Failed to load external track" << location; diff --git a/src/library/basesqltablemodel.cpp b/src/library/basesqltablemodel.cpp index b1314b323d..7d1fb55417 100644 --- a/src/library/basesqltablemodel.cpp +++ b/src/library/basesqltablemodel.cpp @@ -702,7 +702,7 @@ bool BaseSqlTableModel::setTrackValueForColumn( } else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_COMMENT) == column) { pTrack->setComment(value.toString()); } else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_BPM) == column) { - pTrack->setBpm(static_cast<double>(value.toDouble())); + pTrack->trySetBpm(static_cast<double>(value.toDouble())); } else if (fieldIndex(ColumnCache::COLUMN_LIBRARYTABLE_PLAYED) == column) { // Update both the played flag and the number of times played pTrack->updatePlayCounter(value.toBool()); diff --git a/src/library/browse/browsetablemodel.cpp b/src/library/browse/browsetablemodel.cpp index a61914b4f4..36a26b5d81 100644 --- a/src/library/browse/browsetablemodel.cpp +++ b/src/library/browse/browsetablemodel.cpp @@ -396,7 +396,7 @@ bool BrowseTableModel::setData( pTrack->setAlbum(value.toString()); break; case COLUMN_BPM: - pTrack->setBpm(value.toDouble()); + pTrack->trySetBpm(value.toDouble()); break; case COLUMN_KEY: pTrack->setKeyText(value.toString()); diff --git a/src/library/dao/trackdao.cpp b/src/library/dao/trackdao.cpp index f0da8334f1..c5fcce5670 100644 --- a/src/library/dao/trackdao.cpp +++ b/src/library/dao/trackdao.cpp @@ -1224,11 +1224,16 @@ bool setTrackBeats(const QSqlRecord& record, const int column, const mixxx::BeatsPointer pBeats = BeatFactory::loadBeatsFromByteArray( pTrack->getSampleRate(), beatsVersion, beatsSubVersion, beatsBlob); if (pBeats) { - pTrack->setBeats(pBeats); + if (bpmLocked) { + pTrack->trySetAndLockBeats(pBeats); + } else { + pTrack->trySetBeats(pBeats); + } } else { - pTrack->setBpm(bpm); + // Load a temorary beat grid without offset that will be replaced by the analyzer. + const auto pBeats = BeatFactory::makeBeatGrid(pTrack->getSampleRate(), bpm, 0.0); + pTrack->trySetBeats(pBeats); } - pTrack->setBpmLocked(bpmLocked); return false; } diff --git a/src/library/dlgtrackinfo.cpp b/src/library/dlgtrackinfo.cpp index 3ca293f6ee..5ceb5852ec 100644 --- a/src/library/dlgtrackinfo.cpp +++ b/src/library/dlgtrackinfo.cpp @@ -395,10 +395,8 @@ void DlgTrackInfo::saveTrack() { m_pLoadedTrack->setTrackNumber(txtTrackNumber->text()); m_pLoadedTrack->setComment(txtComment->toPlainText()); - if (!m_pLoadedTrack->isBpmLocked()) { - m_pLoadedTrack->setBeats(m_pBeatsClone); - reloadTrackBeats(*m_pLoadedTrack); - } + m_pLoadedTrack->trySetBeats(m_pBeatsClone); + reloadTrackBeats(*m_pLoadedTrack); // If the user is editing the key and hits enter to close DlgTrackInfo, the // editingFinished signal will not fire in time. Run the key text changed diff --git a/src/library/rekordbox/rekordboxfeature.cpp b/src/library/rekordbox/rekordboxfeature.cpp index 454b45498d..c06d68b3a7 100644 --- a/src/library/rekordbox/rekordboxfeature.cpp +++ b/src/library/rekordbox/rekordboxfeature.cpp @@ -943,7 +943,7 @@ void readAnalyze(TrackPointer track, sampleRate, mixxx::rekordboxconstants::beatsSubversion, beats); - track->setBeats(pBeats); + track->trySetBeats(pBeats); } break; case rekordbox_anlz_t::SECTION_TAGS_CUES: { if (ignoreCues) { diff --git a/src/mixer/basetrackplayer.cpp b/src/mixer/basetrackplayer.cpp index b0098ebc8d..350bcf5911 100644 --- a/src/mixer/basetrackplayer.cpp +++ b/src/mixer/basetrackplayer.cpp @@ -206,7 +206,7 @@ TrackPointer BaseTrackPlayerImpl::loadFakeTrack(bool bPlay, double filebpm) { mixxx::audio::Bitrate(), mixxx::Duration::fromSeconds(10)); if (filebpm > 0) { - pTrack->setBpm(filebpm); + pTrack->trySetBpm(filebpm); } TrackPointer pOldTrack = m_pLoadedTrack; diff --git a/src/test/beatgridtest.cpp b/src/test/beatgridtest.cpp index 16276e5b76..4538a934d1 100644 --- a/src/test/beatgridtest.cpp +++ b/src/test/beatgridtest.cpp @@ -27,7 +27,7 @@ TEST(BeatGridTest, Scale) { TrackPointer pTrack = newTrack(sampleRate); double bpm = 60.0; - pTrack->setBpm(bpm); + pTrack->trySetBpm(bpm); auto pGrid = BeatGrid::makeBeatGrid(pTrack->getSampleRate(), QString(), bpm, 0); @@ -57,7 +57,7 @@ TEST(BeatGridTest, TestNthBeatWhenOnBeat) { double bpm = 60.1; const int kFrameSize = 2; - pTrack->setBpm(bpm); + pTrack->trySetBpm(bpm); double beatLength = (60.0 * sampleRate / bpm) * kFrameSize; auto pGrid = BeatGrid::makeBeatGrid(pTrack->getSampleRate(), QString(), bpm, 0); @@ -91,7 +91,7 @@ TEST(BeatGridTest, TestNthBeatWhenOnBeat_BeforeEpsilon) { double bpm = 60.1; const int kFrameSize = 2; - pTrack->setBpm(bpm); + pTrack->trySetBpm(bpm); double beatLength = (60.0 * sampleRate / bpm) * kFrameSize; auto pGrid = BeatGrid::makeBeatGrid(pTrack->getSampleRate(), QString(), bpm, 0); @@ -127,7 +127,7 @@ TEST(BeatGridTest, TestNthBeatWhenOnBeat_AfterEpsilon) { double bpm = 60.1; const int kFrameSize = 2; - pTrack->setBpm(bpm); + pTrack->trySetBpm(bpm); double beatLength = (60.0 * sampleRate / bpm) * kFrameSize; auto pGrid = BeatGrid::makeBeatGrid(pTrack->getSampleRate(), QString(), bpm, 0); @@ -163,7 +163,7 @@ TEST(BeatGridTest, TestNthBeatWhenNotOnBeat) { double bpm = 60.1; const int kFrameSize = 2; - pTrack->setBpm(bpm); + pTrack->trySetBpm(bpm); double beatLength = (60.0 * sampleRate / bpm) * kFrameSize; auto pGrid = BeatGrid::makeBeatGrid(pTrack->getSampleRate(), QString(), bpm, 0); @@ -190,4 +190,22 @@ TEST(BeatGridTest, TestNthBeatWhenNotOnBeat) { EXPECT_NEAR(nextBeat, foundNextBeat, kMaxBeatError); } +TEST(BeatGridTest, FromMetadata) { + int sampleRate = 44100; + TrackPointer pTrack = newTrack(sampleRate); + + double bpm = 60.1; + double echoBpm = pTrack->trySetBpm(bpm); + EXPECT_DOUBLE_EQ(echoBpm, bpm); + + auto pBeats = pTrack->getBeats(); + EXPECT_DOUBLE_EQ(pBeats->getBpm(), bpm); + + echoBpm = pTrack->trySetBpm(-60.1); + EXPECT_DOUBLE_EQ(echoBpm, mixxx::Bpm::kValueUndefined); + + pBeats = pTrack->getBeats(); + EXPECT_EQ(pBeats.isNull(), true); +} + } // namespace diff --git a/src/test/beatmaptest.cpp b/src/test/beatmaptest.cpp index 75ac937f0f..a6b7c22174 100644 --- a/src/test/beatmaptest.cpp +++ b/src/test/beatmaptest.cpp @@ -48,7 +48,7 @@ class BeatMapTest : public testing::Test { TEST_F(BeatMapTest, Scale) { const double bpm = 60.0; - m_pTrack->setBpm(bpm); + m_pTrack->trySetBpm(bpm); double beatLengthFrames = getBeatLengthFrames(bpm); double startOffsetFrames = 7; const int numBeats = 100; @@ -78,7 +78,7 @@ TEST_F(BeatMapTest, Scale) { TEST_F(BeatMapTest, TestNthBeat) { const double bpm = 60.0; - m_pTrack->setBpm(bpm); + m_pTrack->trySetBpm(bpm); double beatLengthFrames = getBeatLengthFrames(bpm); double startOffsetFrames = 7; double beatLengthSamples = getBeatLengthSamples(bpm); @@ -110,7 +110,7 @@ TEST_F(BeatMapTest, TestNthBeat) { TEST_F(BeatMapTest, TestNthBeatWhenOnBeat) { const double bpm = 60.0; - m_pTrack->setBpm(bpm); + m_pTrack->trySetBpm(bpm); double beatLengthFrames = getBeatLengthFrames(bpm); double startOffsetFrames = 7; double beatLengthSamples = getBeatLengthSamples(bpm); @@ -147,7 +147,7 @@ TEST_F(BeatMapTest, TestNthBeatWhenOnBeat) { TEST_F(BeatMapTest, TestNthBeatWhenOnBeat_BeforeEpsilon) { const double bpm = 60.0; - m_pTrack->setBpm(bpm); + m_pTrack->trySetBpm(bpm); double beatLengthFrames = getBeatLengthFrames(bpm); double startOffsetFrames = 7; double beatLengthSamples = getBeatLengthSamples(bpm); @@ -186,7 +186,7 @@ TEST_F(BeatMapTest, TestNthBeatWhenOnBeat_BeforeEpsilon) { TEST_F(BeatMapTest, TestNthBeatWhenOnBeat_AfterEpsilon) { const double bpm = 60.0; - m_pTrack->setBpm(bpm); + m_pTrack->trySetBpm(bpm); double beatLengthFrames = getBeatLengthFrames(bpm); double startOffsetFrames = 7; double beatLengthSamples = getBeatLengthSamples(bpm); @@ -226,7 +226,7 @@ TEST_F(BeatMapTest, TestNthBeatWhenOnBeat_AfterEpsilon) { TEST_F(BeatMapTest, TestNthBeatWhenNotOnBeat) { const double bpm = 60.0; - m_pTrack->setBpm(bpm); + m_pTrack->trySetBpm(bpm); double beatLengthFrames = getBeatLengthFrames(bpm); double startOffsetFrames = 7; double beatLengthSamples = getBeatLengthSamples(bpm); @@ -263,7 +263,7 @@ TEST_F(BeatMapTest, TestNthBeatWhenNotOnBeat) { TEST_F(BeatMapTest, TestBpmAround) { const double filebpm = 60.0; double approx_beat_length = getBeatLengthSamples(filebpm); - m_pTrack->setBpm(filebpm); + m_pTrack->trySetBpm(filebpm); const int numBeats = 64; QVector<double> beats; diff --git a/src/test/beatstranslatetest.cpp b/src/test/beatstranslatetest.cpp index acdc5ec1d7..dbbdefdb8c 100644 --- a/src/test/beatstranslatetest.cpp +++ b/src/test/beatstranslatetest.cpp @@ -11,12 +11,12 @@ TEST_F(BeatsTranslateTest, SimpleTranslateMatch) { const double firstBeat = 0.0; auto grid1 = mixxx::BeatGrid::makeBeatGrid( m_pTrack1->getSampleRate(), QString(), bpm, firstBeat); - m_pTrack1->setBeats(mixxx::BeatsPointer(grid1)); + m_pTrack1->trySetBeats(grid1); ASSERT_DOUBLE_EQ(firstBeat, grid1->findClosestBeat(0)); auto grid2 = mixxx::BeatGrid::makeBeatGrid( m_pTrack2->getSampleRate(), QString(), bpm, firstBeat); - m_pTrack2->setBeats(mixxx::BeatsPointer(grid2)); + m_pTrack2->trySetBeats(grid2); ASSERT_DOUBLE_EQ(firstBeat, grid2->findClosestBeat(0)); // Seek deck 1 forward a bit. diff --git a/src/test/cuecontrol_test.cpp b/src/test/cuecontrol_test.cpp index f5fc8cad63..8439ecda9a 100644 --- a/src/test/cuecontrol_test.cpp +++ b/src/test/cuecontrol_test.cpp @@ -175,7 +175,7 @@ TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeEnabled) { m_pQuantizeEnabled->set(1); TrackPointer pTrack = createTestTrack(); - pTrack->setBpm(120.0); + pTrack->trySetBpm(120.0); const int frameSize = 2; const int sampleRate = pTrack->getSampleRate(); @@ -209,7 +209,7 @@ TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeEnabledNoBeats) { m_pQuantizeEnabled->set(1); TrackPointer pTrack = createTestTrack(); - pTrack->setBpm(0.0); + pTrack->trySetBpm(0.0); pTrack->setCuePoint(CuePosition(100.0)); @@ -238,7 +238,7 @@ TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeDisabled) { m_pQuantizeEnabled->set(0); TrackPointer pTrack = createTestTrack(); - pTrack->setBpm(120.0); + pTrack->trySetBpm(120.0); pTrack->setCuePoint(CuePosition(240.0)); @@ -346,7 +346,7 @@ TEST_F(CueControlTest, FollowCueOnQuantize) { config()->set(ConfigKey("[Controls]", "CueRecall"), ConfigValue(static_cast<int>(SeekOnLoadMode::MainCue))); TrackPointer pTrack = createTestTrack(); - pTrack->setBpm(120.0); + pTrack->trySetBpm(120.0); const int frameSize = 2; const int sampleRate = pTrack->getSampleRate(); diff --git a/src/test/enginesynctest.cpp b/src/test/enginesynctest.cpp index 6d1a57954e..c454cf06b5 100644 --- a/src/test/enginesynctest.cpp +++ b/src/test/enginesynctest.cpp @@ -194,9 +194,9 @@ TEST_F(EngineSyncTest, ExplicitMasterPersists) { // If we set an explicit master, enabling sync or pressing play on other decks // doesn't cause the master to move around. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 120, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 124, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); auto pButtonMasterSync1 = std::make_unique<ControlProxy>(m_sGroup1, "sync_mode"); @@ -226,11 +226,11 @@ TEST_F(EngineSyncTest, ExplicitMasterPersists) { TEST_F(EngineSyncTest, SetMasterWhilePlaying) { // Make sure we don't get two master lights if we change masters while playing. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 120, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 124, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); mixxx::BeatsPointer pBeats3 = BeatFactory::makeBeatGrid(m_pTrack3->getSampleRate(), 128, 0.0); - m_pTrack3->setBeats(pBeats3); + m_pTrack3->trySetBeats(pBeats3); auto pButtonMasterSync1 = std::make_unique<ControlProxy>(m_sGroup1, "sync_mode"); @@ -260,7 +260,7 @@ TEST_F(EngineSyncTest, SetMasterWhilePlaying) { TEST_F(EngineSyncTest, SetEnabledBecomesMaster) { // If we set the first channel with a valid tempo to follower, it should be master. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 80, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); auto pButtonMasterSync1 = std::make_unique<ControlProxy>(m_sGroup1, "sync_mode"); pButtonMasterSync1->slotSet(SYNC_FOLLOWER); @@ -287,10 +287,10 @@ TEST_F(EngineSyncTest, DisableInternalMasterWhilePlaying) { // Make sure both decks are playing. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 80, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); ControlObject::getControl(ConfigKey(m_sGroup1, "play"))->set(1.0); mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 80, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); ProcessBuffer(); @@ -306,13 +306,13 @@ TEST_F(EngineSyncTest, DisableInternalMasterWhilePlaying) { TEST_F(EngineSyncTest, DisableSyncOnMaster) { // Channel 1 follower, channel 2 master. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 130, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); auto pButtonSyncMode1 = std::make_unique<ControlProxy>(m_sGroup1, "sync_mode"); pButtonSyncMode1->slotSet(SYNC_FOLLOWER); mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 130, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); auto pButtonSyncMaster2 = std::make_unique<ControlProxy>(m_sGroup2, "sync_master"); pButtonSyncMaster2->slotSet(1.0); @@ -341,7 +341,7 @@ TEST_F(EngineSyncTest, InternalMasterSetFollowerSliderMoves) { // Set the file bpm of channel 1 to 80 bpm. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 80, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); auto pButtonMasterSync1 = std::make_unique<ControlProxy>(m_sGroup1, "sync_mode"); @@ -359,7 +359,7 @@ TEST_F(EngineSyncTest, AnySyncDeckSliderStays) { // master BPM if a new deck enables sync. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 80, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); auto pButtonSyncEnabled1 = std::make_unique<ControlProxy>(m_sGroup1, "sync_enabled"); pButtonSyncEnabled1->set(1.0); @@ -370,7 +370,7 @@ TEST_F(EngineSyncTest, AnySyncDeckSliderStays) { ->get()); mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 100, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); auto pButtonSyncEnabled2 = std::make_unique<ControlProxy>(m_sGroup2, "sync_enabled"); pButtonSyncEnabled2->set(1.0); @@ -394,11 +394,11 @@ TEST_F(EngineSyncTest, InternalClockFollowsFirstPlayingDeck) { // Set up decks so they can be playing, and start deck 1. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 100, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); ControlObject::set(ConfigKey(m_sGroup1, "rate"), getRateSliderValue(1.0)); ControlObject::set(ConfigKey(m_sGroup1, "play"), 1.0); mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 130, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); ControlObject::set(ConfigKey(m_sGroup2, "rate"), getRateSliderValue(1.0)); ControlObject::set(ConfigKey(m_sGroup2, "play"), 0.0); ProcessBuffer(); @@ -464,10 +464,10 @@ TEST_F(EngineSyncTest, SetExplicitMasterByLights) { // Set the file bpm of channel 1 to 160bpm. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 160, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); // Set the file bpm of channel 2 to 150bpm. mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 150, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); // Set channel 1 to be explicit master. pButtonSyncMaster1->slotSet(1.0); @@ -539,7 +539,7 @@ TEST_F(EngineSyncTest, RateChangeTest) { // Set the file bpm of channel 1 to 160bpm. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 160, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); EXPECT_DOUBLE_EQ( 160.0, ControlObject::get(ConfigKey(m_sGroup1, "file_bpm"))); ProcessBuffer(); @@ -558,7 +558,7 @@ TEST_F(EngineSyncTest, RateChangeTest) { // Set the file bpm of channel 2 to 120bpm. mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 120, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); EXPECT_DOUBLE_EQ( 120.0, ControlObject::get(ConfigKey(m_sGroup2, "file_bpm"))); @@ -580,13 +580,13 @@ TEST_F(EngineSyncTest, RateChangeTestWeirdOrder) { // Set the file bpm of channel 1 to 160bpm. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 160, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); EXPECT_DOUBLE_EQ( 160.0, ControlObject::get(ConfigKey(m_sInternalClockGroup, "bpm"))); // Set the file bpm of channel 2 to 120bpm. mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 120, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); // Set the rate slider of channel 1 to 1.2. ControlObject::set(ConfigKey(m_sGroup1, "rate"), getRateSliderValue(1.2)); @@ -604,13 +604,13 @@ TEST_F(EngineSyncTest, RateChangeTestWeirdOrder) { TEST_F(EngineSyncTest, RateChangeTestOrder3) { // Set the file bpm of channel 1 to 160bpm. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 160, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); EXPECT_DOUBLE_EQ( 160.0, ControlObject::get(ConfigKey(m_sGroup1, "file_bpm"))); // Set the file bpm of channel 2 to 120bpm. mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 120, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); EXPECT_DOUBLE_EQ( 120.0, ControlObject::get(ConfigKey(m_sGroup2, "file_bpm"))); @@ -648,11 +648,11 @@ TEST_F(EngineSyncTest, FollowerRateChange) { // Set the file bpm of channel 1 to 160bpm. mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 160, 0.0); - m_pTrack1->setBeats(pBeats1); + m_pTrack1->trySetBeats(pBeats1); // Set the file bpm of channel 2 to 120bpm. mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 120, 0.0); - m_pTrack2->setBeats(pBeats2); + m_pTrack2->trySetBeats(pBeats2); // Set the rate slider of channel 1 to 1.2. ControlObject::set(ConfigKey(m_sGroup1, "rate"), getRateSliderValue(1.2)); @@ -694,13 +694,13 @@ TEST_F(EngineSyncTest, InternalRateChangeTest) { |