135 lines
4.5 KiB
C++
135 lines
4.5 KiB
C++
#include "audiowidget.h"
|
|
#include "dmxPersonality.h"
|
|
|
|
AudioWidget::AudioWidget(QWidget *parent) :
|
|
QWidget(parent)
|
|
, m_layout(new QHBoxLayout())
|
|
{
|
|
m_layers = Settings::getInstance()->getLayersNumber();
|
|
for (uint i= 0; i < m_layers; i++ ) {
|
|
AudioLayerWidget *alw = new AudioLayerWidget(this, i);
|
|
m_layout->insertWidget(i, alw);
|
|
connect(alw, SIGNAL(uiSliderChanged(int, Slider, int)), this, SIGNAL(uiSliderChanged(int, Slider, int)));
|
|
connect(alw, SIGNAL(uiPlaybackChanged(int, Status)), this, SIGNAL(uiPlaybackChanged(int, Status)));
|
|
connect(alw, SIGNAL(uiLoadMedia(int, QString)), this, SIGNAL(uiLoadMedia(int, QString)));
|
|
m_layerUpdate[i].status = Status::Iddle;
|
|
m_layerUpdate[i].duration = -1;
|
|
m_layerUpdate[i].media = "";
|
|
m_layerUpdate[i].vol = -1;
|
|
m_layerUpdate[i].pan = -1;
|
|
m_layerUpdate[i].pitch = -1;
|
|
m_layerUpdate[i].cursor = -1;
|
|
m_layerUpdate[i].level = 100;
|
|
for (int j = 0; j < FILTER_CHANNELS; j++)
|
|
m_filtersUpdate[i][j] = -1;
|
|
}
|
|
m_layout->setSpacing(0);
|
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
|
this->setStyleSheet("margin: 2px;");
|
|
setLayout(m_layout);
|
|
m_refreshUi = new QTimer(this);
|
|
connect(m_refreshUi, SIGNAL(timeout()), this, SLOT(refreshUi()));
|
|
m_refreshUi->start(UI_REFRESH_TIME * 1.5);
|
|
}
|
|
|
|
void AudioWidget::mediaLoaded(int layer, QString file, float duration)
|
|
{
|
|
m_layerUpdate[layer].media = file;
|
|
m_layerUpdate[layer].duration = duration;
|
|
m_layerUpdate[layer].updated = true;
|
|
}
|
|
|
|
void AudioWidget::volChanged(int layer, float vol) {
|
|
m_layerUpdate[layer].vol = vol;
|
|
m_layerUpdate[layer].updated = true;
|
|
}
|
|
|
|
void AudioWidget::panChanged(int layer, int pan) {
|
|
m_layerUpdate[layer].pan = pan;
|
|
m_layerUpdate[layer].updated = true;
|
|
}
|
|
|
|
void AudioWidget::pitchChanged(int layer, int pitch) {
|
|
|
|
m_layerUpdate[layer].pitch = pitch;
|
|
m_layerUpdate[layer].updated = true;
|
|
}
|
|
|
|
void AudioWidget::playbackChanged(int layer, Status status)
|
|
{
|
|
m_layerUpdate[layer].status = status;
|
|
m_layerUpdate[layer].updated = true;
|
|
}
|
|
|
|
void AudioWidget::cursorChanged(int layer, float cursor)
|
|
{
|
|
m_layerUpdate[layer].cursor = cursor;
|
|
m_layerUpdate[layer].updated = true;
|
|
}
|
|
|
|
void AudioWidget::refreshUi()
|
|
{
|
|
for (uint i = 0; i < m_layers; i++)
|
|
{
|
|
if (m_layerUpdate[i].updated) {
|
|
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);
|
|
m_layerUpdate[i].vol = -1;
|
|
}
|
|
if (m_layerUpdate[i].cursor > -1) {
|
|
alw->setCurrentTime(m_layerUpdate[i].cursor);
|
|
m_layerUpdate[i].cursor = -1;
|
|
}
|
|
if (m_layerUpdate[i].pan > -1) {
|
|
alw->setPan(m_layerUpdate[i].pan);
|
|
m_layerUpdate[i].pan = -1;
|
|
}
|
|
if (m_layerUpdate[i].pitch > -1) {
|
|
alw->setPitch(m_layerUpdate[i].pitch);
|
|
m_layerUpdate[i].pitch = -1;
|
|
}
|
|
if (m_layerUpdate[i].status != Status::Iddle) {
|
|
alw->setPlaybackStatus(m_layerUpdate[i].status);
|
|
m_layerUpdate[i].status = Status::Iddle;
|
|
}
|
|
if (m_layerUpdate[i].duration > -1) {
|
|
alw->setMediaFile(m_layerUpdate[i].media);
|
|
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;
|
|
}
|
|
if (m_layerUpdate[i].level < 100) {
|
|
alw->setLevel(m_layerUpdate[i].level);
|
|
m_layerUpdate[i].level = 100;
|
|
}
|
|
m_layerUpdate[i].updated = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
void AudioWidget::filterParamChanged(int layer, int channel, int value)
|
|
{
|
|
m_filtersUpdate[layer][channel - HP_FREQ] = value;
|
|
m_layerUpdate[layer].updated = true;
|
|
}
|
|
|
|
void AudioWidget::levelChanged(int layer, float db)
|
|
{
|
|
m_layerUpdate[layer].level = db;
|
|
m_layerUpdate[layer].updated = true;
|
|
}
|
|
|
|
void AudioWidget::busNameChanged(uint bus, char* name)
|
|
{
|
|
for (uint i = 0; i < m_layers; i++) {
|
|
QLayoutItem *item = m_layout->itemAt(i);
|
|
AudioLayerWidget *alw = dynamic_cast<AudioLayerWidget *>(item->widget());
|
|
alw->setBusName(bus, name);
|
|
}
|
|
}
|