// cuecontrol.cpp
// Created 11/5/2009 by RJ Ryan (rryan@mit.edu)
#include <QMutexLocker>
#include <QStringBuilder>
#include "engine/enginebuffer.h"
#include "engine/cuecontrol.h"
#include "control/controlobject.h"
#include "control/controlpushbutton.h"
#include "control/controlindicator.h"
#include "vinylcontrol/defs_vinylcontrol.h"
#include "util/sample.h"
// TODO: Convert these doubles to a standard enum
// and convert elseif logic to switch statements
static const double CUE_MODE_MIXXX = 0.0;
static const double CUE_MODE_PIONEER = 1.0;
static const double CUE_MODE_DENON = 2.0;
static const double CUE_MODE_NUMARK = 3.0;
static const double CUE_MODE_MIXXX_NO_BLINK = 4.0;
static const double CUE_MODE_CUP = 5.0;
CueControl::CueControl(QString group,
UserSettingsPointer pConfig) :
EngineControl(group, pConfig),
m_bPreviewing(false),
// m_pPlay->toBoo() -> engine play state
// m_pPlay->set(1.0) -> emulate play button press
m_pPlay(ControlObject::getControl(ConfigKey(group, "play"))),
m_pStopButton(ControlObject::getControl(ConfigKey(group, "stop"))),
m_iCurrentlyPreviewingHotcues(0),
m_bypassCueSetByPlay(false),
m_iNumHotCues(NUM_HOT_CUES),
m_pLoadedTrack(),
m_mutex(QMutex::Recursive) {
// To silence a compiler warning about CUE_MODE_PIONEER.
Q_UNUSED(CUE_MODE_PIONEER);
createControls();
m_pTrackSamples = ControlObject::getControl(ConfigKey(group, "track_samples"));
m_pQuantizeEnabled = ControlObject::getControl(ConfigKey(group, "quantize"));
m_pNextBeat = ControlObject::getControl(ConfigKey(group, "beat_next"));
m_pClosestBeat = ControlObject::getControl(ConfigKey(group, "beat_closest"));
m_pCuePoint = new ControlObject(ConfigKey(group, "cue_point"));
m_pCuePoint->set(-1.0);
m_pCueMode = new ControlObject(ConfigKey(group, "cue_mode"));
m_pCueSet = new ControlPushButton(ConfigKey(group, "cue_set"));
m_pCueSet->setButtonMode(ControlPushButton::TRIGGER);
connect(m_pCueSet, SIGNAL(valueChanged(double)),
this, SLOT(cueSet(double)),
Qt::DirectConnection);
m_pCueGoto = new ControlPushButton(ConfigKey(group, "cue_goto"));
connect(m_pCueGoto, SIGNAL(valueChanged(double)),
this, SLOT(cueGoto(double)),
Qt::DirectConnection);
m_pCueGotoAndPlay =
new ControlPushButton(ConfigKey(group, "cue_gotoandplay"));
connect(m_pCueGotoAndPlay, SIGNAL(valueChanged(double)),
this, SLOT(cueGotoAndPlay(double)),
Qt::DirectConnection);
m_pCuePlay =
new ControlPushButton(ConfigKey(group, "cue_play"));
connect(m_pCuePlay, SIGNAL(valueChanged(double)),
this, SLOT(cuePlay(double)),
Qt::DirectConnection);
m_pCueGotoAndStop =
new ControlPushButton(ConfigKey(group, "cue_gotoandstop"));
connect(m_pCueGotoAndStop, SIGNAL(valueChanged(double)),
this, SLOT(cueGotoAndStop(double)),
Qt::DirectConnection);
m_pCuePreview = new ControlPushButton(ConfigKey(group, "cue_preview"));
connect(m_pCuePreview, SIGNAL(valueChanged(double)),
this, SLOT(cuePreview(double)),
Qt