summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorbe_ <be.0@gmx.com>2017-05-08 02:40:01 -0500
committerbe_ <be.0@gmx.com>2017-05-08 02:40:01 -0500
commit2c129ea0af838543b987d55538b903e115f08ba5 (patch)
tree6eda5c12e86dc96f7d0045e01ceed1f823fe1987 /src/engine
parent697695c413b91b6baeca7e96065e37d4727ab9b3 (diff)
measure beatloop_size when setting manual loops with quantize
Plus: * make loop_double/halve always update beatloop_size * remove beatloop_double/halve ControlPushButtons Now, beatloop_size can only be out of sync with the loop in two cases: * a new track is loaded with a loop of a different size * a manual loop is set using loop_in/out without quantize It is no longer possible to resize manual loops that are not quantized with loop_double/halve. As discussed on PR #1187, that is not very useful behavior. It is still possible to resize manual loops that are not quantized by setting loop_scale. That will not update beatloop_size.
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/enginebuffer.h2
-rw-r--r--src/engine/loopingcontrol.cpp55
-rw-r--r--src/engine/loopingcontrol.h4
3 files changed, 16 insertions, 45 deletions
diff --git a/src/engine/enginebuffer.h b/src/engine/enginebuffer.h
index 571e4f2810..fb65aa00f2 100644
--- a/src/engine/enginebuffer.h
+++ b/src/engine/enginebuffer.h
@@ -231,7 +231,7 @@ class EngineBuffer : public EngineObject {
UserSettingsPointer m_pConfig;
LoopingControl* m_pLoopingControl;
- FRIEND_TEST(LoopingControlTest, LoopHalveButton_HalvesLoop);
+ FRIEND_TEST(LoopingControlTest, LoopScale_HalvesLoop);
FRIEND_TEST(LoopingControlTest, LoopMoveTest);
FRIEND_TEST(LoopingControlTest, LoopResizeSeek);
FRIEND_TEST(LoopingControlTest, ReloopToggleButton_DoesNotJumpAhead);
diff --git a/src/engine/loopingcontrol.cpp b/src/engine/loopingcontrol.cpp
index 34fe8ca1e6..bcfdc81fec 100644
--- a/src/engine/loopingcontrol.cpp
+++ b/src/engine/loopingcontrol.cpp
@@ -119,12 +119,6 @@ LoopingControl::LoopingControl(QString group,
true, false, false, 4.0);
m_pCOBeatLoopSize->connectValueChangeRequest(this,
SLOT(slotBeatLoopSizeChangeRequest(double)), Qt::DirectConnection);
- m_pCOBeatLoopDouble = new ControlPushButton(ConfigKey(group, "beatloop_double"));
- connect(m_pCOBeatLoopDouble, SIGNAL(valueChanged(double)),
- this, SLOT(slotBeatLoopDouble(double)));
- m_pCOBeatLoopHalve = new ControlPushButton(ConfigKey(group, "beatloop_halve"));
- connect(m_pCOBeatLoopHalve, SIGNAL(valueChanged(double)),
- this, SLOT(slotBeatLoopHalve(double)));
m_pCOBeatLoopToggle = new ControlPushButton(ConfigKey(group, "beatloop_toggle"));
connect(m_pCOBeatLoopToggle, SIGNAL(valueChanged(double)),
this, SLOT(slotBeatLoopToggle(double)));
@@ -233,8 +227,6 @@ LoopingControl::~LoopingControl() {
delete pBeatLoop;
}
delete m_pCOBeatLoopSize;
- delete m_pCOBeatLoopDouble;
- delete m_pCOBeatLoopHalve;
delete m_pCOBeatLoopToggle;
delete m_pCOBeatLoopRollActivate;
@@ -315,14 +307,7 @@ void LoopingControl::slotLoopHalve(double pressed) {
return;
}
- LoopSamples loopSamples = m_loopSamples.getValue();
- bool noLoopSet = loopSamples.start == kNoTrigger || loopSamples.end == kNoTrigger;
-
- if (noLoopSet || currentLoopMatchesBeatloopSize()) {
- slotBeatLoop(m_pCOBeatLoopSize->get() / 2.0, true, false);
- } else {
- slotLoopScale(0.5);
- }
+ slotBeatLoop(m_pCOBeatLoopSize->get() / 2.0, true, false);
}
void LoopingControl::slotLoopDouble(double pressed) {
@@ -330,14 +315,7 @@ void LoopingControl::slotLoopDouble(double pressed) {
return;
}
- LoopSamples loopSamples = m_loopSamples.getValue();
- bool noLoopSet = loopSamples.start == kNoTrigger || loopSamples.end == kNoTrigger;
-
- if (noLoopSet || currentLoopMatchesBeatloopSize()) {
- slotBeatLoop(m_pCOBeatLoopSize->get() * 2.0, true, false);
- } else {
- slotLoopScale(2.0);
- }
+ slotBeatLoop(m_pCOBeatLoopSize->get() * 2.0, true, false);
}
double LoopingControl::process(const double dRate,
@@ -499,6 +477,13 @@ void LoopingControl::setLoopInToCurrentPosition() {
loopSamples.start = pos;
m_pCOLoopStartPosition->set(loopSamples.start);
+ if (m_pQuantizeEnabled->toBool()
+ && loopSamples.start < loopSamples.end
+ && m_pBeats != nullptr) {
+ m_pCOBeatLoopSize->setAndConfirm(
+ m_pBeats->numBeatsInRange(loopSamples.start, loopSamples.end));
+ }
+
m_loopSamples.setValue(loopSamples);
//qDebug() << "set loop_in to " << loopSamples.start;
}
@@ -575,6 +560,10 @@ void LoopingControl::setLoopOutToCurrentPosition() {
loopSamples.end = pos;
m_pCOLoopEndPosition->set(loopSamples.end);
m_loopSamples.setValue(loopSamples);
+ if (m_pQuantizeEnabled->toBool() && m_pBeats != nullptr) {
+ m_pCOBeatLoopSize->setAndConfirm(
+ m_pBeats->numBeatsInRange(loopSamples.start, loopSamples.end));
+ }
// start looping
if (loopSamples.start != kNoTrigger &&
@@ -902,7 +891,7 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable
double nextBeat;
m_pBeats->findPrevNextBeats(cur_pos, &prevBeat, &nextBeat);
- if (m_pQuantizeEnabled->get() > 0.0 && prevBeat != -1) {
+ if (m_pQuantizeEnabled->toBool() && prevBeat != -1) {
if (beats >= 1.0) {
newloopSamples.start = prevBeat;
} else {
@@ -960,7 +949,7 @@ void LoopingControl::slotBeatLoop(double beats, bool keepStartPoint, bool enable
return;
}
- // When loading a new track or after setting a manual loop,
+ // When loading a new track or after setting a manual loop without quantize,
// do not resize the existing loop until beatloop_size matches
// the size of the existing loop.
// Do not return immediately so beatloop_size can be updated.
@@ -1020,20 +1009,6 @@ void LoopingControl::slotBeatLoopSizeChangeRequest(double beats) {
slotBeatLoop(beats, true, false);
}
-void LoopingControl::slotBeatLoopDouble(double pressed) {
- if (pressed <= 0.0) {
- return;
- }
- slotBeatLoop(m_pCOBeatLoopSize->get() * 2.0, true, false);
-}
-
-void LoopingControl::slotBeatLoopHalve(double pressed) {
- if (pressed <= 0.0) {
- return;
- }
- slotBeatLoop(m_pCOBeatLoopSize->get() / 2.0, true, false);
-}
-
void LoopingControl::slotBeatLoopToggle(double pressed) {
if (pressed > 0) {
if (m_bLoopingEnabled) {
diff --git a/src/engine/loopingcontrol.h b/src/engine/loopingcontrol.h
index 815d0bb794..7c0801c4ee 100644
--- a/src/engine/loopingcontrol.h
+++ b/src/engine/loopingcontrol.h
@@ -75,8 +75,6 @@ class LoopingControl : public EngineControl {
// beatslicing effect.
void slotBeatLoop(double loopSize, bool keepStartPoint=false, bool enable=true);
void slotBeatLoopSizeChangeRequest(double beats);
- void slotBeatLoopHalve(double pressed);
- void slotBeatLoopDouble(double pressed);
void slotBeatLoopToggle(double pressed);
void slotBeatLoopRollActivate(double pressed);
void slotBeatLoopActivate(BeatLoopingControl* pBeatLoopControl);
@@ -156,8 +154,6 @@ class LoopingControl : public EngineControl {
// Base BeatLoop Control Object.
ControlObject* m_pCOBeatLoop;
ControlObject* m_pCOBeatLoopSize;
- ControlPushButton* m_pCOBeatLoopDouble;
- ControlPushButton* m_pCOBeatLoopHalve;
// Different sizes for Beat Loops/Seeks.
static double s_dBeatSizes[];
// Array of BeatLoopingControls, one for each size.