diff options
author | Nino Miškić-Pletenac <nino.mip@gmail.com> | 2019-03-27 02:50:00 +0100 |
---|---|---|
committer | Nino Miškić-Pletenac <nino.mip@gmail.com> | 2019-03-27 02:50:00 +0100 |
commit | 65dc18eee31c8fea7c40cd5afcda91325003012b (patch) | |
tree | a60dc41d762a6ecdb6d0ee3cb76b9baca1169b43 /src | |
parent | 7a7e3e51d114929da5a189f39e2fc9e96960e6e5 (diff) |
CueControl: Fix computation of end position for intro/outro cues
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/controls/cuecontrol.cpp | 36 | ||||
-rw-r--r-- | src/track/cue.cpp | 11 | ||||
-rw-r--r-- | src/track/cue.h | 2 |
3 files changed, 25 insertions, 24 deletions
diff --git a/src/engine/controls/cuecontrol.cpp b/src/engine/controls/cuecontrol.cpp index 2f0b969927..7f43f1da6f 100644 --- a/src/engine/controls/cuecontrol.cpp +++ b/src/engine/controls/cuecontrol.cpp @@ -435,20 +435,14 @@ void CueControl::loadCuesFromTrack() { } if (pIntroCue) { - double position = pIntroCue->getPosition(); - double length = pIntroCue->getLength(); + double startPosition = pIntroCue->getPosition(); + double endPosition = pIntroCue->getEndPosition(); Cue::CueSource source = pIntroCue->getSource(); - m_pIntroStartPosition->set(quantizeCuePoint(position, source, QuantizeMode::PreviousBeat)); - m_pIntroStartEnabled->forceSet(position == -1.0 ? 0.0 : 1.0); - - if (length > 0.0) { - m_pIntroEndPosition->set(quantizeCuePoint(position + length, source, QuantizeMode::NextBeat)); - m_pIntroEndEnabled->forceSet(1.0); - } else { - m_pIntroEndPosition->set(-1.0); - m_pIntroEndEnabled->forceSet(0.0); - } + m_pIntroStartPosition->set(quantizeCuePoint(startPosition, source, QuantizeMode::PreviousBeat)); + m_pIntroStartEnabled->forceSet(startPosition == -1.0 ? 0.0 : 1.0); + m_pIntroEndPosition->set(quantizeCuePoint(endPosition, source, QuantizeMode::NextBeat)); + m_pIntroEndEnabled->forceSet(endPosition == -1.0 ? 0.0 : 1.0); } else { m_pIntroStartPosition->set(-1.0); m_pIntroStartEnabled->forceSet(0.0); @@ -457,20 +451,14 @@ void CueControl::loadCuesFromTrack() { } if (pOutroCue) { - double position = pOutroCue->getPosition(); - double length = pOutroCue->getLength(); + double startPosition = pOutroCue->getPosition(); + double endPosition = pOutroCue->getEndPosition(); Cue::CueSource source = pOutroCue->getSource(); - m_pOutroStartPosition->set(quantizeCuePoint(position, source, QuantizeMode::PreviousBeat)); - m_pOutroStartEnabled->forceSet(position == -1.0 ? 0.0 : 1.0); - - if (length > 0.0) { - m_pOutroEndPosition->set(quantizeCuePoint(position + length, source, QuantizeMode::NextBeat)); - m_pOutroEndEnabled->forceSet(1.0); - } else { - m_pOutroEndPosition->set(-1.0); - m_pOutroEndEnabled->forceSet(0.0); - } + m_pOutroStartPosition->set(quantizeCuePoint(startPosition, source, QuantizeMode::PreviousBeat)); + m_pOutroStartEnabled->forceSet(startPosition == -1.0 ? 0.0 : 1.0); + m_pOutroEndPosition->set(quantizeCuePoint(endPosition, source, QuantizeMode::NextBeat)); + m_pOutroEndEnabled->forceSet(endPosition == -1.0 ? 0.0 : 1.0); } else { m_pOutroStartPosition->set(-1.0); m_pOutroStartEnabled->forceSet(0.0); diff --git a/src/track/cue.cpp b/src/track/cue.cpp index 347458ae06..0376b80854 100644 --- a/src/track/cue.cpp +++ b/src/track/cue.cpp @@ -176,6 +176,17 @@ void Cue::setDirty(bool dirty) { m_bDirty = dirty; } +double Cue::getEndPosition() const { + QMutexLocker lock(&m_mutex); + if (m_samplePosition == -1.0) { + return m_length; + } else if (m_length == 0.0) { + return -1.0; + } else { + return m_samplePosition + m_length; + } +} + bool operator==(const CuePosition& lhs, const CuePosition& rhs) { return lhs.getPosition() == rhs.getPosition() && lhs.getSource() == rhs.getSource(); diff --git a/src/track/cue.h b/src/track/cue.h index f6138b78b2..1e0e7abc02 100644 --- a/src/track/cue.h +++ b/src/track/cue.h @@ -64,6 +64,8 @@ class Cue : public QObject { CuePosition getCuePosition() const; void setCuePosition(CuePosition position); + double getEndPosition() const; + signals: void updated(); |