Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/engine/bpmcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const int kLocalBpmSpan = 4;
BpmControl::BpmControl(QString group,
UserSettingsPointer pConfig) :
EngineControl(group, pConfig),
m_dPreviousSample(0),
m_dSyncTargetBeatDistance(0.0),
m_dSyncInstantaneousBpm(0.0),
m_dLastSyncAdjustment(1.0),
Expand Down Expand Up @@ -785,11 +784,6 @@ void BpmControl::slotBeatsTranslateMatchAlignment(double v) {
}
}

void BpmControl::setCurrentSample(const double dCurrentSample, const double dTotalSamples) {
m_dPreviousSample = dCurrentSample;
EngineControl::setCurrentSample(dCurrentSample, dTotalSamples);
}

double BpmControl::updateLocalBpm() {
double prev_local_bpm = m_pLocalBpm->get();
double local_bpm = 0;
Expand All @@ -810,7 +804,7 @@ double BpmControl::updateLocalBpm() {
}

double BpmControl::updateBeatDistance() {
double beat_distance = getBeatDistance(m_dPreviousSample);
double beat_distance = getBeatDistance(getCurrentSample());
m_pThisBeatDistance->set(beat_distance);
if (getSyncMode() == SYNC_NONE) {
m_dUserOffset = 0.0;
Expand Down
4 changes: 0 additions & 4 deletions src/engine/bpmcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class BpmControl : public EngineControl {
double getNearestPositionInPhase(double dThisPosition, bool respectLoops, bool playing);
double getPhaseOffset(double dThisPosition);
double getBeatDistance(double dThisPosition) const;
double getPreviousSample() const { return m_dPreviousSample; }

void setCurrentSample(const double dCurrentSample, const double dTotalSamples) override;
void setTargetBeatDistance(double beatDistance);
void setInstantaneousBpm(double instantaneousBpm);
void resetSyncAdjustment();
Expand Down Expand Up @@ -148,8 +146,6 @@ class BpmControl : public EngineControl {
// Button that translates beats to match another playing deck
ControlPushButton* m_pBeatsTranslateMatchAlignment;

double m_dPreviousSample;

// Master Sync objects and values.
ControlObject* m_pSyncMode;
ControlProxy* m_pThisBeatDistance;
Expand Down
11 changes: 5 additions & 6 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ void EngineBuffer::readToCrossfadeBuffer(const int iBufferSize) {

// WARNING: This method is not thread safe and must not be called from outside
// the engine callback!
void EngineBuffer::setNewPlaypos(double newpos) {
void EngineBuffer::setNewPlaypos(double newpos, bool adjustingPhase) {
//qDebug() << m_group << "engine new pos " << newpos;

m_filepos_play = newpos;
Expand All @@ -464,7 +464,7 @@ void EngineBuffer::setNewPlaypos(double newpos) {
for (QList<EngineControl*>::iterator it = m_engineControls.begin();
it != m_engineControls.end(); ++it) {
EngineControl *pControl = *it;
pControl->notifySeek(m_filepos_play);
pControl->notifySeek(m_filepos_play, adjustingPhase);
}

verifyPlay(); // verify or update play button and indicator
Expand Down Expand Up @@ -1157,12 +1157,14 @@ void EngineBuffer::processSeek(bool paused) {
seekType |= SEEK_PHASE;
}

bool adjustingPhase = false;
switch (seekType) {
case SEEK_NONE:
return;
case SEEK_PHASE:
// only adjust phase
position = m_filepos_play;
adjustingPhase = true;
break;
case SEEK_EXACT:
case SEEK_STANDARD: // = SEEK_EXACT | SEEK_PHASE
Expand All @@ -1176,11 +1178,8 @@ void EngineBuffer::processSeek(bool paused) {
if ((seekType & SEEK_PHASE) && !paused && m_pQuantize->toBool()) {
position = m_pBpmControl->getNearestPositionInPhase(position, true, true);
}

double newPlayFrame = position / kSamplesPerFrame;
position = round(newPlayFrame) * kSamplesPerFrame;
if (position != m_filepos_play) {
setNewPlaypos(position);
setNewPlaypos(position, adjustingPhase);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/engine/enginebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class EngineBuffer : public EngineObject {
void readToCrossfadeBuffer(const int iBufferSize);

// Reset buffer playpos and set file playpos.
void setNewPlaypos(double playpos);
void setNewPlaypos(double playpos, bool adjustingPhase);

void processSyncRequests();
void processSeek(bool paused);
Expand Down
3 changes: 2 additions & 1 deletion src/engine/enginecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ void EngineControl::seek(double sample) {
}
}

void EngineControl::notifySeek(double dNewPlaypos) {
void EngineControl::notifySeek(double dNewPlaypos, bool adjustingPhase) {
Q_UNUSED(dNewPlaypos);
Q_UNUSED(adjustingPhase);
}

EngineBuffer* EngineControl::pickSyncTarget() {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/enginecontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class EngineControl : public QObject {
}

// Called whenever a seek occurs to allow the EngineControl to respond.
virtual void notifySeek(double dNewPlaypo);
virtual void notifySeek(double dNewPlaypo, bool adjustingPhase);

public slots:
virtual void trackLoaded(TrackPointer pNewTrack, TrackPointer pOldTrack);
Expand Down
37 changes: 21 additions & 16 deletions src/engine/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,26 @@ double LoopingControl::nextTrigger(bool reverse,
// should be moved with it
*pTarget = seekInsideAdjustedLoop(currentSample,
m_oldLoopSamples.start, loopSamples.start, loopSamples.end);
} else {
bool movedOut = false;
// Check if we have moved out of the loop, before we could enable it
if (reverse) {
if (loopSamples.start > currentSample) {
movedOut = true;
}
} else {
if (loopSamples.end < currentSample) {
movedOut = true;
}
}
if (movedOut) {
*pTarget = seekInsideAdjustedLoop(currentSample,
loopSamples.start, loopSamples.start, loopSamples.end);
}
}
m_oldLoopSamples = loopSamples;
if (*pTarget != kNoTrigger) {
// jump immediately
qDebug() << currentSample <<
m_oldLoopSamples.start << loopSamples.start << loopSamples.end;
return currentSample;
}
}
Expand Down Expand Up @@ -752,12 +766,13 @@ void LoopingControl::slotLoopEndPos(double pos) {
}

// This is called from the engine thread
void LoopingControl::notifySeek(double dNewPlaypos) {
void LoopingControl::notifySeek(double dNewPlaypos, bool adjustingPhase) {
LoopSamples loopSamples = m_loopSamples.getValue();
double currentSample = m_currentSample.getValue();
if (m_bLoopingEnabled) {
if (m_bLoopingEnabled && !adjustingPhase) {
// Disable loop when we jumping out, or over a catching loop,
// using hot cues or waveform overview.
// Do not jump out of a loop if we adjust a phase (lp1743010)
if (currentSample >= loopSamples.start &&
currentSample <= loopSamples.end &&
dNewPlaypos < loopSamples.start) {
Expand Down Expand Up @@ -965,17 +980,8 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable
}

newloopSamples.end = m_pBeats->findNBeatsFromSample(newloopSamples.start, beats);

if (newloopSamples.start == newloopSamples.end) {
if ((newloopSamples.end + 2) > samples) {
newloopSamples.start -= 2;
} else {
newloopSamples.end += 2;
}
}

// Do not allow beat loops to go beyond the end of the track
if (newloopSamples.end > samples) {
if (newloopSamples.start >= newloopSamples.end // happens when the call above fails
|| newloopSamples.end > samples) { // Do not allow beat loops to go beyond the end of the track
// If a track is loaded with beatloop_size larger than
// the distance between the loop in point and
// the end of the track, let beatloop_size be set to
Expand Down Expand Up @@ -1127,7 +1133,6 @@ void LoopingControl::slotLoopMove(double beats) {
int LoopingControl::seekInsideAdjustedLoop(
double currentSample, double old_loop_in,
double new_loop_in, double new_loop_out) {
// Copy on stack since m_iCurrentSample sample can change under us.
if (currentSample >= new_loop_in && currentSample <= new_loop_out) {
// playposition already is inside the loop
return kNoTrigger;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/loopingcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LoopingControl : public EngineControl {
// sample, if set.
void hintReader(HintVector* pHintList) override;

void notifySeek(double dNewPlaypos) override;
void notifySeek(double dNewPlaypos, bool adjustingPhase) override;

public slots:
void slotLoopIn(double pressed);
Expand Down
3 changes: 2 additions & 1 deletion src/engine/ratecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ void RateControl::resetRateTemp(void)
setRateTemp(0.0);
}

void RateControl::notifySeek(double playPos) {
void RateControl::notifySeek(double playPos, bool adjustingPhase) {
Q_UNUSED(adjustingPhase);
m_pScratchController->notifySeek(playPos);
}
2 changes: 1 addition & 1 deletion src/engine/ratecontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class RateControl : public EngineControl {
// Set Rate Ramp Sensitivity
static void setRateRampSensitivity(int);
static int getRateRampSensitivity();
void notifySeek(double dNewPlaypos) override;
void notifySeek(double dNewPlaypos, bool adjustingPhase) override;

public slots:
void slotReverseRollActivate(double);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/readaheadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ double ReadAheadManager::getFilePlaypositionFromLog(
// (Not looping control)
if (shouldNotifySeek) {
if (m_pRateControl) {
m_pRateControl->notifySeek(entry.virtualPlaypositionStart);
m_pRateControl->notifySeek(entry.virtualPlaypositionStart, false);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/readaheadmanager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ class StubLoopControl : public LoopingControl {
Q_UNUSED(pHintList);
}

void notifySeek(double dNewPlaypos) override {
void notifySeek(double dNewPlaypos, bool adjustingPhase) override {
Q_UNUSED(dNewPlaypos);
Q_UNUSED(adjustingPhase);
}

public slots:
Expand Down