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

Add beatloop anchor to set and adjust loop from either start or end #12745

Merged
merged 6 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 21 additions & 0 deletions src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,16 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
QString beatloopRollActivateTitle = tr("Loop Roll Selected Beats");
QString beatloopRollActivateDescription = tr("Create a rolling beat loop of selected beat size");
QString beatLoopTitle = tr("Loop %1 Beats");
QString reverseBeatLoopTitle = tr("Loop %1 Beats set from its exit point");
acolombier marked this conversation as resolved.
Show resolved Hide resolved
QString beatLoopRollTitle = tr("Loop Roll %1 Beats");
QString reverseBeatLoopRollTitle = tr("Loop Roll %1 Beats set from its exit point");
QString beatLoopDescription = tr("Create %1-beat loop");
QString reverseBeatLoopDescription = tr(
"Create %1-beat loop with the current play position as loop exit");
QString beatLoopRollDescription = tr("Create temporary %1-beat loop roll");
QString reverseBeatLoopRollDescription =
tr("Create temporary %1-beat loop roll with the current play "
"position as loop exit");

QList<double> beatSizes = LoopingControl::getBeatSizes();

Expand Down Expand Up @@ -624,6 +631,13 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
beatLoopDescription.arg(humanBeats),
pLoopActivateMenu);
}
for (double beats : beatSizes) {
QString humanBeats = humanBeatSizes.value(beats, QString::number(beats));
addDeckControl(QString("beatloop_r%1_toggle").arg(beats),
reverseBeatLoopTitle.arg(humanBeats),
reverseBeatLoopDescription.arg(humanBeats),
pLoopActivateMenu);
}
pLoopMenu->addSeparator();

addDeckControl("beatlooproll_activate",
Expand All @@ -638,6 +652,13 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
beatLoopRollDescription.arg(humanBeats),
pLooprollActivateMenu);
}
for (double beats : beatSizes) {
QString humanBeats = humanBeatSizes.value(beats, QString::number(beats));
addDeckControl(QString("beatlooproll_r%1_activate").arg(beats),
reverseBeatLoopRollTitle.arg(humanBeats),
reverseBeatLoopRollDescription.arg(humanBeats),
pLooprollActivateMenu);
}
pLoopMenu->addSeparator();

addDeckControl("loop_in", tr("Loop In"), tr("Loop In button"), pLoopMenu);
Expand Down
108 changes: 86 additions & 22 deletions src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1920,49 +1920,74 @@ void LoopMoveControl::slotMoveForward(double v) {

BeatLoopingControl::BeatLoopingControl(const QString& group, double size)
: m_dBeatLoopSize(size),
m_bActive(false) {
m_bActive(false),
m_pCOLoopAnchor(std::make_unique<ControlProxy>(group, "loop_anchor", this)) {
// This is the original beatloop control which is now deprecated. Its value
// is the state of the beatloop control (1 for enabled, 0 for disabled).
m_pLegacy = new ControlPushButton(
m_pLegacy = std::make_unique<ControlPushButton>(
keyForControl(group, "beatloop_%1", size));
m_pLegacy->setButtonMode(ControlPushButton::TOGGLE);
connect(m_pLegacy, &ControlObject::valueChanged,
this, &BeatLoopingControl::slotLegacy,
connect(m_pLegacy.get(),
&ControlObject::valueChanged,
this,
&BeatLoopingControl::slotLegacy,
Qt::DirectConnection);
// A push-button which activates the beatloop.
m_pActivate = new ControlPushButton(
m_pActivate = std::make_unique<ControlPushButton>(
keyForControl(group, "beatloop_%1_activate", size));
connect(m_pActivate, &ControlObject::valueChanged,
this, &BeatLoopingControl::slotActivate,
connect(m_pActivate.get(),
&ControlObject::valueChanged,
this,
&BeatLoopingControl::slotActivate,
Qt::DirectConnection);
// And the same but setting it from the end point instead of starting
m_pRActivate = std::make_unique<ControlPushButton>(
keyForControl(group, "beatloop_r%1_activate", size));
connect(m_pRActivate.get(),
&ControlObject::valueChanged,
this,
&BeatLoopingControl::slotReverseActivate,
Qt::DirectConnection);
// A push-button which toggles the beatloop as active or inactive.
m_pToggle = new ControlPushButton(
m_pToggle = std::make_unique<ControlPushButton>(
keyForControl(group, "beatloop_%1_toggle", size));
connect(m_pToggle, &ControlObject::valueChanged,
this, &BeatLoopingControl::slotToggle,
connect(m_pToggle.get(),
&ControlObject::valueChanged,
this,
&BeatLoopingControl::slotToggle,
Qt::DirectConnection);
// And the same but setting it from the end point instead of starting
m_pRToggle = std::make_unique<ControlPushButton>(
keyForControl(group, "beatloop_r%1_toggle", size));
connect(m_pRToggle.get(),
&ControlObject::valueChanged,
this,
&BeatLoopingControl::slotReverseToggle,
Qt::DirectConnection);

// A push-button which activates rolling beatloops
m_pActivateRoll = new ControlPushButton(
m_pActivateRoll = std::make_unique<ControlPushButton>(
keyForControl(group, "beatlooproll_%1_activate", size));
connect(m_pActivateRoll, &ControlObject::valueChanged,
this, &BeatLoopingControl::slotActivateRoll,
connect(m_pActivateRoll.get(),
&ControlObject::valueChanged,
this,
&BeatLoopingControl::slotActivateRoll,
Qt::DirectConnection);
// And the same but setting it from the end point instead of starting
m_pRActivateRoll = std::make_unique<ControlPushButton>(
keyForControl(group, "beatlooproll_r%1_activate", size));
connect(m_pRActivateRoll.get(),
&ControlObject::valueChanged,
this,
&BeatLoopingControl::slotReverseActivateRoll,
Qt::DirectConnection);

// An indicator control which is 1 if the beatloop is enabled and 0 if not.
m_pEnabled = new ControlObject(
m_pEnabled = std::make_unique<ControlObject>(
keyForControl(group, "beatloop_%1_enabled", size));
m_pEnabled->setReadOnly();
}

BeatLoopingControl::~BeatLoopingControl() {
delete m_pActivate;
delete m_pToggle;
delete m_pEnabled;
delete m_pLegacy;
delete m_pActivateRoll;
}

void BeatLoopingControl::deactivate() {
if (m_bActive) {
m_bActive = false;
Expand Down Expand Up @@ -2016,3 +2041,42 @@ void BeatLoopingControl::slotToggle(double value) {
emit activateBeatLoop(this);
}
}

void BeatLoopingControl::slotReverseActivate(double value) {
bool isReverseAnchor = m_pCOLoopAnchor->toBool();
if (!isReverseAnchor) {
// If the reverse mode is not enabled, we do so temporarily
m_pCOLoopAnchor->set(1.0);
acolombier marked this conversation as resolved.
Show resolved Hide resolved
}
slotActivate(value);
if (!isReverseAnchor) {
// If the reverse mode was enabled temporarily, we disabled it now
m_pCOLoopAnchor->set(0.0);
}
}

void BeatLoopingControl::slotReverseActivateRoll(double v) {
bool isReverseAnchor = m_pCOLoopAnchor->toBool();
if (!isReverseAnchor) {
// If the reverse mode is not enabled, we do so temporarily
m_pCOLoopAnchor->set(1.0);
}
slotActivateRoll(v);
if (!isReverseAnchor) {
// If the reverse mode was enabled temporarily, we disabled it now
m_pCOLoopAnchor->set(0.0);
}
}

void BeatLoopingControl::slotReverseToggle(double value) {
bool isReverseAnchor = m_pCOLoopAnchor->toBool();
if (!isReverseAnchor) {
// If the reverse mode is not enabled, we do so temporarily
m_pCOLoopAnchor->set(1.0);
}
slotToggle(value);
if (!isReverseAnchor) {
// If the reverse mode was enabled temporarily, we disabled it now
m_pCOLoopAnchor->set(0.0);
}
}
20 changes: 14 additions & 6 deletions src/engine/controls/loopingcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class ControlPushButton;
class ControlObject;
class ControlProxy;
class RateControl;
class LoopMoveControl;
class BeatJumpControl;
Expand Down Expand Up @@ -287,7 +288,6 @@ class BeatLoopingControl : public QObject {
Q_OBJECT
public:
BeatLoopingControl(const QString& group, double size);
virtual ~BeatLoopingControl();

void activate();
void deactivate();
Expand All @@ -299,6 +299,10 @@ class BeatLoopingControl : public QObject {
void slotActivate(double value);
void slotActivateRoll(double value);
void slotToggle(double value);
private slots:
void slotReverseActivate(double value);
void slotReverseActivateRoll(double value);
void slotReverseToggle(double value);

signals:
void activateBeatLoop(BeatLoopingControl*);
Expand All @@ -309,9 +313,13 @@ class BeatLoopingControl : public QObject {
private:
double m_dBeatLoopSize;
bool m_bActive;
ControlPushButton* m_pLegacy;
ControlPushButton* m_pActivate;
ControlPushButton* m_pActivateRoll;
ControlPushButton* m_pToggle;
ControlObject* m_pEnabled;
std::unique_ptr<ControlPushButton> m_pLegacy;
std::unique_ptr<ControlPushButton> m_pActivate;
std::unique_ptr<ControlPushButton> m_pRActivate;
std::unique_ptr<ControlPushButton> m_pActivateRoll;
std::unique_ptr<ControlPushButton> m_pRActivateRoll;
std::unique_ptr<ControlPushButton> m_pToggle;
std::unique_ptr<ControlPushButton> m_pRToggle;
std::unique_ptr<ControlProxy> m_pCOLoopAnchor;
std::unique_ptr<ControlObject> m_pEnabled;
};