Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 9 additions & 18 deletions src/control/controlobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,12 @@ ControlObject::ControlObject() {
}

ControlObject::ControlObject(ConfigKey key, bool bIgnoreNops, bool bTrack,
bool bPersist, double defaultValue) {
initialize(key, bIgnoreNops, bTrack, bPersist, defaultValue);
}

ControlObject::~ControlObject() {
if (m_pControl) {
m_pControl->removeCreatorCO();
}
}

void ControlObject::initialize(ConfigKey key, bool bIgnoreNops, bool bTrack,
bool bPersist, double defaultValue) {
m_key = key;

bool bPersist, double defaultValue)
: m_key(key) {
// Don't bother looking up the control if key is NULL. Prevents log spew.
if (!m_key.isNull()) {
m_pControl = ControlDoublePrivate::getControl(m_key, true, this,
bIgnoreNops, bTrack,
bPersist, defaultValue);
bIgnoreNops, bTrack, bPersist, defaultValue);
}

// getControl can fail and return a NULL control even with the create flag.
Expand All @@ -58,13 +45,17 @@ void ControlObject::initialize(ConfigKey key, bool bIgnoreNops, bool bTrack,
}
}

ControlObject::~ControlObject() {
if (m_pControl) {
m_pControl->removeCreatorCO();
}
}

// slot
void ControlObject::privateValueChanged(double dValue, QObject* pSender) {
// Only emit valueChanged() if we did not originate this change.
if (pSender != this) {
emit(valueChanged(dValue));
} else {
emit(valueChangedFromEngine(dValue));
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/control/controlobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ class ControlObject : public QObject {

signals:
void valueChanged(double);
void valueChangedFromEngine(double);

public:
// DEPRECATED: Called to set the control value from the controller
Expand All @@ -177,8 +176,6 @@ class ControlObject : public QObject {
void readOnlyHandler(double v);

private:
void initialize(ConfigKey key, bool bIgnoreNops, bool bTrack,
bool bPersist, double defaultValue);
inline bool ignoreNops() const {
return m_pControl ? m_pControl->ignoreNops() : true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
effectUnitGroups);

const int iNumDecks = ControlObject::get(
ConfigKey("[Master]", "num_decks"));
ConfigKey("[Master]", "num_decks"));
for (int iDeckNumber = 1; iDeckNumber <= iNumDecks; ++iDeckNumber) {
// PlayerManager::groupForDeck is 0-indexed.
QString playerGroup = PlayerManager::groupForDeck(iDeckNumber - 1);
Expand Down
23 changes: 5 additions & 18 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ EngineBuffer::EngineBuffer(QString group, UserSettingsPointer pConfig,
m_iUiSlowTick(0),
m_dSlipPosition(0.),
m_dSlipRate(1.0),
m_slipEnabled(0),
m_bSlipEnabledProcessing(false),
m_pRepeat(NULL),
m_startButton(NULL),
Expand Down Expand Up @@ -145,12 +144,6 @@ EngineBuffer::EngineBuffer(QString group, UserSettingsPointer pConfig,

m_pSlipButton = new ControlPushButton(ConfigKey(m_group, "slip_enabled"));
m_pSlipButton->setButtonMode(ControlPushButton::TOGGLE);
connect(m_pSlipButton, SIGNAL(valueChanged(double)),
this, SLOT(slotControlSlip(double)),
Qt::DirectConnection);
connect(m_pSlipButton, SIGNAL(valueChangedFromEngine(double)),
this, SLOT(slotControlSlip(double)),
Qt::DirectConnection);

// BPM to display in the UI (updated more slowly than the actual bpm)
m_visualBpm = new ControlObject(ConfigKey(m_group, "visual_bpm"));
Expand Down Expand Up @@ -522,7 +515,6 @@ void EngineBuffer::slotTrackLoaded(TrackPointer pTrack,
m_pTrackSampleRate->set(iTrackSampleRate);
// Reset slip mode
m_pSlipButton->set(0);
m_slipEnabled = 0;
m_bSlipEnabledProcessing = false;
m_dSlipPosition = 0.;
m_dSlipRate = 0;
Expand Down Expand Up @@ -658,7 +650,7 @@ void EngineBuffer::slotControlPlayRequest(double v) {
bool verifiedPlay = updateIndicatorsAndModifyPlay(v > 0.0);

if (!oldPlay && verifiedPlay) {
if (m_pQuantize->get() > 0.0
if (m_pQuantize->toBool()
#ifdef __VINYLCONTROL__
&& m_pVinylControlControl && !m_pVinylControlControl->isEnabled()
#endif
Expand Down Expand Up @@ -708,11 +700,6 @@ void EngineBuffer::slotControlStop(double v)
}
}

void EngineBuffer::slotControlSlip(double v)
{
m_slipEnabled = static_cast<int>(v > 0.0);
}

void EngineBuffer::slotKeylockEngineChanged(double dIndex) {
if (m_bScalerOverride) {
return;
Expand Down Expand Up @@ -900,7 +887,7 @@ void EngineBuffer::process(CSAMPLE* pOutput, const int iBufferSize) {
// we need to sync phase or we'll be totally out of whack and the sync
// adjuster will kick in and push the track back in to sync with the
// master.
if (m_scratching_old && !is_scratching && m_pQuantize->get() > 0.0
if (m_scratching_old && !is_scratching && m_pQuantize->toBool()
&& m_pSyncControl->getSyncMode() == SYNC_FOLLOWER && !paused) {
// TODO() The resulting seek is processed in the following callback
// That is to late
Expand Down Expand Up @@ -1033,13 +1020,13 @@ void EngineBuffer::process(CSAMPLE* pOutput, const int iBufferSize) {
at_start = m_filepos_play <= 0;
at_end = m_filepos_play >= m_trackSamplesOld;

bool repeat_enabled = m_pRepeat->get() != 0.0;
bool repeat_enabled = m_pRepeat->toBool();

bool end_of_track = //(at_start && backwards) ||
(at_end && !backwards);

// If playbutton is pressed, check if we are at start or end of track
if ((m_playButton->get() || (m_fwdButton->get() || m_backButton->get()))
if ((m_playButton->toBool() || (m_fwdButton->toBool() || m_backButton->toBool()))
&& end_of_track) {
if (repeat_enabled) {
double fractionalPos = at_start ? 1.0 : 0;
Expand Down Expand Up @@ -1098,7 +1085,7 @@ void EngineBuffer::process(CSAMPLE* pOutput, const int iBufferSize) {

void EngineBuffer::processSlip(int iBufferSize) {
// Do a single read from m_bSlipEnabled so we don't run in to race conditions.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update the comment

bool enabled = static_cast<bool>(load_atomic(m_slipEnabled));
bool enabled = m_pSlipButton->toBool();
if (enabled != m_bSlipEnabledProcessing) {
m_bSlipEnabledProcessing = enabled;
if (enabled) {
Expand Down
3 changes: 0 additions & 3 deletions src/engine/enginebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ class EngineBuffer : public EngineObject {
void slotControlSeek(double);
void slotControlSeekAbs(double);
void slotControlSeekExact(double);
void slotControlSlip(double);
void slotKeylockEngineChanged(double);

void slotEjectTrack(double);
Expand Down Expand Up @@ -306,8 +305,6 @@ class EngineBuffer : public EngineObject {
double m_dSlipPosition;
// Saved value of rate for slip mode
double m_dSlipRate;
// m_slipEnabled is a boolean accessed from multiple threads, so we use an atomic int.
QAtomicInt m_slipEnabled;
// m_bSlipEnabledProcessing is only used by the engine processing thread.
bool m_bSlipEnabledProcessing;

Expand Down
60 changes: 17 additions & 43 deletions src/engine/keycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,56 +77,28 @@ KeyControl::KeyControl(QString group,
m_keyunlockMode->setButtonMode(ControlPushButton::TOGGLE);

// In case of vinyl control "rate" is a filtered mean value for display
m_pRateSlider = ControlObject::getControl(ConfigKey(group, "rate"));
connect(m_pRateSlider, SIGNAL(valueChanged(double)),
this, SLOT(slotRateChanged()),
Qt::DirectConnection);
connect(m_pRateSlider, SIGNAL(valueChangedFromEngine(double)),
this, SLOT(slotRateChanged()),
m_pRateSlider = new ControlProxy(group, "rate", this);
m_pRateSlider->connectValueChanged(SLOT(slotRateChanged()),
Qt::DirectConnection);

m_pRateRange = ControlObject::getControl(ConfigKey(group, "rateRange"));
connect(m_pRateRange, SIGNAL(valueChanged(double)),
this, SLOT(slotRateChanged()),
Qt::DirectConnection);
connect(m_pRateRange, SIGNAL(valueChangedFromEngine(double)),
this, SLOT(slotRateChanged()),
m_pRateRange = new ControlProxy(group, "rateRange", this);
m_pRateRange->connectValueChanged(SLOT(slotRateChanged()),
Qt::DirectConnection);

m_pRateDir = ControlObject::getControl(ConfigKey(group, "rate_dir"));
connect(m_pRateDir, SIGNAL(valueChanged(double)),
this, SLOT(slotRateChanged()),
Qt::DirectConnection);
connect(m_pRateDir, SIGNAL(valueChangedFromEngine(double)),
this, SLOT(slotRateChanged()),
m_pRateDir = new ControlProxy(group, "rate_dir", this);
m_pRateDir->connectValueChanged(SLOT(slotRateChanged()),
Qt::DirectConnection);

m_pVCEnabled = ControlObject::getControl(ConfigKey(group, "vinylcontrol_enabled"));
if (m_pVCEnabled) {
connect(m_pVCEnabled, SIGNAL(valueChanged(double)),
this, SLOT(slotRateChanged()),
Qt::DirectConnection);
connect(m_pVCEnabled, SIGNAL(valueChangedFromEngine(double)),
this, SLOT(slotRateChanged()),
Qt::DirectConnection);
}
m_pVCEnabled = new ControlProxy(group, "vinylcontrol_enabled", this);
m_pVCEnabled->connectValueChanged(SLOT(slotRateChanged()),
Qt::DirectConnection);

m_pVCRate = ControlObject::getControl(ConfigKey(group, "vinylcontrol_rate"));
if (m_pVCRate) {
connect(m_pVCRate, SIGNAL(valueChanged(double)),
this, SLOT(slotRateChanged()),
Qt::DirectConnection);
connect(m_pVCRate, SIGNAL(valueChangedFromEngine(double)),
this, SLOT(slotRateChanged()),
m_pVCRate = new ControlProxy(group, "vinylcontrol_rate", this);
m_pVCRate->connectValueChanged(SLOT(slotRateChanged()),
Qt::DirectConnection);
}

m_pKeylock = ControlObject::getControl(ConfigKey(group, "keylock"));
connect(m_pKeylock, SIGNAL(valueChanged(double)),
this, SLOT(slotRateChanged()),
Qt::DirectConnection);
connect(m_pKeylock, SIGNAL(valueChangedFromEngine(double)),
this, SLOT(slotRateChanged()),
m_pKeylock = new ControlProxy(group, "keylock", this);
m_pKeylock->connectValueChanged(SLOT(slotRateChanged()),
Qt::DirectConnection);
}

Expand Down Expand Up @@ -172,10 +144,12 @@ void KeyControl::updateRate() {
// If rate is not 1.0 then we have to try and calculate the octave change
// caused by it.

if(m_pVCEnabled && m_pVCEnabled->toBool()) {
if(m_pVCEnabled->toBool()) {
m_pitchRateInfo.tempoRatio = m_pVCRate->get();
} else {
m_pitchRateInfo.tempoRatio = 1.0 + m_pRateDir->get() * m_pRateRange->get() * m_pRateSlider->get();
m_pitchRateInfo.tempoRatio = 1.0
+ m_pRateDir->get() * m_pRateRange->get()
* m_pRateSlider->get();
}

if (m_pitchRateInfo.tempoRatio == 0) {
Expand Down
13 changes: 6 additions & 7 deletions src/engine/keycontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ class KeyControl : public EngineControl {
void updatePitchAdjust();
void updateRate();

// ControlObjects that come from EngineBuffer
ControlObject* m_pRateSlider;
ControlObject* m_pRateRange;
ControlObject* m_pRateDir;
ControlProxy* m_pRateSlider;
ControlProxy* m_pRateRange;
ControlProxy* m_pRateDir;

ControlObject* m_pVCRate;
ControlObject* m_pVCEnabled;
ControlProxy* m_pVCRate;
ControlProxy* m_pVCEnabled;

ControlObject* m_pKeylock;
ControlProxy* m_pKeylock;
ControlPotmeter* m_pPitch;
ControlPotmeter* m_pPitchAdjust;
ControlPushButton* m_pButtonSyncKey;
Expand Down
Loading