Skip to content

Commit

Permalink
Merge pull request #2523 from Holzhaus/cueinfo
Browse files Browse the repository at this point in the history
Add CueInfo DTO
  • Loading branch information
uklotzde authored Mar 2, 2020
2 parents 99bfeef + 09d2383 commit 18a134f
Show file tree
Hide file tree
Showing 21 changed files with 359 additions and 156 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/track/beatutils.cpp
src/track/bpm.cpp
src/track/cue.cpp
src/track/cueinfo.cpp
src/track/globaltrackcache.cpp
src/track/keyfactory.cpp
src/track/keys.cpp
Expand Down
1 change: 1 addition & 0 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ def sources(self, build):
"src/track/beats.cpp",
"src/track/bpm.cpp",
"src/track/cue.cpp",
"src/track/cueinfo.cpp",
"src/track/keyfactory.cpp",
"src/track/keys.cpp",
"src/track/keyutils.cpp",
Expand Down
18 changes: 9 additions & 9 deletions src/analyzer/analyzersilence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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);
}
Expand Down
42 changes: 21 additions & 21 deletions src/engine/controls/cuecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,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;
}
Expand All @@ -366,7 +366,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());
Expand All @@ -380,7 +380,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());

Expand All @@ -390,7 +390,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();
Expand Down Expand Up @@ -447,16 +447,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);

Expand Down Expand Up @@ -593,7 +593,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);
// TODO(XXX) deal with spurious signals
attachCue(pCue, pControl);

Expand Down Expand Up @@ -1158,10 +1158,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);
Expand All @@ -1179,7 +1179,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);
Expand Down Expand Up @@ -1234,10 +1234,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);
Expand All @@ -1255,7 +1255,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);
Expand Down Expand Up @@ -1310,10 +1310,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);
Expand All @@ -1331,7 +1331,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);
Expand Down Expand Up @@ -1386,10 +1386,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);
Expand All @@ -1407,7 +1407,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);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/controls/vinylcontrolcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/library/dao/cuedao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,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::Type)type, position, length, hotcue, label, color));
CuePointer pCue(new Cue(id, trackId, (mixxx::CueType)type, position, length, hotcue, label, color));
m_cues[id] = pCue;
return pCue;
}
Expand Down
59 changes: 29 additions & 30 deletions src/library/dlgtrackinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,8 @@ void DlgTrackInfo::populateCues(TrackPointer pTrack) {
QListIterator<CuePointer> it(cuePoints);
while (it.hasNext()) {
CuePointer pCue = it.next();
Cue::Type type = pCue->getType();
if (type == Cue::Type::HotCue || type == Cue::Type::MainCue || type == Cue::Type::Intro
|| type == Cue::Type::Outro) {
mixxx::CueType type = pCue->getType();
if (type == mixxx::CueType::HotCue || type == mixxx::CueType::MainCue || type == mixxx::CueType::Intro || type == mixxx::CueType::Outro) {
listPoints.push_back(pCue);
}
}
Expand Down Expand Up @@ -376,32 +375,32 @@ void DlgTrackInfo::populateCues(TrackPointer pTrack) {
// Decode cue type to display text
QString cueType;
switch (pCue->getType()) {
case Cue::Type::Invalid:
cueType = "?";
break;
case Cue::Type::HotCue:
cueType = "Hotcue";
break;
case Cue::Type::MainCue:
cueType = "Main Cue";
break;
case Cue::Type::Beat:
cueType = "Beat";
break;
case Cue::Type::Loop:
cueType = "Loop";
break;
case Cue::Type::Jump:
cueType = "Jump";
break;
case Cue::Type::Intro:
cueType = "Intro";
break;
case Cue::Type::Outro:
cueType = "Outro";
break;
default:
break;
case mixxx::CueType::Invalid:
cueType = "?";
break;
case mixxx::CueType::HotCue:
cueType = "Hotcue";
break;
case mixxx::CueType::MainCue:
cueType = "Main Cue";
break;
case mixxx::CueType::Beat:
cueType = "Beat";
break;
case mixxx::CueType::Loop:
cueType = "Loop";
break;
case mixxx::CueType::Jump:
cueType = "Jump";
break;
case mixxx::CueType::Intro:
cueType = "Intro";
break;
case mixxx::CueType::Outro:
cueType = "Outro";
break;
default:
break;
}

QTableWidgetItem* typeItem = new QTableWidgetItem(cueType);
Expand Down Expand Up @@ -504,7 +503,7 @@ void DlgTrackInfo::saveTrack() {
pCue->setHotCue(-1);
}

if (pCue->getType() == Cue::Type::HotCue) {
if (pCue->getType() == mixxx::CueType::HotCue) {
auto colorComboBox = qobject_cast<QComboBox*>(colorWidget);
if (colorComboBox) {
PredefinedColorPointer color = Color::kPredefinedColorsSet.allColors.at(colorComboBox->currentIndex());
Expand Down
6 changes: 3 additions & 3 deletions src/library/rekordbox/rekordboxfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 18a134f

Please sign in to comment.