wip acciones desde ui, la primera capa hace bien el pause pero el resto
no. sólo reciben datos las ptres primeras capas.
This commit is contained in:
parent
521f1fc6d7
commit
abf5d3340f
9 changed files with 76 additions and 30 deletions
|
@ -1,8 +1,9 @@
|
||||||
#include "audiolayerwidget.h"
|
#include "audiolayerwidget.h"
|
||||||
|
|
||||||
|
|
||||||
AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name, int layer):
|
||||||
QGroupBox(parent)
|
QGroupBox(parent)
|
||||||
|
, m_layer(layer)
|
||||||
, m_suspendResumeButton(0)
|
, m_suspendResumeButton(0)
|
||||||
, m_volumeIndicator(new QSpinBox)
|
, m_volumeIndicator(new QSpinBox)
|
||||||
, m_panIndicator(new QSpinBox)
|
, m_panIndicator(new QSpinBox)
|
||||||
|
@ -93,7 +94,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
m_progressTime->setDisplayFormat("h:mm:ss:zzz");
|
m_progressTime->setDisplayFormat("h:mm:ss:zzz");
|
||||||
m_progressTime->setReadOnly(true);
|
m_progressTime->setReadOnly(true);
|
||||||
m_progressTime->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
m_progressTime->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||||
m_progressTime->setMaximumWidth(120);
|
m_progressTime->setMaximumWidth(100);
|
||||||
progressTime->addWidget(m_progressTimeLabel);
|
progressTime->addWidget(m_progressTimeLabel);
|
||||||
progressTime->addWidget(m_progressTime);
|
progressTime->addWidget(m_progressTime);
|
||||||
m_totalTimeLabel = new QLabel;
|
m_totalTimeLabel = new QLabel;
|
||||||
|
@ -102,7 +103,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
m_totalTimeValue->setDisplayFormat("h:mm:ss:zzz");
|
m_totalTimeValue->setDisplayFormat("h:mm:ss:zzz");
|
||||||
m_totalTimeValue->setReadOnly(true);
|
m_totalTimeValue->setReadOnly(true);
|
||||||
m_totalTimeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
m_totalTimeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||||
m_totalTimeValue->setMaximumWidth(120);
|
m_totalTimeValue->setMaximumWidth(100);
|
||||||
progressTime->addWidget(m_totalTimeLabel);
|
progressTime->addWidget(m_totalTimeLabel);
|
||||||
progressTime->addWidget(m_totalTimeValue);
|
progressTime->addWidget(m_totalTimeValue);
|
||||||
layout->addLayout(progressTime);
|
layout->addLayout(progressTime);
|
||||||
|
@ -153,11 +154,14 @@ void AudioLayerWidget::toggleSuspendResume()
|
||||||
case Status::PlayingLoop:
|
case Status::PlayingLoop:
|
||||||
case Status::PlayingOnce:
|
case Status::PlayingOnce:
|
||||||
this->setPlaybackStatus(Status::Paused);
|
this->setPlaybackStatus(Status::Paused);
|
||||||
|
emit uiPlaybackChanged(m_layer, Status::Paused);
|
||||||
|
break;
|
||||||
case Status::Paused:
|
case Status::Paused:
|
||||||
case Status::Stopped:
|
case Status::Stopped:
|
||||||
this->setPlaybackStatus(Status::PlayingOnce);
|
this->setPlaybackStatus(Status::PlayingOnce);
|
||||||
|
emit uiPlaybackChanged(m_layer, Status::PlayingOnce);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
// ToDo: call the audio engine
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// from DMX signals
|
// from DMX signals
|
||||||
|
@ -195,13 +199,10 @@ void AudioLayerWidget::fileLoaded(QString file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::setPlaybackStatus(Status status)
|
QString AudioLayerWidget::getStatus()
|
||||||
{
|
{
|
||||||
m_status = status;
|
|
||||||
if (status == Status::Stopped)
|
|
||||||
m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(0));
|
|
||||||
QString tmp;
|
QString tmp;
|
||||||
switch (status) {
|
switch (m_status) {
|
||||||
case Status::Paused:
|
case Status::Paused:
|
||||||
tmp.append("Paused");
|
tmp.append("Paused");
|
||||||
break;
|
break;
|
||||||
|
@ -215,8 +216,21 @@ void AudioLayerWidget::setPlaybackStatus(Status status)
|
||||||
tmp.append("Stopped");
|
tmp.append("Stopped");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioLayerWidget::setPlaybackStatus(Status status)
|
||||||
|
{
|
||||||
|
m_status = status;
|
||||||
|
if (status == Status::Stopped)
|
||||||
|
m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(0));
|
||||||
|
QString tmp = this->getStatus();
|
||||||
|
m_statusValue->blockSignals(true);
|
||||||
|
m_suspendResumeButton->blockSignals(true);
|
||||||
m_statusValue->setText(tmp);
|
m_statusValue->setText(tmp);
|
||||||
m_suspendResumeButton->setText(tmp);
|
m_suspendResumeButton->setText(tmp);
|
||||||
|
m_statusValue->blockSignals(false);
|
||||||
|
m_suspendResumeButton->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::durationChanged(qint64 dur)
|
void AudioLayerWidget::durationChanged(qint64 dur)
|
||||||
|
|
|
@ -23,7 +23,7 @@ class AudioLayerWidget : public QGroupBox
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AudioLayerWidget(QWidget *parent = 0, QString name = "Layer");
|
explicit AudioLayerWidget(QWidget *parent = 0, QString name = "Layer", int layer = 0);
|
||||||
~AudioLayerWidget();
|
~AudioLayerWidget();
|
||||||
void setVol(qreal vol);
|
void setVol(qreal vol);
|
||||||
void resume();
|
void resume();
|
||||||
|
@ -32,17 +32,18 @@ public:
|
||||||
void setLoop(bool on);
|
void setLoop(bool on);
|
||||||
void setPlaybackStatus(Status status);
|
void setPlaybackStatus(Status status);
|
||||||
inline Status getPlaybackStatus() { return m_status; }
|
inline Status getPlaybackStatus() { return m_status; }
|
||||||
|
QString getStatus();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Status m_status;
|
||||||
|
int m_layer;
|
||||||
QPushButton *m_suspendResumeButton;
|
QPushButton *m_suspendResumeButton;
|
||||||
|
|
||||||
QLabel *m_statusLabel;
|
QLabel *m_statusLabel;
|
||||||
QLabel * m_statusValue;
|
QLabel * m_statusValue;
|
||||||
QLabel *m_fileLabel;
|
QLabel *m_fileLabel;
|
||||||
QLabel *m_fileValue;
|
QLabel *m_fileValue;
|
||||||
QLabel * m_folderLabel;
|
QLabel * m_folderLabel;
|
||||||
QLabel * m_folderValue;
|
QLabel * m_folderValue;
|
||||||
|
|
||||||
QLabel *m_volumeLabel;
|
QLabel *m_volumeLabel;
|
||||||
QSlider *m_volumeSlider;
|
QSlider *m_volumeSlider;
|
||||||
QSpinBox *m_volumeIndicator;
|
QSpinBox *m_volumeIndicator;
|
||||||
|
@ -52,7 +53,6 @@ private:
|
||||||
QLabel *m_pitchLabel;
|
QLabel *m_pitchLabel;
|
||||||
QSlider *m_pitchSlider;
|
QSlider *m_pitchSlider;
|
||||||
QSpinBox *m_pitchIndicator;
|
QSpinBox *m_pitchIndicator;
|
||||||
|
|
||||||
QLabel * m_progressLabel;
|
QLabel * m_progressLabel;
|
||||||
QSlider *m_progressSlider;
|
QSlider *m_progressSlider;
|
||||||
QLabel *m_progressTimeLabel;
|
QLabel *m_progressTimeLabel;
|
||||||
|
@ -60,8 +60,6 @@ private:
|
||||||
QLabel *m_totalTimeLabel;
|
QLabel *m_totalTimeLabel;
|
||||||
QTimeEdit *m_totalTimeValue;
|
QTimeEdit *m_totalTimeValue;
|
||||||
|
|
||||||
Status m_status;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleSuspendResume();
|
void toggleSuspendResume();
|
||||||
void volumeChanged(int vol);
|
void volumeChanged(int vol);
|
||||||
|
@ -71,6 +69,11 @@ public slots:
|
||||||
void fileLoaded(QString file);
|
void fileLoaded(QString file);
|
||||||
void durationChanged(qint64 dur);
|
void durationChanged(qint64 dur);
|
||||||
void refreshUi(float progress);
|
void refreshUi(float progress);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void uiPlaybackChanged(int layer, Status s);
|
||||||
|
void uiSliderChanged(int layer, Slider s, Status status);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUDIOLAYERWIDGET_H
|
#endif // AUDIOLAYERWIDGET_H
|
||||||
|
|
|
@ -5,10 +5,12 @@ AudioWidget::AudioWidget() :
|
||||||
m_layout(new QHBoxLayout())
|
m_layout(new QHBoxLayout())
|
||||||
, m_refreshUi(new QTimer(this))
|
, m_refreshUi(new QTimer(this))
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i= 0; i < Settings::getInstance()->getLayersNumber(); i++ ) {
|
for (int i= 0; i < Settings::getInstance()->getLayersNumber(); i++ ) {
|
||||||
m_layout->insertWidget(i, new AudioLayerWidget(this, tr("Layer %1").arg(i + 1)));
|
AudioLayerWidget *alw = new AudioLayerWidget(this, tr("Layer %1").arg(i + 1), i);
|
||||||
}
|
m_layout->insertWidget(i, alw);
|
||||||
|
connect(alw, SIGNAL(uiSliderAction(int, Slider, qreal)), this, SLOT(uiSliderAction(int, Status)));
|
||||||
|
connect(alw, SIGNAL(uiPlaybackChanged(int, Status)), this, SLOT(uiChangePlaybackStatus(int, Status)));
|
||||||
|
}
|
||||||
setLayout(m_layout);
|
setLayout(m_layout);
|
||||||
connect(m_refreshUi, SIGNAL(timeout()), this, SLOT(refreshUi()));
|
connect(m_refreshUi, SIGNAL(timeout()), this, SLOT(refreshUi()));
|
||||||
m_refreshUi->start(UI_REFRESH_TIME);
|
m_refreshUi->start(UI_REFRESH_TIME);
|
||||||
|
@ -89,3 +91,21 @@ void AudioWidget::refreshUi() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioWidget::uiSliderAction(int layer, Slider s, qreal value)
|
||||||
|
{
|
||||||
|
switch (s){
|
||||||
|
case Slider::Volume:
|
||||||
|
this->volChanged(layer, value);
|
||||||
|
case Slider::Pan:
|
||||||
|
this->panChanged(layer, value);
|
||||||
|
case Slider::Pitch:
|
||||||
|
this->pitchChanged(layer, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioWidget::uiChangePlaybackStatus(int layer, Status s) {
|
||||||
|
qDebug("changing playback %i %i", layer, s);
|
||||||
|
m_mae.playbackChanged(layer, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
class AudioWidget : public QWidget
|
class AudioWidget : public QWidget
|
||||||
{
|
{
|
||||||
friend class libreMediaServerAudio;
|
friend class libreMediaServerAudio;
|
||||||
|
friend class AudioLayerWidget;
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -38,6 +39,10 @@ private:
|
||||||
QHBoxLayout *m_layout;
|
QHBoxLayout *m_layout;
|
||||||
QTimer *m_refreshUi;
|
QTimer *m_refreshUi;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void uiSliderAction(int layer, Slider s, qreal value);
|
||||||
|
void uiChangePlaybackStatus(int layer, Status s);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void refreshUi();
|
void refreshUi();
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#define VERSION "LibreMediaServer-Audio 0.1.4"
|
#define VERSION "LibreMediaServer-Audio 0.1.4"
|
||||||
#define COPYRIGHT "(C) 2014-2024 Santi Norena lms@criptomart.net"
|
#define COPYRIGHT "(C) 2014-2024 Santi Norena lms@criptomart.net"
|
||||||
#define LICENSE "GPL 3 License. See LICENSE.txt and credits.txt for details"
|
#define LICENSE "GPL 3 License. See LICENSE.txt and credits.txt for details"
|
||||||
#define LAYERS_NUMBER 4 // esto tiene que desaparecer
|
|
||||||
#define DEFAULT_FILE "lms-audio.xlm"
|
#define DEFAULT_FILE "lms-audio.xlm"
|
||||||
#define SUSPEND_LABEL "Pause"
|
#define SUSPEND_LABEL "Pause"
|
||||||
#define RESUME_LABEL "Resume"
|
#define RESUME_LABEL "Resume"
|
||||||
|
@ -62,5 +61,12 @@ enum Status
|
||||||
PlayingLoop,
|
PlayingLoop,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Slider
|
||||||
|
{
|
||||||
|
Volume,
|
||||||
|
Pan,
|
||||||
|
Pitch,
|
||||||
|
};
|
||||||
|
|
||||||
#endif // DEFINES_H
|
#endif // DEFINES_H
|
||||||
|
|
||||||
|
|
|
@ -6,18 +6,16 @@ olaThread::olaThread(QObject *parent)
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
m_counter = 0;
|
m_counter = 0;
|
||||||
gettimeofday(&m_last_data, NULL);
|
gettimeofday(&m_last_data, NULL);
|
||||||
// Init the dmx buffer to 0
|
for (int i=0; i < MAX_LAYERS; i++)
|
||||||
for (int i=0; i < LAYERS_NUMBER; i++)
|
|
||||||
{
|
{
|
||||||
for (int j=0; j < LAYER_CHANNELS; j++)
|
for (int j=0; j < LAYER_CHANNELS; j++)
|
||||||
{
|
{
|
||||||
m_dmx[i][j] = 0;
|
m_dmx[i][j] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
init(); // start the ola connection
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- DECONSTRUCTOR ---
|
|
||||||
olaThread::~olaThread() {
|
olaThread::~olaThread() {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
@ -70,7 +68,7 @@ void olaThread::NewDmx(const ola::client::DMXMetadata &data,
|
||||||
emit layerReceived();
|
emit layerReceived();
|
||||||
foreach (const dmxSetting &i, Settings::getInstance()->getDmxSettings()) { // loop for reading the channels by layer.
|
foreach (const dmxSetting &i, Settings::getInstance()->getDmxSettings()) { // loop for reading the channels by layer.
|
||||||
if(i.universe == universe && i.address > -1) { // Compare if the layer is from this universe AND if the DMX address is 0 or greater, process this layer.
|
if(i.universe == universe && i.address > -1) { // Compare if the layer is from this universe AND if the DMX address is 0 or greater, process this layer.
|
||||||
for (int j = 0; j < LAYER_CHANNELS; j++){
|
for (int j = 0; j < MAX_LAYERS; j++){
|
||||||
int value = buffer.Get((i.address) + j); // Get the value for this channel.
|
int value = buffer.Get((i.address) + j); // Get the value for this channel.
|
||||||
if (m_dmx[i.layer][j] != value) { // Compare the new value with the old value.
|
if (m_dmx[i.layer][j] != value) { // Compare the new value with the old value.
|
||||||
emit dmxOutput(i.layer,j,value);
|
emit dmxOutput(i.layer,j,value);
|
||||||
|
@ -103,7 +101,7 @@ bool olaThread::CheckDataLoss() {
|
||||||
void olaThread::resendDmx()
|
void olaThread::resendDmx()
|
||||||
{
|
{
|
||||||
// qDebug() << "Resending DMX info";
|
// qDebug() << "Resending DMX info";
|
||||||
for (int i = 0; i < Settings::getInstance()->getLayersNumber(); i++) { // loop for reading the channels by layer.
|
for (int i = 0; i < MAX_LAYERS; i++) { // loop for reading the channels by layer.
|
||||||
for (int j = 0; j < LAYER_CHANNELS; j++){
|
for (int j = 0; j < LAYER_CHANNELS; j++){
|
||||||
emit dmxOutput(i, j, m_dmx[i][j]);
|
emit dmxOutput(i, j, m_dmx[i][j]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
unsigned int m_counter;
|
unsigned int m_counter;
|
||||||
struct timeval m_last_data; // Last DMX frame received
|
struct timeval m_last_data; // Last DMX frame received
|
||||||
|
|
||||||
int m_dmx[LAYERS_NUMBER][LAYER_CHANNELS]; // DMX Buffer. Habría que cambiarlo si queremos hacer las capas dinámicas
|
int m_dmx[MAX_LAYERS][LAYER_CHANNELS]; // DMX Buffer. Habría que cambiarlo si queremos hacer las capas dinámicas
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Callback from ola. Control de errores en el registro de Universos en OLA
|
* @brief Callback from ola. Control de errores en el registro de Universos en OLA
|
||||||
|
|
|
@ -42,7 +42,7 @@ void Settings::readFromFile(QString file) {
|
||||||
QXmlStreamReader* xmlReader = new QXmlStreamReader(xmlFile);
|
QXmlStreamReader* xmlReader = new QXmlStreamReader(xmlFile);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
//Parse the XML until we reach end of it
|
//Parse the XML until we reach end of it
|
||||||
while(!xmlReader->atEnd() && !xmlReader->hasError() && counter < LAYERS_NUMBER) {
|
while(!xmlReader->atEnd() && !xmlReader->hasError() && counter < MAX_LAYERS) {
|
||||||
// Read next element
|
// Read next element
|
||||||
QXmlStreamReader::TokenType token = xmlReader->readNext();
|
QXmlStreamReader::TokenType token = xmlReader->readNext();
|
||||||
//If token is just StartDocument - go to next
|
//If token is just StartDocument - go to next
|
||||||
|
@ -75,8 +75,8 @@ void Settings::readFromFile(QString file) {
|
||||||
m_universe.insert(temp.universe);
|
m_universe.insert(temp.universe);
|
||||||
// emit registerUniverse(temp.universe);
|
// emit registerUniverse(temp.universe);
|
||||||
}
|
}
|
||||||
|
counter++;
|
||||||
}
|
}
|
||||||
counter++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,10 +92,10 @@ public:
|
||||||
*/
|
*/
|
||||||
inline void setLayersNumber(int layersNumber)
|
inline void setLayersNumber(int layersNumber)
|
||||||
{
|
{
|
||||||
if (layersNumber <= LAYERS_NUMBER)
|
if (layersNumber <= MAX_LAYERS)
|
||||||
m_layersNumber = layersNumber;
|
m_layersNumber = layersNumber;
|
||||||
else
|
else
|
||||||
m_layersNumber = LAYERS_NUMBER;
|
m_layersNumber = MAX_LAYERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int getAudioDeviceId() { return m_audioDeviceId; }
|
inline int getAudioDeviceId() { return m_audioDeviceId; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue