Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for LoopIn/LoopOut visualisation in waveforms #12538

Merged
merged 2 commits into from Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/engine/controls/loopingcontrol.h
Expand Up @@ -78,6 +78,12 @@ class LoopingControl : public EngineControl {
bool isLoopingEnabled() {
return m_bLoopingEnabled;
}
bool isAdjustLoopInActive() {
return m_bAdjustingLoopIn;
}
bool isAdjustLoopOutActive() {
return m_bAdjustingLoopOut;
}
bool isLoopRollActive() {
return m_bLoopRollActive;
}
Expand Down
4 changes: 4 additions & 0 deletions src/engine/enginebuffer.cpp
Expand Up @@ -583,6 +583,8 @@ void EngineBuffer::ejectTrack() {
0.0,
SlipModeState::Disabled,
false,
false,
false,
0.0,
0.0,
0.0,
Expand Down Expand Up @@ -1438,6 +1440,8 @@ void EngineBuffer::updateIndicators(double speed, int iBufferSize) {
effectiveSlipRate,
m_slipModeState,
m_pLoopingControl->isLoopingEnabled(),
m_pLoopingControl->isAdjustLoopInActive(),
m_pLoopingControl->isAdjustLoopOutActive(),
fFractionalLoopStartPos,
fFractionalLoopEndPos,
tempoTrackSeconds,
Expand Down
12 changes: 10 additions & 2 deletions src/waveform/visualplayposition.cpp
Expand Up @@ -29,6 +29,8 @@ void VisualPlayPosition::set(
double slipRate,
SlipModeState m_slipModeState,
bool loopEnabled,
bool loopInAdjustActive,
bool loopOutAdjustActive,
double loopStartPosition,
double loopEndPosition,
double tempoTrackSeconds,
Expand All @@ -43,6 +45,8 @@ void VisualPlayPosition::set(
data.m_slipPos = slipPosition;
data.m_slipModeState = m_slipModeState;
data.m_loopEnabled = loopEnabled;
data.m_loopInAdjustActive = loopInAdjustActive;
data.m_loopOutAdjustActive = loopOutAdjustActive;
data.m_loopStartPos = loopStartPosition;
data.m_loopEndPos = loopEndPosition;
data.m_tempoTrackSeconds = tempoTrackSeconds;
Expand Down Expand Up @@ -104,25 +108,29 @@ double VisualPlayPosition::determinePlayPosInLoopBoundries(
if (loopSize > 0) {
if ((data.m_playRate < 0.0) &&
(interpolatedPlayPos < data.m_loopStartPos) &&
(data.m_playPos >= data.m_loopStartPos)) {
(data.m_playPos >= data.m_loopStartPos) &&
!data.m_loopInAdjustActive) {
// 1. Deck playing reverse
// 2. Interpolated playposition at the time of next VSync would
// be outsite of the active loop
// 3. Playposition is currently inside the active loop
// (not scratching left of an activated loop)
// 4. LoopIn is not being held down
interpolatedPlayPos = data.m_loopEndPos -
std::remainder(
data.m_loopStartPos - interpolatedPlayPos,
loopSize);
}
if ((data.m_playRate > 0.0) &&
(interpolatedPlayPos > data.m_loopEndPos) &&
(data.m_playPos <= data.m_loopEndPos)) {
(data.m_playPos <= data.m_loopEndPos) &&
!data.m_loopOutAdjustActive) {
// 1. Deck playing forward
// 2. Interpolated playposition at the time of next VSync would
// be outsite of the active loop
// 3. Playposition is currently inside the active loop
// (not scratching right of an activated loop)
// 4. LoopOut is not being held down
interpolatedPlayPos = data.m_loopStartPos +
std::remainder(
interpolatedPlayPos - data.m_loopEndPos,
Expand Down
4 changes: 4 additions & 0 deletions src/waveform/visualplayposition.h
Expand Up @@ -40,6 +40,8 @@ class VisualPlayPositionData {
double m_slipRate;
SlipModeState m_slipModeState;
bool m_loopEnabled;
bool m_loopInAdjustActive;
bool m_loopOutAdjustActive;
double m_loopStartPos;
double m_loopEndPos;
double m_tempoTrackSeconds; // total track time, taking the current tempo into account
Expand All @@ -62,6 +64,8 @@ class VisualPlayPosition : public QObject {
double slipRate,
SlipModeState slipModeState,
bool loopEnabled,
bool loopInAdjustActive,
bool loopOutAdjustActive,
double loopStartPos,
double loopEndPos,
double tempoTrackSeconds,
Expand Down