Skip to content

Commit

Permalink
Slip mode: consider loop for background position only if it was enabl…
Browse files Browse the repository at this point in the history
…ed before slip

this restores 2.3 behaviour (broken by c5127eb):
* enable slip mode (no active loop)
* active loop (NOT rolling loop since that would quit slip mode when disabling it)
* let it do a few interations so the slip position and the background position can be clearly distinguished
* disable loop
* quit slip mode
= position is where it would have been without slip mode
  • Loading branch information
ronso0 committed Aug 21, 2023
1 parent 2d18ffe commit a33d74d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
11 changes: 3 additions & 8 deletions src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ LoopingControl::LoopingControl(const QString& group,
: EngineControl(group, pConfig),
m_bLoopingEnabled(false),
m_bLoopRollActive(false),
m_bLoopWasEnabledBeforeSlipEnable(false),
m_bAdjustingLoopIn(false),
m_bAdjustingLoopOut(false),
m_bAdjustingLoopInOld(false),
Expand Down Expand Up @@ -1164,6 +1165,8 @@ void LoopingControl::notifySeek(mixxx::audio::FramePos newPosition) {
}

void LoopingControl::setLoopingEnabled(bool enabled) {
m_bLoopWasEnabledBeforeSlipEnable =
!m_pSlipEnabled->toBool() && enabled && !m_bLoopRollActive;
if (m_bLoopingEnabled == enabled) {
return;
}
Expand All @@ -1182,14 +1185,6 @@ void LoopingControl::setLoopingEnabled(bool enabled) {
emit loopEnabledChanged(enabled);
}

bool LoopingControl::isLoopingEnabled() {
return m_bLoopingEnabled;
}

bool LoopingControl::isLoopRollActive() {
return m_bLoopRollActive;
}

void LoopingControl::trackLoaded(TrackPointer pNewTrack) {
m_pTrack = pNewTrack;
mixxx::BeatsPointer pBeats;
Expand Down
13 changes: 11 additions & 2 deletions src/engine/controls/loopingcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ class LoopingControl : public EngineControl {
mixxx::audio::FramePos endPosition,
bool enabled);
void setRateControl(RateControl* rateControl);
bool isLoopingEnabled();
bool isLoopRollActive();

bool isLoopingEnabled() {
return m_bLoopingEnabled;
}
bool isLoopRollActive() {
return m_bLoopRollActive;
}
bool loopWasEnabledBeforeSlipEnable() {
return m_bLoopWasEnabledBeforeSlipEnable;
}

void trackLoaded(TrackPointer pNewTrack) override;
void trackBeatsUpdated(mixxx::BeatsPointer pBeats) override;
Expand Down Expand Up @@ -175,6 +183,7 @@ class LoopingControl : public EngineControl {

bool m_bLoopingEnabled;
bool m_bLoopRollActive;
bool m_bLoopWasEnabledBeforeSlipEnable;
bool m_bAdjustingLoopIn;
bool m_bAdjustingLoopOut;
bool m_bAdjustingLoopInOld;
Expand Down
1 change: 1 addition & 0 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,7 @@ void EngineBuffer::processSlip(int iBufferSize) {
static_cast<mixxx::audio::FrameDiff_t>(bufferFrameCount) * m_dSlipRate;
// Simulate looping if a regular loop is active
if (m_pLoopingControl->isLoopingEnabled() &&
m_pLoopingControl->loopWasEnabledBeforeSlipEnable() &&
!m_pLoopingControl->isLoopRollActive()) {
const mixxx::audio::FramePos newPos = m_slipPosition + slipDelta;
m_slipPosition = m_pLoopingControl->adjustedPositionForCurrentLoop(
Expand Down

0 comments on commit a33d74d

Please sign in to comment.