indicadores filtros Ui funcionando, sin interacción de usuario.

This commit is contained in:
snt 2024-05-15 17:50:21 +02:00
parent 8f321b9d69
commit 86567b8bef
16 changed files with 275 additions and 108 deletions

82
src/filterbankwidget.cpp Normal file
View file

@ -0,0 +1,82 @@
#include "filterbankwidget.h"
#include <QBoxLayout>
#include "dmxPersonality.h"
FilterBankWidget::FilterBankWidget(QWidget *parent)
: QWidget{parent}
{
QHBoxLayout *layout = new QHBoxLayout;
layout->setAlignment(Qt::AlignHCenter);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
this->setStyleSheet("border: 1px solid #5a4855;"
"margin: 0px;"
"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);
}
fb[0]->setRange(0, 500);
layout->insertWidget(0, fb[0]);
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);
fb[j]->setMinimum(-50);
fb[j]->setValue(-8);
}
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);
qDebug() << "filter " << filter << " " << result;
}