true bypass en filterBank
This commit is contained in:
parent
d94f874259
commit
27c7969df3
8 changed files with 65 additions and 4 deletions
|
@ -72,6 +72,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
||||||
layout->addLayout(status);
|
layout->addLayout(status);
|
||||||
|
|
||||||
m_filterBank = new FilterBankWidget(this);
|
m_filterBank = new FilterBankWidget(this);
|
||||||
|
connect(m_filterBank, SIGNAL(setBypass(bool)), this, SLOT(setBypass(bool)));
|
||||||
layout->addWidget(m_filterBank);
|
layout->addWidget(m_filterBank);
|
||||||
|
|
||||||
QVBoxLayout *volumeBox = new QVBoxLayout;
|
QVBoxLayout *volumeBox = new QVBoxLayout;
|
||||||
|
@ -111,6 +112,12 @@ void AudioLayerWidget::pitchChanged(int value)
|
||||||
emit(uiSliderChanged(m_layer, Slider::Pitch, value));
|
emit(uiSliderChanged(m_layer, Slider::Pitch, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioLayerWidget::setBypass(bool value)
|
||||||
|
{
|
||||||
|
emit(uiSliderChanged(m_layer, Slider::Bypass, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AudioLayerWidget::toggleSuspendResume()
|
void AudioLayerWidget::toggleSuspendResume()
|
||||||
{
|
{
|
||||||
switch (m_status) {
|
switch (m_status) {
|
||||||
|
|
|
@ -53,6 +53,7 @@ private slots:
|
||||||
void volumeChanged(int vol);
|
void volumeChanged(int vol);
|
||||||
void panChanged(int pan);
|
void panChanged(int pan);
|
||||||
void pitchChanged(int pitch);
|
void pitchChanged(int pitch);
|
||||||
|
void setBypass(bool value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void uiPlaybackChanged(int layer, Status s);
|
void uiPlaybackChanged(int layer, Status s);
|
||||||
|
|
|
@ -64,6 +64,7 @@ enum Slider
|
||||||
Volume,
|
Volume,
|
||||||
Pan,
|
Pan,
|
||||||
Pitch,
|
Pitch,
|
||||||
|
Bypass
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
|
@ -22,8 +22,13 @@ FilterBankWidget::FilterBankWidget(QWidget *parent)
|
||||||
fb[i]->setObjectName(name);
|
fb[i]->setObjectName(name);
|
||||||
fb[i]->setToolTip(name);
|
fb[i]->setToolTip(name);
|
||||||
}
|
}
|
||||||
|
QVBoxLayout *master = new QVBoxLayout;
|
||||||
fb[0]->setRange(0, 500);
|
fb[0]->setRange(0, 500);
|
||||||
layout->insertWidget(0, fb[0]);
|
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;) {
|
for (int i = 1; i < 13;) {
|
||||||
QVBoxLayout *filterLayout= new QVBoxLayout;
|
QVBoxLayout *filterLayout= new QVBoxLayout;
|
||||||
for (int j = i; j < i + 3; j++) {
|
for (int j = i; j < i + 3; j++) {
|
||||||
|
@ -79,3 +84,11 @@ void FilterBankWidget::setValue(int filter, int value)
|
||||||
}
|
}
|
||||||
fb[filter]->setValue(result);
|
fb[filter]->setValue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FilterBankWidget::bypassChanged(int value)
|
||||||
|
{
|
||||||
|
if (value == 0)
|
||||||
|
emit setBypass(false);
|
||||||
|
else
|
||||||
|
emit setBypass(true);
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QCheckBox>
|
||||||
#include "clickabledoublespinbox.h"
|
#include "clickabledoublespinbox.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,11 +13,14 @@ class FilterBankWidget : public QWidget
|
||||||
public:
|
public:
|
||||||
explicit FilterBankWidget(QWidget *parent = nullptr);
|
explicit FilterBankWidget(QWidget *parent = nullptr);
|
||||||
ClickableDoubleSpinBox *fb[13];
|
ClickableDoubleSpinBox *fb[13];
|
||||||
|
QCheckBox *m_bypass;
|
||||||
void setValue(int filter, int value);
|
void setValue(int filter, int value);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void bypassChanged(int value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void setBypass(bool value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILTERBANKWIDGET_H
|
#endif // FILTERBANKWIDGET_H
|
||||||
|
|
|
@ -249,6 +249,8 @@ void libreMediaServerAudio::uiSliderChanged(int layer, Slider s, int value)
|
||||||
case Slider::Pitch:
|
case Slider::Pitch:
|
||||||
m_mae.pitchChanged(layer, value);
|
m_mae.pitchChanged(layer, value);
|
||||||
break;
|
break;
|
||||||
|
case Slider::Bypass:
|
||||||
|
m_mae.setBypass(m_dmxSettings.at(layer).audioDevice, layer, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,13 @@ ma_result MiniAudioEngine::createFilterBank(int id, uint layer)
|
||||||
ma_node *endpoint = ma_engine_get_endpoint(&m_engine[id]);
|
ma_node *endpoint = ma_engine_get_endpoint(&m_engine[id]);
|
||||||
filterBank *fb = &m_filterBank[id][layer];
|
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);
|
fb->hpfConfig = ma_hpf_node_config_init(CHANNELS, SAMPLE_RATE, 16, FILTER_ORDER);
|
||||||
result = ma_hpf_node_init(ng, &fb->hpfConfig, NULL, &fb->hpf);
|
result = ma_hpf_node_init(ng, &fb->hpfConfig, NULL, &fb->hpf);
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
|
@ -100,13 +107,23 @@ ma_result MiniAudioEngine::createFilterBank(int id, uint layer)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ma_splitter_node_config splitterConfig = ma_splitter_node_config_init(CHANNELS);
|
|
||||||
result = ma_splitter_node_init(ng, &splitterConfig, NULL, &fb->output);
|
result = ma_splitter_node_init(ng, &splitterConfig, NULL, &fb->output);
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
cout << "ERROR " << result << ": Failed to initialize output node." << endl;
|
cout << "ERROR " << result << ": Failed to initialize output node." << endl;
|
||||||
return result;
|
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);
|
result = ma_node_attach_output_bus(&fb->hpf, 0, &fb->loshelf, 0);
|
||||||
if (result != MA_SUCCESS) {
|
if (result != MA_SUCCESS) {
|
||||||
cout << "ERROR " << result << ": Failed to attach high pass pass filter node." << endl;
|
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;
|
cout << "Error " << result << ": Failed to load file " << file << endl;
|
||||||
return result;
|
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) {
|
if (result != MA_SUCCESS) {
|
||||||
cout << "Error " << result << ": Failed to attach output bus " << audioDevice << endl;
|
cout << "Error " << result << ": Failed to attach output bus " << audioDevice << endl;
|
||||||
//return result;
|
//return result;
|
||||||
|
@ -526,3 +543,17 @@ ma_result MiniAudioEngine::filterParamChanged(int layer, int audioDevice, int ch
|
||||||
}
|
}
|
||||||
return (result);
|
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
|
typedef struct
|
||||||
{
|
{
|
||||||
|
ma_splitter_node input;
|
||||||
ma_hpf_node hpf;
|
ma_hpf_node hpf;
|
||||||
ma_hpf_node_config hpfConfig;
|
ma_hpf_node_config hpfConfig;
|
||||||
ma_loshelf_node loshelf;
|
ma_loshelf_node loshelf;
|
||||||
|
@ -43,6 +44,7 @@ public:
|
||||||
bool startEngine(uint layersQty);
|
bool startEngine(uint layersQty);
|
||||||
bool startDevice(uint *id, uint nb);
|
bool startDevice(uint *id, uint nb);
|
||||||
static void audioDataCallback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
|
static void audioDataCallback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
|
||||||
|
bool setBypass(int audioDevice, int layer, bool bypass);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ma_result loadMedia(int layer, char *media, uint audioDevice);
|
ma_result loadMedia(int layer, char *media, uint audioDevice);
|
||||||
|
|
Loading…
Add table
Reference in a new issue