|
1 | 1 | #include "engine/positionscratchcontroller.h" |
2 | 2 |
|
| 3 | +#include "audio/frame.h" |
3 | 4 | #include "control/controlobject.h" |
4 | 5 | #include "control/controlproxy.h" |
5 | 6 | #include "engine/bufferscalers/enginebufferscale.h" // for MIN_SEEK_SPEED |
@@ -95,9 +96,7 @@ PositionScratchController::PositionScratchController(const QString& group) |
95 | 96 | m_isScratching(false), |
96 | 97 | m_inertiaEnabled(false), |
97 | 98 | m_prevSamplePos(0), |
98 | | - // TODO we might as well use FramePos in order to use more convenient |
99 | | - // mixxx::audio::kInvalidFramePos, then convert to sample pos on the fly |
100 | | - m_seekSamplePos(std::numeric_limits<double>::quiet_NaN()), |
| 99 | + m_seekFramePos(mixxx::audio::kInvalidFramePos), |
101 | 100 | m_samplePosDeltaSum(0), |
102 | 101 | m_scratchTargetDelta(0), |
103 | 102 | m_scratchStartPos(0), |
@@ -314,20 +313,19 @@ void PositionScratchController::process(double currentSamplePos, |
314 | 313 | // qDebug() << "scratchEnable()" << currentSamplePos; |
315 | 314 | } |
316 | 315 |
|
317 | | - if (!util_isnan(m_seekSamplePos)) { |
| 316 | + if (!m_seekFramePos.isValid()) { |
318 | 317 | // We need to transpose all buffers to compensate the seek |
319 | 318 | // in a way that the next process call does not even notice anything |
320 | | - currentSamplePos = m_seekSamplePos; |
321 | | - m_seekSamplePos = std::numeric_limits<double>::quiet_NaN(); |
| 319 | + currentSamplePos = m_seekFramePos.toEngineSamplePos(); |
| 320 | + m_seekFramePos = mixxx::audio::kInvalidFramePos; |
322 | 321 | } |
323 | 322 | m_prevSamplePos = currentSamplePos; |
324 | 323 | } |
325 | 324 |
|
326 | 325 | void PositionScratchController::notifySeek(mixxx::audio::FramePos position) { |
327 | | - const double newPos = position.toEngineSamplePos(); |
328 | 326 | // Scratching continues after seek due to calculating the relative |
329 | 327 | // distance traveled in m_samplePosDeltaSum |
330 | | - m_seekSamplePos = newPos; |
| 328 | + m_seekFramePos = position; |
331 | 329 | } |
332 | 330 |
|
333 | 331 | void PositionScratchController::reset() { |
|
0 commit comments