Skip to content

Commit

Permalink
remove useless tracking of automatic vs manually placed cues
Browse files Browse the repository at this point in the history
This was introduced in PR mixxxdj#1242 but is no longer used.
  • Loading branch information
Be-ing committed Aug 13, 2019
1 parent 620e5f6 commit 107c61d
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 231 deletions.
11 changes: 6 additions & 5 deletions res/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,12 @@ METADATA
</revision>
<revision version="29" min_compatible="3">
<description>
Add source to cue. Default is MANUAL.
<!-- See track/cue.h. -->
This was used in the development of 2.3 to track whether cues were placed
manually or automatically. However, this turned out to be unnecessary.
This version is left as a placeholder so users who were using the master
branch will have their database updated correctly for the subsequent
schema change.
</description>
<sql>
ALTER TABLE cues ADD COLUMN source INTEGER DEFAULT 2 NOT NULL;
</sql>
<sql/>
</revision>
</schema>
24 changes: 3 additions & 21 deletions src/analyzer/analyzersilence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down
25 changes: 8 additions & 17 deletions src/engine/controls/cuecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,21 +443,18 @@ 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);
}

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/engine/controls/cuecontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 2 additions & 6 deletions src/library/dao/cuedao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ 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();
int hotcue = record.value(record.indexOf("hotcue")).toInt();
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;
}
Expand Down Expand Up @@ -141,9 +140,8 @@ bool CueDAO::saveCue(Cue* cue) {
if (cue->getId() == -1) {
// New 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.prepare("INSERT INTO " CUE_TABLE " (track_id, type, position, length, hotcue, label, color) VALUES (:track_id, :type, :position, :length, :hotcue, :label, :color)");
query.bindValue(":track_id", cue->getTrackId().toVariant());
query.bindValue(":source", static_cast<int>(cue->getSource()));
query.bindValue(":type", static_cast<int>(cue->getType()));
query.bindValue(":position", cue->getPosition());
query.bindValue(":length", cue->getLength());
Expand All @@ -163,7 +161,6 @@ bool CueDAO::saveCue(Cue* cue) {
QSqlQuery query(m_database);
query.prepare("UPDATE " CUE_TABLE " SET "
"track_id = :track_id,"
"source = :source,"
"type = :type,"
"position = :position,"
"length = :length,"
Expand All @@ -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<int>(cue->getSource()));
query.bindValue(":type", static_cast<int>(cue->getType()));
query.bindValue(":position", cue->getPosition());
query.bindValue(":length", cue->getLength());
Expand Down
2 changes: 1 addition & 1 deletion src/library/dao/trackdao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 107c61d

Please sign in to comment.