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"
|
||||
|
||||
|
||||
AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||
AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name, int layer):
|
||||
QGroupBox(parent)
|
||||
, m_layer(layer)
|
||||
, m_suspendResumeButton(0)
|
||||
, m_volumeIndicator(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->setReadOnly(true);
|
||||
m_progressTime->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||
m_progressTime->setMaximumWidth(120);
|
||||
m_progressTime->setMaximumWidth(100);
|
||||
progressTime->addWidget(m_progressTimeLabel);
|
||||
progressTime->addWidget(m_progressTime);
|
||||
m_totalTimeLabel = new QLabel;
|
||||
|
@ -102,7 +103,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
|||
m_totalTimeValue->setDisplayFormat("h:mm:ss:zzz");
|
||||
m_totalTimeValue->setReadOnly(true);
|
||||
m_totalTimeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||
m_totalTimeValue->setMaximumWidth(120);
|
||||
m_totalTimeValue->setMaximumWidth(100);
|
||||
progressTime->addWidget(m_totalTimeLabel);
|
||||
progressTime->addWidget(m_totalTimeValue);
|
||||
layout->addLayout(progressTime);
|
||||
|
@ -153,11 +154,14 @@ void AudioLayerWidget::toggleSuspendResume()
|
|||
case Status::PlayingLoop:
|
||||
case Status::PlayingOnce:
|
||||
this->setPlaybackStatus(Status::Paused);
|
||||
emit uiPlaybackChanged(m_layer, Status::Paused);
|
||||
break;
|
||||
case Status::Paused:
|
||||
case Status::Stopped:
|
||||
this->setPlaybackStatus(Status::PlayingOnce);
|
||||
emit uiPlaybackChanged(m_layer, Status::PlayingOnce);
|
||||
break;
|
||||
}
|
||||
// ToDo: call the audio engine
|
||||
}
|
||||
|
||||
// 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;
|
||||
switch (status) {
|
||||
switch (m_status) {
|
||||
case Status::Paused:
|
||||
tmp.append("Paused");
|
||||
break;
|
||||
|
@ -215,8 +216,21 @@ void AudioLayerWidget::setPlaybackStatus(Status status)
|
|||
tmp.append("Stopped");
|
||||
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_suspendResumeButton->setText(tmp);
|
||||
m_statusValue->blockSignals(false);
|
||||
m_suspendResumeButton->blockSignals(false);
|
||||
}
|
||||
|
||||
void AudioLayerWidget::durationChanged(qint64 dur)
|
||||
|
|
|
@ -23,7 +23,7 @@ class AudioLayerWidget : public QGroupBox
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AudioLayerWidget(QWidget *parent = 0, QString name = "Layer");
|
||||
explicit AudioLayerWidget(QWidget *parent = 0, QString name = "Layer", int layer = 0);
|
||||
~AudioLayerWidget();
|
||||
void setVol(qreal vol);
|
||||
void resume();
|
||||
|
@ -32,17 +32,18 @@ public:
|
|||
void setLoop(bool on);
|
||||
void setPlaybackStatus(Status status);
|
||||
inline Status getPlaybackStatus() { return m_status; }
|
||||
QString getStatus();
|
||||
|
||||
private:
|
||||
Status m_status;
|
||||
int m_layer;
|
||||
QPushButton *m_suspendResumeButton;
|
||||
|
||||
QLabel *m_statusLabel;
|
||||
QLabel * m_statusValue;
|
||||
QLabel *m_fileLabel;
|
||||
QLabel *m_fileValue;
|
||||
QLabel * m_folderLabel;
|
||||
QLabel * m_folderValue;
|
||||
|
||||
QLabel *m_volumeLabel;
|
||||
QSlider *m_volumeSlider;
|
||||
QSpinBox *m_volumeIndicator;
|
||||
|
@ -52,7 +53,6 @@ private:
|
|||
QLabel *m_pitchLabel;
|
||||
QSlider *m_pitchSlider;
|
||||
QSpinBox *m_pitchIndicator;
|
||||
|
||||
QLabel * m_progressLabel;
|
||||
QSlider *m_progressSlider;
|
||||
QLabel *m_progressTimeLabel;
|
||||
|
@ -60,8 +60,6 @@ private:
|
|||
QLabel *m_totalTimeLabel;
|
||||
QTimeEdit *m_totalTimeValue;
|
||||
|
||||
Status m_status;
|
||||
|
||||
public slots:
|
||||
void toggleSuspendResume();
|
||||
void volumeChanged(int vol);
|
||||
|
@ -71,6 +69,11 @@ public slots:
|
|||
void fileLoaded(QString file);
|
||||
void durationChanged(qint64 dur);
|
||||
void refreshUi(float progress);
|
||||
|
||||
signals:
|
||||
void uiPlaybackChanged(int layer, Status s);
|
||||
void uiSliderChanged(int layer, Slider s, Status status);
|
||||
|
||||
};
|
||||
|
||||
#endif // AUDIOLAYERWIDGET_H
|
||||
|
|
|
@ -5,9 +5,11 @@ AudioWidget::AudioWidget() :
|
|||
m_layout(new QHBoxLayout())
|
||||
, m_refreshUi(new QTimer(this))
|
||||
{
|
||||
|
||||
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);
|
||||
connect(m_refreshUi, SIGNAL(timeout()), this, SLOT(refreshUi()));
|
||||
|
@ -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
|
||||
{
|
||||
friend class libreMediaServerAudio;
|
||||
friend class AudioLayerWidget;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -38,6 +39,10 @@ private:
|
|||
QHBoxLayout *m_layout;
|
||||
QTimer *m_refreshUi;
|
||||
|
||||
public slots:
|
||||
void uiSliderAction(int layer, Slider s, qreal value);
|
||||
void uiChangePlaybackStatus(int layer, Status s);
|
||||
|
||||
private slots:
|
||||
void refreshUi();
|
||||
};
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define VERSION "LibreMediaServer-Audio 0.1.4"
|
||||
#define COPYRIGHT "(C) 2014-2024 Santi Norena lms@criptomart.net"
|
||||
#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 SUSPEND_LABEL "Pause"
|
||||
#define RESUME_LABEL "Resume"
|
||||
|
@ -62,5 +61,12 @@ enum Status
|
|||
PlayingLoop,
|
||||
};
|
||||
|
||||
enum Slider
|
||||
{
|
||||
Volume,
|
||||
Pan,
|
||||
Pitch,
|
||||
};
|
||||
|
||||
#endif // DEFINES_H
|
||||
|
||||
|
|
|
@ -6,18 +6,16 @@ olaThread::olaThread(QObject *parent)
|
|||
Q_UNUSED(parent);
|
||||
m_counter = 0;
|
||||
gettimeofday(&m_last_data, NULL);
|
||||
// Init the dmx buffer to 0
|
||||
for (int i=0; i < LAYERS_NUMBER; i++)
|
||||
for (int i=0; i < MAX_LAYERS; i++)
|
||||
{
|
||||
for (int j=0; j < LAYER_CHANNELS; j++)
|
||||
{
|
||||
m_dmx[i][j] = 0;
|
||||
}
|
||||
}
|
||||
init(); // start the ola connection
|
||||
init();
|
||||
}
|
||||
|
||||
// --- DECONSTRUCTOR ---
|
||||
olaThread::~olaThread() {
|
||||
stop();
|
||||
}
|
||||
|
@ -70,7 +68,7 @@ void olaThread::NewDmx(const ola::client::DMXMetadata &data,
|
|||
emit layerReceived();
|
||||
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.
|
||||
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.
|
||||
if (m_dmx[i.layer][j] != value) { // Compare the new value with the old value.
|
||||
emit dmxOutput(i.layer,j,value);
|
||||
|
@ -103,7 +101,7 @@ bool olaThread::CheckDataLoss() {
|
|||
void olaThread::resendDmx()
|
||||
{
|
||||
// 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++){
|
||||
emit dmxOutput(i, j, m_dmx[i][j]);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
unsigned int m_counter;
|
||||
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
|
||||
|
|
|
@ -42,7 +42,7 @@ void Settings::readFromFile(QString file) {
|
|||
QXmlStreamReader* xmlReader = new QXmlStreamReader(xmlFile);
|
||||
int counter = 0;
|
||||
//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
|
||||
QXmlStreamReader::TokenType token = xmlReader->readNext();
|
||||
//If token is just StartDocument - go to next
|
||||
|
@ -75,10 +75,10 @@ void Settings::readFromFile(QString file) {
|
|||
m_universe.insert(temp.universe);
|
||||
// emit registerUniverse(temp.universe);
|
||||
}
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(xmlReader->hasError()) {
|
||||
QMessageBox::critical(NULL,"File xml Parse Error ", xmlReader->errorString(), QMessageBox::Ok);
|
||||
|
|
|
@ -92,10 +92,10 @@ public:
|
|||
*/
|
||||
inline void setLayersNumber(int layersNumber)
|
||||
{
|
||||
if (layersNumber <= LAYERS_NUMBER)
|
||||
if (layersNumber <= MAX_LAYERS)
|
||||
m_layersNumber = layersNumber;
|
||||
else
|
||||
m_layersNumber = LAYERS_NUMBER;
|
||||
m_layersNumber = MAX_LAYERS;
|
||||
}
|
||||
|
||||
inline int getAudioDeviceId() { return m_audioDeviceId; }
|
||||
|
|
Loading…
Add table
Reference in a new issue