-
-
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 82 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) { | ||
|
||
// Initialize the EQ Effect Rack | ||
int iEqRackNumber = m_pEffectsManager->getEffectChainManager() | ||
->getEffectRacksSize(); | ||
m_pEQEffectRack = m_pEffectsManager->getEffectRack(iEqRackNumber - 1).data(); | ||
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. We cannot know is this is true after later changes. We may ask the EffectChainManager via a new function 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. Why we cannot use the shared pointer here? 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. We need to pass the raw pointer to |
||
|
||
setupUi(this); | ||
|
||
// Connection | ||
|
@@ -49,16 +58,132 @@ 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(checkBox_bypass, 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))); | ||
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. please align all line breaks here. |
||
|
||
// 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()); | ||
|
||
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(QString("Deck %1"). | ||
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. This should be translate-able |
||
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)); | ||
} | ||
// Add an empty effect entry | ||
box->addItem("None"); | ||
box->setItemData(availableEffectNames.size(), "none"); | ||
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. This should be translate-able |
||
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)); | ||
} | ||
// Add an empty effect entry | ||
simpleBox->addItem("None"); | ||
simpleBox->setItemData(availableEQEffectNames.size(), "none"); | ||
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. This should be translate-able |
||
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("Butterworth8 EQ")); | ||
selectedEffectIndex = box->findText(configuredEffect); | ||
box->setCurrentIndex(selectedEffectIndex); | ||
|
||
configuredEffect = m_pConfig->getValueString(ConfigKey(CONFIG_KEY, | ||
QString("BasicEffectForDeck%1").arg(m_deckBasicEffectSelectors.size())), | ||
QString("Butterworth8 EQ")); | ||
selectedEffectIndex = simpleBox->findText(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 +218,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); | ||
checkBox_bypass->setChecked(false); | ||
} | ||
} | ||
|
||
|
@@ -118,32 +231,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(c->currentText())); | ||
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. Here, you should use the ID String of the effect. |
||
} | ||
} | ||
|
||
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(c->currentText())); | ||
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. Can we avoid some duplicated code here? |
||
} | ||
|
||
slotApply(); | ||
} | ||
|
||
void DlgPrefEQ::slotUpdateHiEQ() | ||
|
@@ -208,16 +327,47 @@ 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")); | ||
// Load none on each deck | ||
int noneIndex; | ||
foreach(QComboBox* box, m_deckEffectSelectors) { | ||
noneIndex = box->findText(QString("None")); | ||
box->setCurrentIndex(noneIndex); | ||
box->setEnabled(false); | ||
} | ||
foreach(QComboBox* box, m_deckBasicEffectSelectors) { | ||
noneIndex = box->findText(QString("None")); | ||
box->setCurrentIndex(noneIndex); | ||
box->setEnabled(false); | ||
} | ||
} else { | ||
m_pConfig->set(ConfigKey(CONFIG_KEY, ENABLE_INTERNAL_EQ), QString("yes")); | ||
// Load Butterworth8 EQ on each slot after enabling the EQ | ||
int defaultEqIndex; | ||
foreach(QComboBox* box, m_deckEffectSelectors) { | ||
defaultEqIndex = box->findText(QString("Butterworth8 EQ")); | ||
box->setCurrentIndex(defaultEqIndex); | ||
box->setEnabled(true); | ||
} | ||
foreach(QComboBox* box, m_deckBasicEffectSelectors) { | ||
defaultEqIndex = box->findText(QString("Butterworth8 EQ")); | ||
box->setCurrentIndex(defaultEqIndex); | ||
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.
// Get the EQ Effect Rack
It is already initialized