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

View file

@ -2,8 +2,11 @@ TEMPLATE = app
TARGET = libremediaserver-audio TARGET = libremediaserver-audio
QT += webkitwidgets widgets QT += webkitwidgets widgets
HEADERS += src/libremediaserver-audio.h \ HEADERS += src/libremediaserver-audio.h \
src/clickabledoublespinbox.h \
src/clickablelabel.h \ src/clickablelabel.h \
src/clickableslider.h \
src/dmxwidget.h \ src/dmxwidget.h \
src/filterbankwidget.h \
src/libremediaserver-audio-gui.h \ src/libremediaserver-audio-gui.h \
src/main.h \ src/main.h \
src/miniaudio.h \ src/miniaudio.h \
@ -17,8 +20,11 @@ HEADERS += src/libremediaserver-audio.h \
src/settings.h \ src/settings.h \
src/slidergroup.h src/slidergroup.h
SOURCES += src/main.cpp \ SOURCES += src/main.cpp \
src/clickabledoublespinbox.cpp \
src/clickablelabel.cpp \ src/clickablelabel.cpp \
src/clickableslider.cpp \
src/dmxwidget.cpp \ src/dmxwidget.cpp \
src/filterbankwidget.cpp \
src/libremediaserver-audio-gui.cpp \ src/libremediaserver-audio-gui.cpp \
src/miniaudio.c \ src/miniaudio.c \
src/libremediaserver-audio.cpp \ src/libremediaserver-audio.cpp \

View file

@ -1,5 +1,7 @@
#include "audiolayerwidget.h" #include "audiolayerwidget.h"
#include <QComboBox>
#include <QBoxLayout>
#include <QFileDialog>
AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer): AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
QWidget(parent) QWidget(parent)
@ -21,7 +23,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
m_fileValue = new ClickableLabel; m_fileValue = new ClickableLabel;
connect(m_fileValue, SIGNAL(clicked()), this, SLOT(openMediaDialog())); connect(m_fileValue, SIGNAL(clicked()), this, SLOT(openMediaDialog()));
connect(m_folderValue, SIGNAL(clicked()), this, SLOT(openMediaDialog())); connect(m_folderValue, SIGNAL(clicked()), this, SLOT(openMediaDialog()));
m_fileValue->setMaximumWidth(160); m_fileValue->setMaximumWidth(300);
m_fileValue->setAlignment(Qt::AlignLeft); m_fileValue->setAlignment(Qt::AlignLeft);
m_fileValue->setStyleSheet( m_fileValue->setStyleSheet(
"color: white;" "color: white;"
@ -69,6 +71,10 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
status->addWidget(m_progressTime); status->addWidget(m_progressTime);
status->addWidget(m_totalTimeValue); status->addWidget(m_totalTimeValue);
layout->addLayout(status); layout->addLayout(status);
m_filterBank = new FilterBankWidget(this);
layout->addWidget(m_filterBank);
QVBoxLayout *volumeBox = new QVBoxLayout; QVBoxLayout *volumeBox = new QVBoxLayout;
m_pitch = new SliderGroup("Pitch", 0 , 255, 0, NULL); m_pitch = new SliderGroup("Pitch", 0 , 255, 0, NULL);
volumeBox->addWidget(m_pitch); volumeBox->addWidget(m_pitch);
@ -88,10 +94,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
this->setLayout(layout); this->setLayout(layout);
} }
AudioLayerWidget::~AudioLayerWidget() AudioLayerWidget::~AudioLayerWidget() {}
{
}
// From UI. // From UI.
void AudioLayerWidget::volumeChanged(int value) void AudioLayerWidget::volumeChanged(int value)
@ -209,3 +212,11 @@ void AudioLayerWidget::setCurrentTime(float progress)
m_progress->blockSignals(false); m_progress->blockSignals(false);
m_progressTime->blockSignals(false); m_progressTime->blockSignals(false);
} }
void AudioLayerWidget::setFilterParam(int channel, int value)
{
m_filterBank->blockSignals(true);
m_filterBank->setValue(channel, value);
m_filterBank->blockSignals(false);
}

View file

@ -3,14 +3,13 @@
#include <QPushButton> #include <QPushButton>
#include <QTimeEdit> #include <QTimeEdit>
#include <QFileDialog>
#include <QProgressBar> #include <QProgressBar>
#include "defines.h" #include "defines.h"
#include "slidergroup.h" #include "slidergroup.h"
#include "clickablelabel.h" #include "clickablelabel.h"
#include "settings.h" #include "settings.h"
#include "filterbankwidget.h"
class AudioLayerWidget : public QWidget class AudioLayerWidget : public QWidget
{ {
@ -20,6 +19,16 @@ public:
explicit AudioLayerWidget(QWidget *parent = 0, int layer = 0); explicit AudioLayerWidget(QWidget *parent = 0, int layer = 0);
~AudioLayerWidget(); ~AudioLayerWidget();
// From OLA -> LibreMediaServer -> AudioWidget
void setMediaFile(QString file);
void setDuration(float dur);
void setCurrentTime(float progress);
void setPlaybackStatus(Status status);
void setVol(float vol);
void setPan(int pan);
void setPitch(int pitch);
void setFilterParam(int channel, int value);
private: private:
Status m_status; Status m_status;
Status m_oldStatus; Status m_oldStatus;
@ -33,16 +42,9 @@ private:
QTimeEdit *m_progressTime; QTimeEdit *m_progressTime;
QTimeEdit *m_totalTimeValue; QTimeEdit *m_totalTimeValue;
QProgressBar *m_progress; QProgressBar *m_progress;
FilterBankWidget *m_filterBank;
// From DMX //public slots:
public slots:
void setMediaFile(QString file);
void setDuration(float dur);
void setCurrentTime(float progress);
void setPlaybackStatus(Status status);
void setVol(float vol);
void setPan(int pan);
void setPitch(int pitch);
// From Ui // From Ui
private slots: private slots:

View file

@ -1,5 +1,6 @@
#include "audiowidget.h" #include "audiowidget.h"
#include <cmath>
//#include <cmath>
AudioWidget::AudioWidget(QWidget *parent) : AudioWidget::AudioWidget(QWidget *parent) :
QWidget(parent) QWidget(parent)
@ -19,6 +20,8 @@ AudioWidget::AudioWidget(QWidget *parent) :
m_layerUpdate[i].pan = 128; m_layerUpdate[i].pan = 128;
m_layerUpdate[i].pitch = 128; m_layerUpdate[i].pitch = 128;
m_layerUpdate[i].cursor = 0; m_layerUpdate[i].cursor = 0;
for (int j = 0; j < FILTER_CHANNELS; j++)
m_filtersUpdate[i][j] = -1;
} }
m_layout->setSpacing(0); m_layout->setSpacing(0);
m_layout->setContentsMargins(1, 1, 1, 1); m_layout->setContentsMargins(1, 1, 1, 1);
@ -68,7 +71,7 @@ void AudioWidget::refreshUi()
for (uint i = 0; i < m_layers; i++) for (uint i = 0; i < m_layers; i++)
{ {
if (m_layerUpdate[i].updated) { if (m_layerUpdate[i].updated) {
QLayoutItem * const item = m_layout->itemAt(i); QLayoutItem *item = m_layout->itemAt(i);
AudioLayerWidget *alw = dynamic_cast<AudioLayerWidget *>(item->widget()); AudioLayerWidget *alw = dynamic_cast<AudioLayerWidget *>(item->widget());
if (m_layerUpdate[i].vol > -1) { if (m_layerUpdate[i].vol > -1) {
alw->setVol(m_layerUpdate[i].vol); alw->setVol(m_layerUpdate[i].vol);
@ -95,7 +98,18 @@ void AudioWidget::refreshUi()
alw->setDuration(m_layerUpdate[i].duration); alw->setDuration(m_layerUpdate[i].duration);
m_layerUpdate[i].duration = -1; m_layerUpdate[i].duration = -1;
} }
for (int j = 0; j < FILTER_CHANNELS; j++) {
if (m_filtersUpdate[i][j] > -1)
alw->setFilterParam(j, m_filtersUpdate[i][j]);
m_filtersUpdate[i][j] = -1;
}
m_layerUpdate[i].updated = false; m_layerUpdate[i].updated = false;
} }
} }
} }
void AudioWidget::filterParamChanged(int layer, int channel, int value)
{
m_filtersUpdate[layer][channel - 9] = value;
m_layerUpdate[layer].updated = true;
}

View file

@ -2,6 +2,7 @@
#define AUDIOWIDGET_H #define AUDIOWIDGET_H
#include <QTimer> #include <QTimer>
#include <QBoxLayout>
#include "audiolayerwidget.h" #include "audiolayerwidget.h"
#include "settings.h" #include "settings.h"
@ -13,12 +14,14 @@ class AudioWidget : public QWidget
public: public:
AudioWidget(QWidget *parent = nullptr); AudioWidget(QWidget *parent = nullptr);
void filterParamChanged(int layer, int channel, int value);
private: private:
QHBoxLayout *m_layout; QHBoxLayout *m_layout;
layerData m_layerUpdate[MAX_LAYERS]; layerData m_layerUpdate[MAX_LAYERS];
QTimer *m_refreshUi; QTimer *m_refreshUi;
uint m_layers; uint m_layers;
int m_filtersUpdate[MAX_LAYERS][FILTER_CHANNELS];
public slots: public slots:
void volChanged(int layer, float vol); void volChanged(int layer, float vol);

View file

@ -0,0 +1,21 @@
#include "clickabledoublespinbox.h"
#include <QVBoxLayout>
ClickableDoubleSpinBox::ClickableDoubleSpinBox(QWidget *parent)
: QDoubleSpinBox(parent)
{
setFocusPolicy(Qt::NoFocus);
setButtonSymbols(QAbstractSpinBox::NoButtons);
setValue(-1);
setDecimals(1);
setAlignment(Qt::AlignHCenter);
setContentsMargins(0, 0, 0, 0);
setMaximumWidth(50);
this->setStyleSheet("border: 0px solid #5a4855;"
"width: 50px;"
"margin: 0px;"
"background-color: #383034;"
);
}

View file

@ -0,0 +1,25 @@
#ifndef CLICKABLEDOUBLESPINBOX_H
#define CLICKABLEDOUBLESPINBOX_H
#include <QWidget>
#include <QDoubleSpinBox>
#include <QMouseEvent>
#include <QDebug>
class ClickableDoubleSpinBox : public QDoubleSpinBox
{
Q_OBJECT
public:
explicit ClickableDoubleSpinBox(QWidget *parent = nullptr);
protected:
void mousePressEvent ( QMouseEvent * event ) {
if (event->button() == Qt::LeftButton) {
emit click();
}
event->accept();
}
signals:
void click();
};
#endif // CLICKABLEDOUBLESPINBOX_H

3
src/clickableslider.cpp Normal file
View file

@ -0,0 +1,3 @@
#include "clickableslider.h"
ClickableSlider::ClickableSlider(QWidget *parent) : QSlider{parent} {}

30
src/clickableslider.h Normal file
View file

@ -0,0 +1,30 @@
#ifndef CLICKABLESLIDER_H
#define CLICKABLESLIDER_H
#include <QSlider>
#include <QEvent>
#include <QMouseEvent>
#include <QDebug>
class ClickableSlider : public QSlider
{
Q_OBJECT
public:
ClickableSlider(QWidget *parent = nullptr);
protected:
void mousePressEvent ( QMouseEvent * event )
{
if (event->button() == Qt::RightButton)
{
if (this->isEnabled()) {
qDebug() << "disabling slider";
this->setDisabled(true);
}
event->accept();
}
QSlider::mousePressEvent(event);
}
};
#endif // CLICKABLESLIDER_H

View file

@ -9,6 +9,7 @@
#define MAX_AUDIODEVICES 8 #define MAX_AUDIODEVICES 8
#define UI_REFRESH_TIME 100 #define UI_REFRESH_TIME 100
#define FADE_TIME 25 // DMX Frame time, 40 fps, avoid clicks #define FADE_TIME 25 // DMX Frame time, 40 fps, avoid clicks
#define FILTER_CHANNELS 13 // number of dmx channels dedicated to filters by layer
struct dmxSetting { struct dmxSetting {
int address; int address;

View file

@ -27,4 +27,24 @@
#define SEND2 23 #define SEND2 23
#define LAYER_CHANNELS 24 #define LAYER_CHANNELS 24
constexpr const char* dmxChannelToString(int e) noexcept
{
switch (e) {
case HP_FREQ: return "High Pass Cutoff Frec";
case LOW_FREQ: return "Low Cutoff Frec";
case LOW_Q: return "Low Slope";
case LOW_GAIN: return "Low Gain";
case MIDLOW_FREQ: return "Mid Low Frec";
case MIDLOW_Q: return "Mid Low Q";
case MIDLOW_GAIN: return "Mid Low Gain";
case MIDHIGH_FREQ: return "Mid High Frec";
case MIDHIGH_Q: return "Mid High Q";
case MIDHIGH_GAIN: return "Mid High Gain";
case HIGH_FREQ: return "High Cutoff Frec";
case HIGH_Q: return "High Slope";
case HIGH_GAIN: return "High Gain";
default: return "++--++--++";
}
}
#endif // DMXPERSONALITY_H #endif // DMXPERSONALITY_H

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;
}

22
src/filterbankwidget.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef FILTERBANKWIDGET_H
#define FILTERBANKWIDGET_H
#include <QObject>
#include <QWidget>
#include "clickabledoublespinbox.h"
class FilterBankWidget : public QWidget
{
Q_OBJECT
public:
explicit FilterBankWidget(QWidget *parent = nullptr);
ClickableDoubleSpinBox *fb[13];
void setValue(int filter, int value);
signals:
};
#endif // FILTERBANKWIDGET_H

View file

@ -142,6 +142,13 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
#endif #endif
} else if (channel >= HP_FREQ && channel <= HIGH_GAIN) { } else if (channel >= HP_FREQ && channel <= HIGH_GAIN) {
m_mae.filterParamChanged(layer, m_dmxSettings.at(layer).audioDevice, channel, value); m_mae.filterParamChanged(layer, m_dmxSettings.at(layer).audioDevice, channel, value);
#ifndef NOGUI
if (m_ui) {
m_lmsUi->m_aw->filterParamChanged(layer, channel, value);
m_played.clear();
m_played.append(m_ola->getValue(layer, DMX_FILE));
}
#endif
} }
} }
#ifndef NOGUI #ifndef NOGUI

View file

@ -1,16 +1,7 @@
#include "slidergroup.h" #include "slidergroup.h"
#include <QCursor>
#include <QStyle>
DoubleSpinBoxClickable::DoubleSpinBoxClickable(QWidget *parent) #include <QWidget>
: QDoubleSpinBox{parent} {} #include <QVBoxLayout>
DoubleSpinBoxClickable::~DoubleSpinBoxClickable() {}
SliderClickDisable::SliderClickDisable(QWidget *parent)
: QSlider{parent} {}
SliderClickDisable::~SliderClickDisable() {}
SliderGroup::SliderGroup(QString name, SliderGroup::SliderGroup(QString name,
int min, int min,
@ -56,7 +47,7 @@ SliderGroup::SliderGroup(QString name,
valueBox.setAlignment(Qt::AlignHCenter); valueBox.setAlignment(Qt::AlignHCenter);
valueBox.setContentsMargins(0, 0, 0, 0); valueBox.setContentsMargins(0, 0, 0, 0);
connect(&slider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int))); connect(&slider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
connect(&valueBox, SIGNAL(enableSlider()), this, SLOT(enableSlider())); connect(&valueBox, SIGNAL(click()), this, SLOT(enableSlider()));
layout->addWidget(&slider); layout->addWidget(&slider);
layout->addWidget(&valueBox); layout->addWidget(&valueBox);
this->setStyleSheet("border: 1px solid #5a4855;" this->setStyleSheet("border: 1px solid #5a4855;"

View file

@ -1,87 +1,16 @@
#ifndef SLIDERGROUP_H #ifndef SLIDERGROUP_H
#define SLIDERGROUP_H #define SLIDERGROUP_H
#include <QGroupBox> #include <QObject>
#include <QDoubleSpinBox> #include <QWidget>
#include <QVBoxLayout>
#include <QSlider>
#include <QDebug> #include <QDebug>
#include <QEvent>
#include <QMouseEvent>
/*
//slider->installEventFilter(new QSliderAnalyser);
class QSliderAnalyser
: public QObject
{
public:
QSliderAnalyser()
{
}
virtual ~QSliderAnalyser() #include "clickabledoublespinbox.h"
{ #include "clickableslider.h"
}
protected:
bool eventFilter(QObject* object, QEvent* event) override
{
if (event->type() == QEvent::MouseButtonPress) {
qDebug() << event->type() << object->objectName();
}
return QObject::eventFilter(object, event);
}
};*/
class DoubleSpinBoxClickable: public QDoubleSpinBox
{
Q_OBJECT
public:
DoubleSpinBoxClickable(QWidget *parent = 0);
~DoubleSpinBoxClickable();
signals:
void enableSlider();
protected:
void mousePressEvent ( QMouseEvent * event )
{
if (event->button() == Qt::LeftButton) {
qDebug() << "enabling slider";
emit(enableSlider());
}
event->accept();
}
};
class SliderClickDisable
: public QSlider
{
Q_OBJECT
public:
explicit SliderClickDisable(QWidget *parent = Q_NULLPTR);
~SliderClickDisable();
protected:
void mousePressEvent ( QMouseEvent * event )
{
if (event->button() == Qt::RightButton)
{
if (this->isEnabled()) {
qDebug() << "disabling slider";
this->setDisabled(true);
}
event->accept();
}
QSlider::mousePressEvent(event);
}
};
class SliderGroup : public QWidget class SliderGroup : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
SliderGroup(QString name, SliderGroup(QString name,
int min, int min,
@ -97,8 +26,8 @@ public slots:
void sliderValueChanged(int value); void sliderValueChanged(int value);
private: private:
SliderClickDisable slider; ClickableSlider slider;
DoubleSpinBoxClickable valueBox; ClickableDoubleSpinBox valueBox;
private slots: private slots:
void enableSlider() { slider.setEnabled(true); } void enableSlider() { slider.setEnabled(true); }