summaryrefslogtreecommitdiffstats
path: root/src/engine/controls/loopingcontrol.cpp
diff options
context:
space:
mode:
authorPhilip Gottschling <gottschlingp@gmail.com>2019-09-27 16:44:42 +0200
committerPhilip Gottschling <gottschlingp@gmail.com>2019-09-27 21:21:19 +0200
commita6d7a15974787c3d4100362b50c23318413b8d14 (patch)
tree2d49a19ac01332d4c26cf9497f38d34ac07deeaf /src/engine/controls/loopingcontrol.cpp
parent3bef0dffbcff75348e954ebe853f582da302728e (diff)
fixed failing test
Diffstat (limited to 'src/engine/controls/loopingcontrol.cpp')
-rw-r--r--src/engine/controls/loopingcontrol.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/engine/controls/loopingcontrol.cpp b/src/engine/controls/loopingcontrol.cpp
index f050ed9435..245201df76 100644
--- a/src/engine/controls/loopingcontrol.cpp
+++ b/src/engine/controls/loopingcontrol.cpp
@@ -53,7 +53,7 @@ LoopingControl::LoopingControl(QString group,
m_loopSamples.setValue(m_oldLoopSamples);
m_currentSample.setValue(0.0);
m_pActiveBeatLoop = NULL;
-
+ m_pRateControl = NULL;
//Create loop-in, loop-out, loop-exit, and reloop/exit ControlObjects
m_pLoopInButton = new ControlPushButton(ConfigKey(group, "loop_in"));
connect(m_pLoopInButton, &ControlObject::valueChanged,
@@ -119,7 +119,6 @@ LoopingControl::LoopingControl(QString group,
m_pClosestBeat = ControlObject::getControl(ConfigKey(group, "beat_closest"));
m_pTrackSamples = ControlObject::getControl(ConfigKey(group, "track_samples"));
m_pSlipEnabled = ControlObject::getControl(ConfigKey(group, "slip_enabled"));
- m_pCOReverse = ControlObject::getControl(group, "reverse");
// DEPRECATED: Use beatloop_size and beatloop_set instead.
// Activates a beatloop of a specified number of beats.
@@ -683,6 +682,10 @@ void LoopingControl::setLoopOutToCurrentPosition() {
m_loopSamples.setValue(loopSamples);
}
+void LoopingControl::setRateControl(RateControl* rateControl) {
+ m_pRateControl = rateControl;
+}
+
void LoopingControl::slotLoopOut(double pressed) {
if (m_pTrack == nullptr) {
return;
@@ -1086,7 +1089,7 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable
// find the previous beat fraction and check if the current position is closer to this or the next one
// place the new loop start to the closer one
- double previousFractionBeat = prevBeat + floor(samplesSinceLastBeat / beatLength) * beatLength;
+ double previousFractionBeat = prevBeat + floor(samplesSinceLastBeat / loopLength) * loopLength;
double samplesSinceLastFractionBeat = currentSample - previousFractionBeat;
if (samplesSinceLastFractionBeat <= (loopLength / 2.0)) {
@@ -1095,9 +1098,13 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable
newloopSamples.start = previousFractionBeat + loopLength;
}
}
+
// If running reverse, move the loop one loop size to the left.
// Thus, the loops end will be closest to the current position
- bool reverse = m_pCOReverse->toBool();
+ bool reverse = false;
+ if (m_pRateControl != NULL) {
+ reverse = m_pRateControl->isReverseButtonPressed();
+ }
if (reverse) {
newloopSamples.start -= loopLength;
}