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: 21 additions & 6 deletions src/engine/keycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

//static const double kLockOriginalKey = 0;
static const double kLockCurrentKey = 1;
static const double kKeepUnlockedKey = 1;

KeyControl::KeyControl(QString group,
UserSettingsPointer pConfig)
Expand Down Expand Up @@ -72,6 +73,9 @@ KeyControl::KeyControl(QString group,
m_keylockMode = new ControlPushButton(ConfigKey(group, "keylockMode"));
m_keylockMode->setButtonMode(ControlPushButton::TOGGLE);

m_keyunlockMode = new ControlPushButton(ConfigKey(group, "keyunlockMode"));
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)),
Expand Down Expand Up @@ -135,6 +139,7 @@ KeyControl::~KeyControl() {
delete m_pEngineKey;
delete m_pEngineKeyDistance;
delete m_keylockMode;
delete m_keyunlockMode;
}

KeyControl::PitchTempoRatio KeyControl::getPitchTempoRatio() {
Expand Down Expand Up @@ -212,12 +217,22 @@ void KeyControl::updateRate() {
// !bKeylock
if (m_pitchRateInfo.keylock) {
// Disabling Keylock
if (m_keylockMode->get() == kLockCurrentKey) {
// reset to linear pitch
m_pitchRateInfo.pitchTweakRatio = 1.0;
// For not resetting to linear pitch:
// Adopt speedPitchRatio change as pitchTweakRatio
//pitchRateInfo.pitchTweakRatio *= (m_speedSliderPitchRatio / pitchRateInfo.tempoRatio);
// If "Keep unlocked key" is enabled
if (m_keyunlockMode->get() == kKeepUnlockedKey) {
// don't reset to linear pitch, instead adopt speedSliderPitchRatio
// change as pitchTweakRatio
m_pitchRateInfo.pitchTweakRatio *=
(speedSliderPitchRatio / m_pitchRateInfo.tempoRatio);
// adopt pitch_adjust now so that it doesn't jump and resets key
// when touching pitch_adjust knob after unlock with offset key
m_pPitchAdjust->set(
KeyUtils::powerOf2ToSemitoneChange(m_pitchRateInfo.pitchTweakRatio));
} else {
// If 'current' aka 'not original' key was locked
if (m_keylockMode->get() == kLockCurrentKey) {
// reset to linear pitch
m_pitchRateInfo.pitchTweakRatio = 1.0;
}
}
m_pitchRateInfo.keylock = false;
}
Expand Down
1 change: 1 addition & 0 deletions src/engine/keycontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class KeyControl : public EngineControl {
ControlPushButton* m_pButtonSyncKey;
ControlPushButton* m_pButtonResetKey;
ControlPushButton* m_keylockMode;
ControlPushButton* m_keyunlockMode;

/** The current loaded file's detected key */
ControlObject* m_pFileKey;
Expand Down
56 changes: 50 additions & 6 deletions src/preferences/dialog/dlgprefcontrols.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***************************************************************************
dlgprefcontrols.cpp - description
-------------------
dlgprefcontrols.cpp - description
-------------------
begin : Sat Jul 5 2003
copyright : (C) 2003 by Tue & Ken Haste Andersen
email : haste@diku.dk
Expand Down Expand Up @@ -125,12 +125,26 @@ DlgPrefControls::DlgPrefControls(QWidget * parent, MixxxMainWindow * mixxx,
connect(buttonGroupKeyLockMode, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(slotKeyLockMode(QAbstractButton *)));

// 0 Lock original key, 1 Lock current key
m_keylockMode = m_pConfig->getValue(
ConfigKey("[Controls]", "keylockMode"), 0);
foreach (ControlProxy* pControl, m_keylockModeControls) {
pControl->set(m_keylockMode);
}

//
// Key unlock mode
//
connect(buttonGroupKeyUnlockMode, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(slotKeyUnlockMode(QAbstractButton *)));

// 0 Reset locked key (default), 1 Keep locked key
m_keyunlockMode = m_pConfig->getValue(
ConfigKey("[Controls]", "keyunlockMode"), 0);
foreach (ControlProxy* pControl, m_keyunlockModeControls) {
pControl->set(m_keyunlockMode);
}

//
// Rate buttons configuration
//
Expand Down Expand Up @@ -302,7 +316,7 @@ DlgPrefControls::DlgPrefControls(QWidget * parent, MixxxMainWindow * mixxx,
// Start in fullscreen mode
//
checkBoxStartFullScreen->setChecked(m_pConfig->getValueString(
ConfigKey("[Config]", "StartInFullscreen")).toInt()==1);
ConfigKey("[Config]", "StartInFullscreen")).toInt()==1);
connect(checkBoxStartFullScreen, SIGNAL(toggled(bool)),
this, SLOT(slotSetStartInFullScreen(bool)));
//
Expand Down Expand Up @@ -378,6 +392,7 @@ DlgPrefControls::~DlgPrefControls() {
qDeleteAll(m_cueControls);
qDeleteAll(m_rateRangeControls);
qDeleteAll(m_keylockModeControls);
qDeleteAll(m_keyunlockModeControls);
}

void DlgPrefControls::slotUpdateSchemes() {
Expand Down Expand Up @@ -427,6 +442,11 @@ void DlgPrefControls::slotUpdate() {
else
radioButtonOriginalKey->setChecked(true);

if (m_keyunlockMode == 1)
radioButtonKeepUnlockedKey->setChecked(true);
else
radioButtonResetUnlockedKey->setChecked(true);

checkBoxResetSpeed->setChecked(m_speedAutoReset);
checkBoxResetPitch->setChecked(m_pitchAutoReset);
}
Expand Down Expand Up @@ -481,6 +501,10 @@ void DlgPrefControls::slotResetToDefaults() {
// Lock to original key
m_keylockMode = 0;
radioButtonOriginalKey->setChecked(true);

// Reset key on unlock
m_keyunlockMode = 0;
radioButtonResetUnlockedKey->setChecked(true);
}

void DlgPrefControls::slotSetLocale(int pos) {
Expand Down Expand Up @@ -542,6 +566,13 @@ void DlgPrefControls::slotKeyLockMode(QAbstractButton* b) {
else { m_keylockMode = 0; }
}

void DlgPrefControls::slotKeyUnlockMode(QAbstractButton* b) {
if (b == radioButtonResetUnlockedKey) {
m_keyunlockMode = 0;
}
else { m_keyunlockMode = 1; }
}

void DlgPrefControls::slotSetAllowTrackLoadToPlayingDeck(bool b) {
// If b is true, it means NOT to allow track loading
m_pConfig->set(ConfigKey("[Controls]", "AllowTrackLoadToPlayingDeck"),
Expand Down Expand Up @@ -691,11 +722,18 @@ void DlgPrefControls::slotApply() {
ConfigValue(configSPAutoReset));

m_pConfig->set(ConfigKey("[Controls]", "keylockMode"),
ConfigValue(m_keylockMode));
ConfigValue(m_keylockMode));
// Set key lock behavior for every group
foreach (ControlProxy* pControl, m_keylockModeControls) {
pControl->set(m_keylockMode);
}

m_pConfig->set(ConfigKey("[Controls]", "keyunlockMode"),
ConfigValue(m_keyunlockMode));
// Set key un-lock behavior for every group
foreach (ControlProxy* pControl, m_keyunlockModeControls) {
pControl->set(m_keyunlockMode);
}
}

//Returns TRUE if skin fits to screen resolution, FALSE otherwise
Expand Down Expand Up @@ -748,8 +786,11 @@ void DlgPrefControls::slotNumDecksChanged(double new_count) {
m_cueControls.push_back(new ControlProxy(
group, "cue_mode"));
m_keylockModeControls.push_back(new ControlProxy(
group, "keylockMode"));
group, "keylockMode"));
m_keylockModeControls.last()->set(m_keylockMode);
m_keyunlockModeControls.push_back(new ControlProxy(
group, "keyunlockMode"));
m_keyunlockModeControls.last()->set(m_keyunlockMode);
}

m_iNumConfiguredDecks = numdecks;
Expand All @@ -774,8 +815,11 @@ void DlgPrefControls::slotNumSamplersChanged(double new_count) {
m_cueControls.push_back(new ControlProxy(
group, "cue_mode"));
m_keylockModeControls.push_back(new ControlProxy(
group, "keylockMode"));
group, "keylockMode"));
m_keylockModeControls.last()->set(m_keylockMode);
m_keyunlockModeControls.push_back(new ControlProxy(
group, "keyunlockMode"));
m_keyunlockModeControls.last()->set(m_keyunlockMode);
}

m_iNumConfiguredSamplers = numsamplers;
Expand Down
3 changes: 3 additions & 0 deletions src/preferences/dialog/dlgprefcontrols.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class DlgPrefControls : public DlgPreferencePage, public Ui::DlgPrefControlsDlg
void slotSetRateDir(bool invert);
void slotSetRateDir(int pos);
void slotKeyLockMode(QAbstractButton*);
void slotKeyUnlockMode(QAbstractButton*);
void slotSetRateTempLeft(double);
void slotSetRateTempRight(double);
void slotSetRatePermLeft(double);
Expand Down Expand Up @@ -96,6 +97,7 @@ class DlgPrefControls : public DlgPreferencePage, public Ui::DlgPrefControlsDlg
QList<ControlProxy*> m_rateDirControls;
QList<ControlProxy*> m_rateRangeControls;
QList<ControlProxy*> m_keylockModeControls;
QList<ControlProxy*> m_keyunlockModeControls;
MixxxMainWindow *m_mixxx;
SkinLoader* m_pSkinLoader;
PlayerManager* m_pPlayerManager;
Expand All @@ -106,6 +108,7 @@ class DlgPrefControls : public DlgPreferencePage, public Ui::DlgPrefControlsDlg
bool m_speedAutoReset;
bool m_pitchAutoReset;
int m_keylockMode;
int m_keyunlockMode;
};

#endif
Loading