-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
EQ Rack #330
EQ Rack #330
Changes from all commits
bbf6999
458b8b7
d91b153
4c0d2fb
5781325
2a4b063
1299acb
5cb622f
dd092b6
e46bf37
def4866
16f52cb
2589688
ee31d2e
d49aaa8
8859eff
03bdf87
5890140
199146a
4752eba
2d878c4
ab66eee
a61f12a
df366e2
25559ed
50ee860
7122847
ee07447
574d8ea
0c9dabc
f0bfd6f
66bb4ed
e8dcab8
4bf1845
9aeb025
e6f9f4d
06d34aa
615d2e9
c463b8f
2b18b73
b87b610
2f30f76
7a03def
eeb35dc
5cda4b7
8b81768
94177af
fb64948
776323c
f72071f
872341d
be04f6a
9e4ef33
aa97b18
657658b
b20cb78
3fa8cc7
b18c59e
babb40c
5aef2b0
ce76dd8
a27f92a
80c960f
c7bfc2f
bda0da7
1e95377
fa36e3c
b64f3cb
2dbece9
afcc172
b5c9f2f
b89544d
6cc37d4
6c59fa0
d016e61
3875241
b02cc8b
b04311f
94b4013
40a5eb6
795e47b
feb19f0
818c873
e82a1ab
358e074
0343ab6
fb70322
490dcd6
e47fe35
ef107cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,12 @@ | |
|
||
#include <QWidget> | ||
#include <QString> | ||
#include <QHBoxLayout> | ||
|
||
#include "dlgprefeq.h" | ||
#include "engine/enginefilterbessel4.h" | ||
#include "controlobject.h" | ||
#include "controlobjectslave.h" | ||
#include "util/math.h" | ||
|
||
#define CONFIG_KEY "[Mixer Profile]" | ||
|
@@ -29,15 +31,22 @@ | |
const int kFrequencyUpperLimit = 20050; | ||
const int kFrequencyLowerLimit = 16; | ||
|
||
DlgPrefEQ::DlgPrefEQ(QWidget* pParent, ConfigObject<ConfigValue>* pConfig) | ||
DlgPrefEQ::DlgPrefEQ(QWidget* pParent, EffectsManager* pEffectsManager, | ||
ConfigObject<ConfigValue>* pConfig) | ||
: DlgPreferencePage(pParent), | ||
m_COTLoFreq(CONFIG_KEY, "LoEQFrequency"), | ||
m_COTHiFreq(CONFIG_KEY, "HiEQFrequency"), | ||
m_COTLoFi(CONFIG_KEY, "LoFiEQs"), | ||
m_COTEnableEq(CONFIG_KEY, ENABLE_INTERNAL_EQ), | ||
m_pConfig(pConfig), | ||
m_lowEqFreq(0.0), | ||
m_highEqFreq(0.0) { | ||
m_highEqFreq(0.0), | ||
m_pEffectsManager(pEffectsManager) { | ||
|
||
// Get the EQ Effect Rack | ||
m_pEQEffectRack = m_pEffectsManager->getEQEffectRack().data(); | ||
m_eqRackGroup = QString("[EffectRack%1_EffectUnit%2_Effect1]"). | ||
arg(m_pEffectsManager->getEQEffectRackNumber()); | ||
|
||
setupUi(this); | ||
|
||
// Connection | ||
|
@@ -49,16 +58,135 @@ DlgPrefEQ::DlgPrefEQ(QWidget* pParent, ConfigObject<ConfigValue>* pConfig) | |
connect(SliderLoEQ, SIGNAL(sliderMoved(int)), this, SLOT(slotUpdateLoEQ())); | ||
connect(SliderLoEQ, SIGNAL(sliderReleased()), this, SLOT(slotUpdateLoEQ())); | ||
|
||
connect(radioButton_bypass, SIGNAL(clicked()), this, SLOT(slotEqChanged())); | ||
connect(radioButton_bessel4, SIGNAL(clicked()), this, SLOT(slotEqChanged())); | ||
connect(radioButton_butterworth8, SIGNAL(clicked()), this, SLOT(slotEqChanged())); | ||
connect(CheckBoxBypass, SIGNAL(stateChanged(int)), this, SLOT(slotBypass(int))); | ||
|
||
connect(CheckBoxShowAllEffects, SIGNAL(stateChanged(int)), | ||
this, SLOT(slotShowAllEffects())); | ||
|
||
connect(this, | ||
SIGNAL(effectOnChainSlot(const unsigned int, const unsigned int, QString)), | ||
m_pEQEffectRack, | ||
SLOT(slotLoadEffectOnChainSlot(const unsigned int, const unsigned int, QString))); | ||
|
||
// Set to basic view if a previous configuration is missing | ||
CheckBoxShowAllEffects->setChecked(m_pConfig->getValueString( | ||
ConfigKey(CONFIG_KEY, "AdvancedView"), QString("no")) == QString("yes")); | ||
|
||
// Add drop down lists for current decks and connect num_decks control | ||
// to slotAddComboBox | ||
m_pNumDecks = new ControlObjectSlave("[Master]", "num_decks", this); | ||
m_pNumDecks->connectValueChanged(SLOT(slotAddComboBox(double))); | ||
slotAddComboBox(m_pNumDecks->get()); | ||
|
||
// Restore the state of Bypass check box | ||
CheckBoxBypass->setChecked(m_pConfig->getValueString( | ||
ConfigKey(CONFIG_KEY, ENABLE_INTERNAL_EQ), QString("no")) == QString("no")); | ||
if (CheckBoxBypass->isChecked()) { | ||
slotBypass(Qt::Checked); | ||
} else { | ||
slotBypass(Qt::Unchecked); | ||
} | ||
|
||
loadSettings(); | ||
slotUpdate(); | ||
slotApply(); | ||
} | ||
|
||
DlgPrefEQ::~DlgPrefEQ() { | ||
qDeleteAll(m_deckEffectSelectors); | ||
m_deckEffectSelectors.clear(); | ||
} | ||
|
||
void DlgPrefEQ::slotAddComboBox(double numDecks) { | ||
while (m_deckEffectSelectors.size() < static_cast<int>(numDecks)) { | ||
QHBoxLayout* innerHLayout = new QHBoxLayout(); | ||
QLabel* label = new QLabel(QObject::tr("Deck %1"). | ||
arg(m_deckEffectSelectors.size() + 1), this); | ||
|
||
// Create the drop down list and populate it with the available effects | ||
QComboBox* box = new QComboBox(this); | ||
QList<QPair<QString, QString> > availableEffectNames = | ||
m_pEffectsManager->getAvailableEffectNames().toList(); | ||
for (int i = 0; i < availableEffectNames.size(); ++i) { | ||
box->addItem(availableEffectNames[i].second); | ||
box->setItemData(i, QVariant(availableEffectNames[i].first)); | ||
} | ||
m_deckEffectSelectors.append(box); | ||
connect(box, SIGNAL(currentIndexChanged(int)), | ||
this, SLOT(slotEffectChangedOnDeck(int))); | ||
|
||
// Create the drop down list for basic view | ||
// Add EQ Effects only | ||
QComboBox* simpleBox = new QComboBox(this); | ||
QList<QPair<QString, QString> > availableEQEffectNames = | ||
m_pEffectsManager->getAvailableEQEffectNames().toList(); | ||
for (int i = 0; i < availableEQEffectNames.size(); ++i) { | ||
simpleBox->addItem(availableEQEffectNames[i].second); | ||
simpleBox->setItemData(i, QVariant(availableEQEffectNames[i].first)); | ||
} | ||
m_deckBasicEffectSelectors.append(simpleBox); | ||
connect(simpleBox, SIGNAL(currentIndexChanged(int)), | ||
this, SLOT(slotBasicEffectChangedOnDeck(int))); | ||
|
||
// Set the configured effect for box and simpleBox or Butterworth8 EQ | ||
// if none is configured | ||
QString configuredEffect; | ||
int selectedEffectIndex; | ||
configuredEffect = m_pConfig->getValueString(ConfigKey(CONFIG_KEY, | ||
QString("EffectForDeck%1").arg(m_deckEffectSelectors.size())), | ||
QString("butterwortheq")); | ||
selectedEffectIndex = box->findData(configuredEffect); | ||
box->setCurrentIndex(selectedEffectIndex); | ||
|
||
configuredEffect = m_pConfig->getValueString(ConfigKey(CONFIG_KEY, | ||
QString("BasicEffectForDeck%1").arg(m_deckBasicEffectSelectors.size())), | ||
QString("butterwortheq")); | ||
selectedEffectIndex = simpleBox->findData(configuredEffect); | ||
simpleBox->setCurrentIndex(selectedEffectIndex); | ||
|
||
// Force the selected effect on the Effect Rack based on user's preference | ||
bool advancedView = CheckBoxShowAllEffects->isChecked(); | ||
if (advancedView) { | ||
simpleBox->setVisible(false); | ||
emit(effectOnChainSlot(m_deckEffectSelectors.size() - 1, 0, | ||
box->itemData(box->currentIndex()).toString())); | ||
} else { | ||
box->setVisible(false); | ||
emit(effectOnChainSlot(m_deckBasicEffectSelectors.size() - 1, 0, | ||
simpleBox->itemData(simpleBox->currentIndex()).toString())); | ||
} | ||
|
||
// Setup the GUI | ||
innerHLayout->addWidget(label); | ||
innerHLayout->addWidget(box); | ||
innerHLayout->addWidget(simpleBox); | ||
innerHLayout->addStretch(); | ||
verticalLayout_2->addLayout(innerHLayout); | ||
} | ||
} | ||
|
||
void DlgPrefEQ::slotShowAllEffects() { | ||
if (!CheckBoxShowAllEffects->isChecked()) { | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, "AdvancedView"), QString("no")); | ||
foreach (QComboBox* box, m_deckEffectSelectors) { | ||
box->setVisible(false); | ||
} | ||
foreach (QComboBox* basicBox, m_deckBasicEffectSelectors) { | ||
basicBox->setVisible(true); | ||
emit(effectOnChainSlot(m_deckBasicEffectSelectors.indexOf(basicBox), | ||
0, basicBox->itemData(basicBox->currentIndex()).toString())); | ||
} | ||
} else { | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, "AdvancedView"), QString("yes")); | ||
foreach (QComboBox* box, m_deckEffectSelectors) { | ||
box->setVisible(true); | ||
emit(effectOnChainSlot(m_deckEffectSelectors.indexOf(box), | ||
0, box->itemData(box->currentIndex()).toString())); | ||
} | ||
foreach (QComboBox* basicBox, m_deckBasicEffectSelectors) { | ||
basicBox->setVisible(false); | ||
} | ||
} | ||
} | ||
|
||
void DlgPrefEQ::loadSettings() { | ||
|
@@ -93,19 +221,7 @@ void DlgPrefEQ::loadSettings() { | |
|
||
if (m_pConfig->getValueString( | ||
ConfigKey(CONFIG_KEY, ENABLE_INTERNAL_EQ), "yes") == QString("yes")) { | ||
radioButton_bypass->setChecked(false); | ||
if (m_pConfig->getValueString( | ||
ConfigKey(CONFIG_KEY, "LoFiEQs")) == QString("yes")) { | ||
radioButton_bessel4->setChecked(true); | ||
radioButton_butterworth8->setChecked(false); | ||
} else { | ||
radioButton_bessel4->setChecked(false); | ||
radioButton_butterworth8->setChecked(true); | ||
} | ||
} else { | ||
radioButton_bypass->setChecked(true); | ||
radioButton_bessel4->setChecked(false); | ||
radioButton_butterworth8->setChecked(false); | ||
CheckBoxBypass->setChecked(false); | ||
} | ||
} | ||
|
||
|
@@ -118,32 +234,38 @@ void DlgPrefEQ::setDefaultShelves() | |
} | ||
|
||
void DlgPrefEQ::slotResetToDefaults() { | ||
radioButton_bypass->setChecked(false); | ||
radioButton_butterworth8->setChecked(false); | ||
radioButton_bessel4->setChecked(true); | ||
slotEqChanged(); | ||
setDefaultShelves(); | ||
loadSettings(); | ||
slotUpdate(); | ||
slotApply(); | ||
} | ||
|
||
void DlgPrefEQ::slotEqChanged() { | ||
if (radioButton_bypass->isChecked()) { | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, ENABLE_INTERNAL_EQ), QString("no")); | ||
} else { | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, ENABLE_INTERNAL_EQ), QString("yes")); | ||
} | ||
|
||
if (radioButton_bessel4->isChecked()) { | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, "LoFiEQs"), ConfigValue(QString("yes"))); | ||
void DlgPrefEQ::slotEffectChangedOnDeck(int effectIndex) { | ||
QComboBox* c = qobject_cast<QComboBox*>(sender()); | ||
// Check if qobject_cast was successful | ||
if (c) { | ||
int deckNumber = m_deckEffectSelectors.indexOf(c); | ||
QString effectId = c->itemData(effectIndex).toString(); | ||
emit(effectOnChainSlot(deckNumber, 0, effectId)); | ||
|
||
// Update the configured effect for the current QComboBox | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, QString("EffectForDeck%1"). | ||
arg(deckNumber + 1)), ConfigValue(effectId)); | ||
} | ||
} | ||
|
||
if (radioButton_butterworth8->isChecked()) { | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, "LoFiEQs"), ConfigValue(QString("no"))); | ||
void DlgPrefEQ::slotBasicEffectChangedOnDeck(int effectIndex) { | ||
QComboBox* c = qobject_cast<QComboBox*>(sender()); | ||
// Check if qobject_cast was successful | ||
if (c) { | ||
int deckNumber = m_deckBasicEffectSelectors.indexOf(c); | ||
QString effectId = c->itemData(effectIndex).toString(); | ||
emit(effectOnChainSlot(deckNumber, 0, effectId)); | ||
|
||
// Update the configured effect for the current QComboBox | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, QString("BasicEffectForDeck%1"). | ||
arg(deckNumber + 1)), ConfigValue(effectId)); | ||
} | ||
|
||
slotApply(); | ||
} | ||
|
||
void DlgPrefEQ::slotUpdateHiEQ() | ||
|
@@ -208,16 +330,52 @@ void DlgPrefEQ::slotApply() { | |
m_COTLoFreq.slotSet(m_lowEqFreq); | ||
m_COTHiFreq.slotSet(m_highEqFreq); | ||
|
||
m_COTLoFi.slotSet((m_pConfig->getValueString( | ||
ConfigKey(CONFIG_KEY, "LoFiEQs")) == QString("yes"))); | ||
m_COTEnableEq.slotSet((m_pConfig->getValueString( | ||
ConfigKey(CONFIG_KEY, ENABLE_INTERNAL_EQ), "yes") == QString("yes"))); | ||
} | ||
|
||
void DlgPrefEQ::slotUpdate() { | ||
slotUpdateLoEQ(); | ||
slotUpdateHiEQ(); | ||
slotEqChanged(); | ||
} | ||
|
||
void DlgPrefEQ::slotBypass(int state) { | ||
if (state) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer here to keep the selected effect. You can just disable the EQ Effects by the enable CO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, thanks for the idea. It is much better this way. |
||
m_pConfig->set(ConfigKey(CONFIG_KEY, ENABLE_INTERNAL_EQ), QString("no")); | ||
// Disable effect processing for all decks by setting the appropriate | ||
// controls to 0 ("[EffectRackX_EffectUnitDeck_Effect1],enable") | ||
int deck = 1; | ||
ControlObjectSlave disableControl; | ||
foreach(QComboBox* box, m_deckEffectSelectors) { | ||
disableControl.initialize(ConfigKey(m_eqRackGroup.arg(deck), "enabled")); | ||
disableControl.set(0); | ||
deck++; | ||
box->setEnabled(false); | ||
} | ||
|
||
foreach(QComboBox* box, m_deckBasicEffectSelectors) { | ||
box->setEnabled(false); | ||
} | ||
|
||
} else { | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, ENABLE_INTERNAL_EQ), QString("yes")); | ||
// Enable effect processing for all decks by setting the appropriate | ||
// controls to 1 ("[EffectRackX_EffectUnitDeck_Effect1],enable") | ||
int deck = 1; | ||
ControlObjectSlave enableControl; | ||
foreach(QComboBox* box, m_deckEffectSelectors) { | ||
enableControl.initialize(ConfigKey(m_eqRackGroup.arg(deck), "enabled")); | ||
enableControl.set(1); | ||
deck++; | ||
box->setEnabled(true); | ||
} | ||
|
||
foreach(QComboBox* box, m_deckBasicEffectSelectors) { | ||
box->setEnabled(true); | ||
} | ||
} | ||
|
||
slotApply(); | ||
} | ||
|
||
double DlgPrefEQ::getEqFreq(int sliderVal, int minValue, int maxValue) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should hold a strong reference to the EQEffectRack. This ensures that it is not detested early elsewhere.
You can user .data() inside the connect statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do that, I get this:
Warning [Main]: QObject: shared QObject was deleted directly. The program is malformed and may crash.
I've read about a similar issue here[1] but I'm not sure if our warning is caused by the same concept.
[1] - http://blog.codef00.com/2011/12/15/not-so-much-fun-with-qsharedpointer/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then it seam there is an underlying issue. Probably something to do with the memory leak you are facing in the open bug. Please leaf a comment here and we can issue that in a separate commit.