TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeDisabled) { m_pQuantizeEnabled->set(0); TrackPointer pTrack = createTestTrack(); pTrack->setSampleRate(44100); pTrack->setBpm(120.0); pTrack->setCuePoint(CuePosition(240.0, Cue::AUTOMATIC)); auto pIntro = pTrack->createAndAddCue(); pIntro->setType(Cue::INTRO); pIntro->setSource(Cue::AUTOMATIC); pIntro->setPosition(210.0); pIntro->setLength(120.0); auto pOutro = pTrack->createAndAddCue(); pOutro->setType(Cue::OUTRO); pOutro->setSource(Cue::AUTOMATIC); pOutro->setPosition(770.0); pOutro->setLength(220.0); loadTrack(pTrack); EXPECT_DOUBLE_EQ(240.0, m_pCuePoint->get()); EXPECT_DOUBLE_EQ(210.0, m_pIntroStartPosition->get()); EXPECT_DOUBLE_EQ(330.0, m_pIntroEndPosition->get()); EXPECT_DOUBLE_EQ(770.0, m_pOutroStartPosition->get()); EXPECT_DOUBLE_EQ(990.0, m_pOutroEndPosition->get()); }
TrackPointer BaseExternalTrackModel::getTrack(const QModelIndex& index) const { QString artist = index.sibling(index.row(), fieldIndex("artist")).data().toString(); QString title = index.sibling(index.row(), fieldIndex("title")).data().toString(); QString album = index.sibling(index.row(), fieldIndex("album")).data().toString(); QString year = index.sibling(index.row(), fieldIndex("year")).data().toString(); QString genre = index.sibling(index.row(), fieldIndex("genre")).data().toString(); float bpm = index.sibling(index.row(), fieldIndex("bpm")).data().toString().toFloat(); QString location = index.sibling(index.row(), fieldIndex("location")).data().toString(); if (location.isEmpty()) { // Track is lost return TrackPointer(); } bool track_already_in_library = false; TrackPointer pTrack = m_pTrackCollection->getTrackDAO() .getOrAddTrack(location, true, &track_already_in_library); // If this track was not in the Mixxx library it is now added and will be // saved with the metadata from iTunes. If it was already in the library // then we do not touch it so that we do not over-write the user's metadata. if (pTrack && !track_already_in_library) { pTrack->setArtist(artist); pTrack->setTitle(title); pTrack->setAlbum(album); pTrack->setYear(year); pTrack->setGenre(genre); pTrack->setBpm(bpm); } return pTrack; }
TEST_F(CueControlTest, LoadAutodetectedCues_QuantizeEnabled) { m_pQuantizeEnabled->set(1); TrackPointer pTrack = createTestTrack(); pTrack->setSampleRate(44100); pTrack->setBpm(120.0); const int frameSize = 2; const int sampleRate = pTrack->getSampleRate(); const double bpm = pTrack->getBpm(); const double beatLength = (60.0 * sampleRate / bpm) * frameSize; pTrack->setCuePoint(CuePosition(1.9 * beatLength, Cue::AUTOMATIC)); auto pIntro = pTrack->createAndAddCue(); pIntro->setType(Cue::INTRO); pIntro->setSource(Cue::AUTOMATIC); pIntro->setPosition(2.1 * beatLength); pIntro->setLength(1.2 * beatLength); auto pOutro = pTrack->createAndAddCue(); pOutro->setType(Cue::OUTRO); pOutro->setSource(Cue::AUTOMATIC); pOutro->setPosition(11.1 * beatLength); pOutro->setLength(4.4 * beatLength); loadTrack(pTrack); EXPECT_DOUBLE_EQ(2.0 * beatLength, m_pCuePoint->get()); EXPECT_DOUBLE_EQ(2.0 * beatLength, m_pIntroStartPosition->get()); EXPECT_DOUBLE_EQ(4.0 * beatLength, m_pIntroEndPosition->get()); EXPECT_DOUBLE_EQ(11.0 * beatLength, m_pOutroStartPosition->get()); EXPECT_DOUBLE_EQ(16.0 * beatLength, m_pOutroEndPosition->get()); }
TrackPointer BaseExternalPlaylistModel::getTrack(const QModelIndex& index) const { QString location = index.sibling( index.row(), fieldIndex("location")).data().toString(); if (location.isEmpty()) { // Track is lost return TrackPointer(); } TrackDAO& track_dao = m_pTrackCollection->getTrackDAO(); int track_id = track_dao.getTrackId(location); bool track_already_in_library = track_id >= 0; if (track_id < 0) { // Add Track to library track_id = track_dao.addTrack(location, true); } TrackPointer pTrack; if (track_id < 0) { // Add Track to library failed, create a transient TrackInfoObject pTrack = TrackPointer(new TrackInfoObject(location), &QObject::deleteLater); } else { pTrack = track_dao.getTrack(track_id); } // If this track was not in the Mixxx library it is now added and will be // saved with the metadata from iTunes. If it was already in the library // then we do not touch it so that we do not over-write the user's metadata. if (!track_already_in_library) { QString artist = index.sibling( index.row(), fieldIndex("artist")).data().toString(); pTrack->setArtist(artist); QString title = index.sibling( index.row(), fieldIndex("title")).data().toString(); pTrack->setTitle(title); QString album = index.sibling( index.row(), fieldIndex("album")).data().toString(); pTrack->setAlbum(album); QString year = index.sibling( index.row(), fieldIndex("year")).data().toString(); pTrack->setYear(year); 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); } return pTrack; }