#include "filterbankwidget.h" #include #include "dmxPersonality.h" FilterBankWidget::FilterBankWidget(QWidget *parent) : QWidget{parent} { QHBoxLayout *layout = new QHBoxLayout; layout->setAlignment(Qt::AlignHCenter); layout->setContentsMargins(0, 2, 0, 2); layout->setSpacing(0); this->setStyleSheet("border: 2px solid #5a4855;" "margin: 0px;" "margin-top: 3px;" "margin-bottom: 3px;" "background-color: #383034;" ); for (int i = 0; i < 13; i++) { fb[i] = new ClickableDoubleSpinBox; const char *name = dmxChannelToString(i + 9); fb[i]->setObjectName(name); fb[i]->setToolTip(name); } QVBoxLayout *master = new QVBoxLayout; fb[0]->setRange(0, 500); m_bypass = new QCheckBox; master->addWidget(m_bypass); m_bypass->setText("Bypass"); m_bypass->setStyleSheet("QCheckBox { border: 2px solid #2a0825;" "margin: 0px;" "background-color: #885074;" "font-size: 7px;}"); connect(m_bypass, SIGNAL(stateChanged(int)), this, SLOT(bypassChanged(int))); master->addWidget(fb[0]); layout->addLayout(master); for (int i = 1; i < 13;) { QVBoxLayout *filterLayout= new QVBoxLayout; for (int j = i; j < i + 3; j++) { if ((j - 1) % 3 == 0) fb[j]->setRange(0, 24000); else if ((i - 1) % 3 == 1) { fb[j]->setRange(0, 10); } else { fb[j]->setRange(-50, 50); } filterLayout->insertWidget(j, fb[j]); } filterLayout->setSpacing(0); filterLayout->setAlignment(Qt::AlignHCenter); filterLayout->setContentsMargins(0, 0, 0, 0); layout->addLayout(filterLayout); i += 3; } setLayout(layout); } void FilterBankWidget::setValue(int filter, int value) { double result = 0; int channel = filter + 9; if (channel == HP_FREQ) { result = double((value * 1.31) + 16.0f); // 16 - 350 } else if (channel == LOW_FREQ) { result = 30 + (value * 1.647); // 30 - 450 } else if (channel == LOW_Q) { result = (double)(value / 32.0f) + 0.1f; // 0.1 - 8 } else if (channel == LOW_GAIN) { result = (double)(value / 21.25f) - 6.023528412f; } else if (channel == MIDLOW_FREQ) { result = 200 + (value * 9.019607843); // 200 - 450 } else if (channel == MIDLOW_Q) { result = (double)( value / 64.0f) + 0.10; // 0.1 - 4 } else if (channel == MIDLOW_GAIN) { result = (double)(value / 7.0833333333333f) - 18.0f; } else if (channel == MIDHIGH_FREQ) { result = 600 + (value * 25.09803922); // 600 - 7000 } else if (channel == MIDHIGH_Q) { result = (double)( value / 64.0f) + 0.10; // 0.1 - 4 } else if (channel == MIDHIGH_GAIN) { result = (double)(value / 7.0833333333333f) - 18.0f; } else if (channel == HIGH_FREQ) { result = 1500 + (value * 56.8627451); // 1500 - 16000 } else if (channel == HIGH_Q) { result = (double)( value / 32.0f) + 0.1f; } else if (channel == HIGH_GAIN) { result = (double)(value / 21.25) - 6.023528412f; } fb[filter]->setValue(result); } void FilterBankWidget::bypassChanged(int value) { if (value == 0) emit setBypass(false); else emit setBypass(true); }