Compare commits
5 commits
7bc339dfe3
...
27c7969df3
Author | SHA1 | Date | |
---|---|---|---|
|
27c7969df3 | ||
|
d94f874259 | ||
|
14ac167dfb | ||
|
86567b8bef | ||
|
8f321b9d69 |
18 changed files with 366 additions and 119 deletions
|
@ -2,8 +2,11 @@ TEMPLATE = app
|
|||
TARGET = libremediaserver-audio
|
||||
QT += webkitwidgets widgets
|
||||
HEADERS += src/libremediaserver-audio.h \
|
||||
src/clickabledoublespinbox.h \
|
||||
src/clickablelabel.h \
|
||||
src/clickableslider.h \
|
||||
src/dmxwidget.h \
|
||||
src/filterbankwidget.h \
|
||||
src/libremediaserver-audio-gui.h \
|
||||
src/main.h \
|
||||
src/miniaudio.h \
|
||||
|
@ -17,8 +20,11 @@ HEADERS += src/libremediaserver-audio.h \
|
|||
src/settings.h \
|
||||
src/slidergroup.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/clickabledoublespinbox.cpp \
|
||||
src/clickablelabel.cpp \
|
||||
src/clickableslider.cpp \
|
||||
src/dmxwidget.cpp \
|
||||
src/filterbankwidget.cpp \
|
||||
src/libremediaserver-audio-gui.cpp \
|
||||
src/miniaudio.c \
|
||||
src/libremediaserver-audio.cpp \
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
#include "audiolayerwidget.h"
|
||||
#include <QComboBox>
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QFileDialog>
|
||||
|
||||
AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
||||
QWidget(parent)
|
||||
, m_oldStatus(Status::PlayingLoop)
|
||||
, m_layer(layer)
|
||||
, m_suspendResumeButton(0)
|
||||
{
|
||||
|
@ -10,7 +13,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
|||
|
||||
QVBoxLayout *playback = new QVBoxLayout;
|
||||
m_folderValue = new ClickableLabel;
|
||||
m_folderValue->setMaximumWidth(160);
|
||||
m_folderValue->setMaximumWidth(300);
|
||||
m_folderValue->setAlignment(Qt::AlignLeft);
|
||||
m_folderValue->setStyleSheet(
|
||||
"color: white;"
|
||||
|
@ -20,7 +23,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
|||
m_fileValue = new ClickableLabel;
|
||||
connect(m_fileValue, 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->setStyleSheet(
|
||||
"color: white;"
|
||||
|
@ -32,7 +35,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
|||
layout->addLayout(playback);
|
||||
|
||||
m_suspendResumeButton = new QPushButton(this);
|
||||
m_suspendResumeButton->setText(StatusStr[Status::Iddle]);
|
||||
m_suspendResumeButton->setText(statusToString(Status::Iddle));
|
||||
connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspendResume()));
|
||||
layout->addWidget(m_suspendResumeButton);
|
||||
|
||||
|
@ -50,7 +53,6 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
|||
m_progressTime->setReadOnly(true);
|
||||
m_progressTime->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||
m_progressTime->setMinimumWidth(80);
|
||||
//m_progressTime->setMaximumWidth(80);
|
||||
m_progressTime->setFocusPolicy(Qt::NoFocus);
|
||||
m_progressTime->setAlignment(Qt::AlignHCenter);
|
||||
m_progressTime->setContentsMargins(0,0,0,0);
|
||||
|
@ -68,6 +70,11 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
|||
status->addWidget(m_progressTime);
|
||||
status->addWidget(m_totalTimeValue);
|
||||
layout->addLayout(status);
|
||||
|
||||
m_filterBank = new FilterBankWidget(this);
|
||||
connect(m_filterBank, SIGNAL(setBypass(bool)), this, SLOT(setBypass(bool)));
|
||||
layout->addWidget(m_filterBank);
|
||||
|
||||
QVBoxLayout *volumeBox = new QVBoxLayout;
|
||||
m_pitch = new SliderGroup("Pitch", 0 , 255, 0, NULL);
|
||||
volumeBox->addWidget(m_pitch);
|
||||
|
@ -87,10 +94,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
|||
this->setLayout(layout);
|
||||
}
|
||||
|
||||
AudioLayerWidget::~AudioLayerWidget()
|
||||
{
|
||||
|
||||
}
|
||||
AudioLayerWidget::~AudioLayerWidget() {}
|
||||
|
||||
// From UI.
|
||||
void AudioLayerWidget::volumeChanged(int value)
|
||||
|
@ -108,6 +112,12 @@ void AudioLayerWidget::pitchChanged(int value)
|
|||
emit(uiSliderChanged(m_layer, Slider::Pitch, value));
|
||||
}
|
||||
|
||||
void AudioLayerWidget::setBypass(bool value)
|
||||
{
|
||||
emit(uiSliderChanged(m_layer, Slider::Bypass, value));
|
||||
}
|
||||
|
||||
|
||||
void AudioLayerWidget::toggleSuspendResume()
|
||||
{
|
||||
switch (m_status) {
|
||||
|
@ -180,7 +190,7 @@ void AudioLayerWidget::setPlaybackStatus(Status s)
|
|||
{
|
||||
m_suspendResumeButton->blockSignals(true);
|
||||
m_status = s;
|
||||
m_suspendResumeButton->setText(StatusStr[s]);
|
||||
m_suspendResumeButton->setText(statusToString(s));
|
||||
m_suspendResumeButton->blockSignals(false);
|
||||
}
|
||||
|
||||
|
@ -208,3 +218,11 @@ void AudioLayerWidget::setCurrentTime(float progress)
|
|||
m_progress->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);
|
||||
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
#include <QPushButton>
|
||||
#include <QTimeEdit>
|
||||
#include <QFileDialog>
|
||||
#include <QProgressBar>
|
||||
|
||||
#include "defines.h"
|
||||
#include "slidergroup.h"
|
||||
#include "clickablelabel.h"
|
||||
#include "settings.h"
|
||||
#include "filterbankwidget.h"
|
||||
|
||||
class AudioLayerWidget : public QWidget
|
||||
{
|
||||
|
@ -19,6 +19,16 @@ public:
|
|||
explicit AudioLayerWidget(QWidget *parent = 0, int layer = 0);
|
||||
~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:
|
||||
Status m_status;
|
||||
Status m_oldStatus;
|
||||
|
@ -32,16 +42,9 @@ private:
|
|||
QTimeEdit *m_progressTime;
|
||||
QTimeEdit *m_totalTimeValue;
|
||||
QProgressBar *m_progress;
|
||||
FilterBankWidget *m_filterBank;
|
||||
|
||||
// From DMX
|
||||
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);
|
||||
//public slots:
|
||||
|
||||
// From Ui
|
||||
private slots:
|
||||
|
@ -50,6 +53,7 @@ private slots:
|
|||
void volumeChanged(int vol);
|
||||
void panChanged(int pan);
|
||||
void pitchChanged(int pitch);
|
||||
void setBypass(bool value);
|
||||
|
||||
signals:
|
||||
void uiPlaybackChanged(int layer, Status s);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "audiowidget.h"
|
||||
#include <cmath>
|
||||
|
||||
//#include <cmath>
|
||||
|
||||
AudioWidget::AudioWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
|
@ -19,6 +20,8 @@ AudioWidget::AudioWidget(QWidget *parent) :
|
|||
m_layerUpdate[i].pan = 128;
|
||||
m_layerUpdate[i].pitch = 128;
|
||||
m_layerUpdate[i].cursor = 0;
|
||||
for (int j = 0; j < FILTER_CHANNELS; j++)
|
||||
m_filtersUpdate[i][j] = -1;
|
||||
}
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setContentsMargins(1, 1, 1, 1);
|
||||
|
@ -68,7 +71,7 @@ void AudioWidget::refreshUi()
|
|||
for (uint i = 0; i < m_layers; i++)
|
||||
{
|
||||
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());
|
||||
if (m_layerUpdate[i].vol > -1) {
|
||||
alw->setVol(m_layerUpdate[i].vol);
|
||||
|
@ -95,7 +98,18 @@ void AudioWidget::refreshUi()
|
|||
alw->setDuration(m_layerUpdate[i].duration);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioWidget::filterParamChanged(int layer, int channel, int value)
|
||||
{
|
||||
m_filtersUpdate[layer][channel - 9] = value;
|
||||
m_layerUpdate[layer].updated = true;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define AUDIOWIDGET_H
|
||||
|
||||
#include <QTimer>
|
||||
#include <QBoxLayout>
|
||||
|
||||
#include "audiolayerwidget.h"
|
||||
#include "settings.h"
|
||||
|
@ -13,12 +14,14 @@ class AudioWidget : public QWidget
|
|||
|
||||
public:
|
||||
AudioWidget(QWidget *parent = nullptr);
|
||||
void filterParamChanged(int layer, int channel, int value);
|
||||
|
||||
private:
|
||||
QHBoxLayout *m_layout;
|
||||
layerData m_layerUpdate[MAX_LAYERS];
|
||||
QTimer *m_refreshUi;
|
||||
uint m_layers;
|
||||
int m_filtersUpdate[MAX_LAYERS][FILTER_CHANNELS];
|
||||
|
||||
public slots:
|
||||
void volChanged(int layer, float vol);
|
||||
|
|
21
src/clickabledoublespinbox.cpp
Normal file
21
src/clickabledoublespinbox.cpp
Normal 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;"
|
||||
);
|
||||
}
|
||||
|
25
src/clickabledoublespinbox.h
Normal file
25
src/clickabledoublespinbox.h
Normal 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
3
src/clickableslider.cpp
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include "clickableslider.h"
|
||||
|
||||
ClickableSlider::ClickableSlider(QWidget *parent) : QSlider{parent} {}
|
30
src/clickableslider.h
Normal file
30
src/clickableslider.h
Normal 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
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef DEFINES_H
|
||||
#define DEFINES_H
|
||||
|
||||
#define VERSION "LibreMediaServerAudio 0.2.0 Antigona Release"
|
||||
#define VERSION "LibreMediaServerAudio v0.2.0 Antigona"
|
||||
#define COPYRIGHT "(C) 2014-2024 Santi Noreña <lms@criptomart.net>"
|
||||
#define LICENSE "GPL 3 Licensed. See LICENSE.txt."
|
||||
#define DEFAULT_FILE "lms-audio.xlm"
|
||||
|
@ -9,6 +9,7 @@
|
|||
#define MAX_AUDIODEVICES 8
|
||||
#define UI_REFRESH_TIME 100
|
||||
#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 {
|
||||
int address;
|
||||
|
@ -17,7 +18,7 @@ struct dmxSetting {
|
|||
int audioDevice;
|
||||
};
|
||||
|
||||
enum Status
|
||||
enum class Status
|
||||
{
|
||||
Stopped,
|
||||
Paused,
|
||||
|
@ -29,6 +30,22 @@ enum Status
|
|||
PlayingFolderRandom
|
||||
};
|
||||
|
||||
constexpr const char* statusToString(Status e) noexcept
|
||||
{
|
||||
switch (e)
|
||||
{
|
||||
case Status::Stopped: return "Stop";
|
||||
case Status::Paused: return "Paused";
|
||||
case Status::PlayingOnce: return "Play 1";
|
||||
case Status::PlayingLoop: return "Play Loop";
|
||||
case Status::Iddle: return "Iddle";
|
||||
case Status::PlayingFolder: return "Play Folder";
|
||||
case Status::PlayingFolderLoop: return "Play Folder Loop";
|
||||
case Status::PlayingFolderRandom: return "Playing Folder Random";
|
||||
default: return "--++--";
|
||||
}
|
||||
}
|
||||
/*
|
||||
static const char* StatusStr[] =
|
||||
{
|
||||
"Stop",
|
||||
|
@ -40,13 +57,14 @@ static const char* StatusStr[] =
|
|||
"Play Folder Loop",
|
||||
"Play Folder Rand",
|
||||
0x0
|
||||
};
|
||||
};*/
|
||||
|
||||
enum Slider
|
||||
{
|
||||
Volume,
|
||||
Pan,
|
||||
Pitch,
|
||||
Bypass
|
||||
};
|
||||
|
||||
#include <QString>
|
||||
|
|
|
@ -27,4 +27,24 @@
|
|||
#define SEND2 23
|
||||
#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
|
||||
|
|
94
src/filterbankwidget.cpp
Normal file
94
src/filterbankwidget.cpp
Normal file
|
@ -0,0 +1,94 @@
|
|||
#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, 2, 0, 2);
|
||||
layout->setSpacing(0);
|
||||
this->setStyleSheet("border: 1px solid #5a4855;"
|
||||
"margin: 0px;"
|
||||
"margin-top: 2px;"
|
||||
"margin-bottom: 2px;"
|
||||
"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;
|
||||
connect(m_bypass, SIGNAL(stateChanged(int)), this, SLOT(bypassChanged(int)));
|
||||
master->addWidget(m_bypass);
|
||||
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);
|
||||
}
|
26
src/filterbankwidget.h
Normal file
26
src/filterbankwidget.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef FILTERBANKWIDGET_H
|
||||
#define FILTERBANKWIDGET_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QCheckBox>
|
||||
#include "clickabledoublespinbox.h"
|
||||
|
||||
|
||||
class FilterBankWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FilterBankWidget(QWidget *parent = nullptr);
|
||||
ClickableDoubleSpinBox *fb[13];
|
||||
QCheckBox *m_bypass;
|
||||
void setValue(int filter, int value);
|
||||
|
||||
private slots:
|
||||
void bypassChanged(int value);
|
||||
|
||||
signals:
|
||||
void setBypass(bool value);
|
||||
};
|
||||
|
||||
#endif // FILTERBANKWIDGET_H
|
|
@ -132,7 +132,7 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
|
|||
s = Status::PlayingFolderRandom;
|
||||
m_mae.playbackChanged(layer, s);
|
||||
m_currentStatus[layer] = s;
|
||||
qInfo() << "Layer" << layer << StatusStr[s];
|
||||
qInfo() << "Layer" << layer << statusToString(s);
|
||||
#ifndef NOGUI
|
||||
if (m_ui) {
|
||||
m_lmsUi->m_aw->playbackChanged(layer, s);
|
||||
|
@ -142,6 +142,13 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
|
|||
#endif
|
||||
} else if (channel >= HP_FREQ && channel <= HIGH_GAIN) {
|
||||
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
|
||||
|
@ -242,6 +249,8 @@ void libreMediaServerAudio::uiSliderChanged(int layer, Slider s, int value)
|
|||
case Slider::Pitch:
|
||||
m_mae.pitchChanged(layer, value);
|
||||
break;
|
||||
case Slider::Bypass:
|
||||
m_mae.setBypass(m_dmxSettings.at(layer).audioDevice, layer, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +262,7 @@ void libreMediaServerAudio::uiPlaybackChanged(int layer, Status s)
|
|||
if (result == MA_SUCCESS) {
|
||||
m_currentStatus[layer] = s;
|
||||
} else {
|
||||
qWarning() << "ui playback change error" << result << "status" << s << "layer" << layer;
|
||||
qWarning() << "ui playback change error " << result << " status " << statusToString(s) << "layer" << layer;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,13 @@ ma_result MiniAudioEngine::createFilterBank(int id, uint layer)
|
|||
ma_node *endpoint = ma_engine_get_endpoint(&m_engine[id]);
|
||||
filterBank *fb = &m_filterBank[id][layer];
|
||||
|
||||
ma_splitter_node_config splitterConfig = ma_splitter_node_config_init(CHANNELS);
|
||||
result = ma_splitter_node_init(ng, &splitterConfig, NULL, &fb->input);
|
||||
if (result != MA_SUCCESS) {
|
||||
cout << "ERROR " << result << ": Failed to initialize input node." << endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
fb->hpfConfig = ma_hpf_node_config_init(CHANNELS, SAMPLE_RATE, 16, FILTER_ORDER);
|
||||
result = ma_hpf_node_init(ng, &fb->hpfConfig, NULL, &fb->hpf);
|
||||
if (result != MA_SUCCESS) {
|
||||
|
@ -100,13 +107,23 @@ ma_result MiniAudioEngine::createFilterBank(int id, uint layer)
|
|||
return result;
|
||||
}
|
||||
|
||||
ma_splitter_node_config splitterConfig = ma_splitter_node_config_init(CHANNELS);
|
||||
result = ma_splitter_node_init(ng, &splitterConfig, NULL, &fb->output);
|
||||
if (result != MA_SUCCESS) {
|
||||
cout << "ERROR " << result << ": Failed to initialize output node." << endl;
|
||||
return result;
|
||||
}
|
||||
|
||||
result = ma_node_attach_output_bus(&fb->input, 0, &fb->hpf, 0);
|
||||
if (result != MA_SUCCESS) {
|
||||
cout << "ERROR " << result << ": Failed to attach input node." << endl;
|
||||
return result;
|
||||
}
|
||||
result = ma_node_attach_output_bus(&fb->input, 1, &fb->output, 0);
|
||||
if (result != MA_SUCCESS) {
|
||||
cout << "ERROR " << result << ": Failed to attach high pass pass filter node." << endl;
|
||||
return result;
|
||||
}
|
||||
ma_node_set_output_bus_volume(&fb->input, 1, 0.0f);
|
||||
result = ma_node_attach_output_bus(&fb->hpf, 0, &fb->loshelf, 0);
|
||||
if (result != MA_SUCCESS) {
|
||||
cout << "ERROR " << result << ": Failed to attach high pass pass filter node." << endl;
|
||||
|
@ -256,7 +273,7 @@ ma_result MiniAudioEngine::loadMedia(int layer, char *file, uint audioDevice)
|
|||
cout << "Error " << result << ": Failed to load file " << file << endl;
|
||||
return result;
|
||||
}
|
||||
result = ma_node_attach_output_bus(&m_currentSound[layer], 0, &m_filterBank[audioDevice][layer].hpf, 0);
|
||||
result = ma_node_attach_output_bus(&m_currentSound[layer], 0, &m_filterBank[audioDevice][layer].input, 0);
|
||||
if (result != MA_SUCCESS) {
|
||||
cout << "Error " << result << ": Failed to attach output bus " << audioDevice << endl;
|
||||
//return result;
|
||||
|
@ -376,7 +393,10 @@ ma_result MiniAudioEngine::playbackChanged(int layer, Status status)
|
|||
ma_sound_set_stop_time_in_milliseconds(&m_currentSound[layer], ~(ma_uint64)0);
|
||||
ma_sound_set_looping(&m_currentSound[layer], loop);
|
||||
result = ma_sound_start(&m_currentSound[layer]);
|
||||
//this->volChanged(layer, m_currentLayerValues[layer].vol); // glitch when seek to cursor, how flush the audio buffer?
|
||||
if (m_currentLayerValues[layer].cursor != 0) {
|
||||
usleep(1000 * 50); // Avoid small glitch at start, how to flush the cached buffers in audio pipe line?
|
||||
}
|
||||
this->volChanged(layer, m_currentLayerValues[layer].vol);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -523,3 +543,17 @@ ma_result MiniAudioEngine::filterParamChanged(int layer, int audioDevice, int ch
|
|||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
bool MiniAudioEngine::setBypass(int audioDevice, int layer, bool bypass)
|
||||
{
|
||||
filterBank *fb = &m_filterBank[audioDevice][layer];
|
||||
|
||||
if (bypass) {
|
||||
ma_node_set_output_bus_volume(&fb->input, 1, 1.0f);
|
||||
ma_node_set_output_bus_volume(&fb->input, 0, 0.0f);
|
||||
} else {
|
||||
ma_node_set_output_bus_volume(&fb->input, 1, 0.0f);
|
||||
ma_node_set_output_bus_volume(&fb->input, 0, 1.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ using namespace std;
|
|||
|
||||
typedef struct
|
||||
{
|
||||
ma_splitter_node input;
|
||||
ma_hpf_node hpf;
|
||||
ma_hpf_node_config hpfConfig;
|
||||
ma_loshelf_node loshelf;
|
||||
|
@ -43,6 +44,7 @@ public:
|
|||
bool startEngine(uint layersQty);
|
||||
bool startDevice(uint *id, uint nb);
|
||||
static void audioDataCallback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
|
||||
bool setBypass(int audioDevice, int layer, bool bypass);
|
||||
|
||||
protected:
|
||||
ma_result loadMedia(int layer, char *media, uint audioDevice);
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
#include "slidergroup.h"
|
||||
#include <QCursor>
|
||||
#include <QStyle>
|
||||
|
||||
DoubleSpinBoxClickable::DoubleSpinBoxClickable(QWidget *parent)
|
||||
: QDoubleSpinBox{parent} {}
|
||||
|
||||
DoubleSpinBoxClickable::~DoubleSpinBoxClickable() {}
|
||||
|
||||
SliderClickDisable::SliderClickDisable(QWidget *parent)
|
||||
: QSlider{parent} {}
|
||||
|
||||
SliderClickDisable::~SliderClickDisable() {}
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
SliderGroup::SliderGroup(QString name,
|
||||
int min,
|
||||
|
@ -56,7 +47,7 @@ SliderGroup::SliderGroup(QString name,
|
|||
valueBox.setAlignment(Qt::AlignHCenter);
|
||||
valueBox.setContentsMargins(0, 0, 0, 0);
|
||||
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(&valueBox);
|
||||
this->setStyleSheet("border: 1px solid #5a4855;"
|
||||
|
|
|
@ -1,87 +1,16 @@
|
|||
#ifndef SLIDERGROUP_H
|
||||
#define SLIDERGROUP_H
|
||||
|
||||
#include <QGroupBox>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QSlider>
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
/*
|
||||
//slider->installEventFilter(new QSliderAnalyser);
|
||||
class QSliderAnalyser
|
||||
: public QObject
|
||||
{
|
||||
public:
|
||||
QSliderAnalyser()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~QSliderAnalyser()
|
||||
{
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
#include "clickabledoublespinbox.h"
|
||||
#include "clickableslider.h"
|
||||
|
||||
class SliderGroup : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SliderGroup(QString name,
|
||||
int min,
|
||||
|
@ -97,8 +26,8 @@ public slots:
|
|||
void sliderValueChanged(int value);
|
||||
|
||||
private:
|
||||
SliderClickDisable slider;
|
||||
DoubleSpinBoxClickable valueBox;
|
||||
ClickableSlider slider;
|
||||
ClickableDoubleSpinBox valueBox;
|
||||
|
||||
private slots:
|
||||
void enableSlider() { slider.setEnabled(true); }
|
||||
|
|
Loading…
Add table
Reference in a new issue