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()); }
void BeatMap::initialize(TrackPointer pTrack, int iSampleRate) { m_iSampleRate = iSampleRate > 0 ? iSampleRate : pTrack->getSampleRate(); m_dCachedBpm = 0; m_dLastFrame = 0; if (!pTrack.isNull()) { // BeatMap should live in the same thread as the track it is associated // with. moveToThread(pTrack->thread()); } }
void BeatMap::initialize(TrackPointer pTrack, int iSampleRate) { m_iSampleRate = iSampleRate > 0 ? iSampleRate : pTrack->getSampleRate(); m_dCachedBpm = 0; m_dLastFrame = 0; }
void DlgTrackInfo::populateCues(TrackPointer pTrack) { int sampleRate = pTrack->getSampleRate(); QList<Cue*> listPoints; const QList<Cue*>& cuePoints = pTrack->getCuePoints(); QListIterator<Cue*> it(cuePoints); while (it.hasNext()) { Cue* pCue = it.next(); if (pCue->getType() == Cue::CUE || pCue->getType() == Cue::LOAD) { listPoints.push_back(pCue); } } it = QListIterator<Cue*>(listPoints); cueTable->setSortingEnabled(false); int row = 0; while (it.hasNext()) { Cue* pCue = it.next(); QString rowStr = QString("%1").arg(row); // All hotcues are stored in Cue's as 0-indexed, but the GUI presents // them to the user as 1-indexex. Add 1 here. rryan 9/2010 int iHotcue = pCue->getHotCue() + 1; QString hotcue = ""; if (iHotcue != -1) { hotcue = QString("%1").arg(iHotcue); } int position = pCue->getPosition(); double totalSeconds; if (position == -1) continue; else { totalSeconds = float(position) / float(sampleRate) / 2.0; } int fraction = 100*(totalSeconds - floor(totalSeconds)); int seconds = int(totalSeconds) % 60; int mins = int(totalSeconds) / 60; //int hours = mins / 60; //Not going to worry about this for now. :) //Construct a nicely formatted duration string now. QString duration = QString("%1:%2.%3").arg( QString::number(mins), QString("%1").arg(seconds, 2, 10, QChar('0')), QString("%1").arg(fraction, 2, 10, QChar('0'))); QTableWidgetItem* durationItem = new QTableWidgetItem(duration); // Make the duration read only durationItem->setFlags(Qt::NoItemFlags); m_cueMap[row] = pCue; cueTable->insertRow(row); cueTable->setItem(row, 0, new QTableWidgetItem(rowStr)); cueTable->setItem(row, 1, durationItem); cueTable->setItem(row, 2, new QTableWidgetItem(hotcue)); cueTable->setItem(row, 3, new QTableWidgetItem(pCue->getLabel())); row += 1; } cueTable->setSortingEnabled(true); }