Skip to content

Commit

Permalink
ControllerEngine: add stopDeck()
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Mar 29, 2022
1 parent 8de13cd commit 6ebce1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/controllers/controllerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,18 @@ bool ControllerEngine::isDeckPlaying(const QString& group) {
return pPlay->get() > 0.0;
}

void ControllerEngine::stopDeck(const QString& group) {
ControlObjectScript* pPlay = getControlObjectScript(group, "play");

if (pPlay == nullptr) {
QString error = QString("Could not getControlObjectScript()");
scriptErrorDialog(error, error);
return;
}

pPlay->set(0.0);
}

/* -------- ------------------------------------------------------
Purpose: Enables scratching for relative controls
Input: Virtual deck to scratch,
Expand Down Expand Up @@ -1410,10 +1422,7 @@ void ControllerEngine::scratchProcess(int timerId) {
if (m_brakeActive[deck] || m_spinbackActive[deck]) {
// If in brake mode, set scratch2 rate to 0 and stop the deck.
pScratch2->slotSet(0.0);
ControlObjectScript* pPlay = getControlObjectScript(group, "play");
if (pPlay != nullptr) {
pPlay->slotSet(0.0);
}
stopDeck(group);
}

// Clear scratch2_enable to end scratching.
Expand Down Expand Up @@ -1589,7 +1598,7 @@ void ControllerEngine::brake(int deck, bool activate, double factor, double rate
m_brakeActive[deck] = false;
m_spinbackActive[deck] = false;
stopScratchTimer(timerId);
// TODO(ronso0) Stop deck as if we were braking to halt
stopDeck(group);
return;
}
stopScratchTimer(timerId);
Expand Down
1 change: 1 addition & 0 deletions src/controllers/controllerengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class ControllerEngine : public QObject {
void stopScratchTimer(int timerId);

bool isDeckPlaying(const QString& group);
void stopDeck(const QString& group);
double getDeckRate(const QString& group);

Controller* m_pController;
Expand Down

0 comments on commit 6ebce1b

Please sign in to comment.