Antigona Release #1
10 changed files with 50 additions and 125 deletions
|
@ -13,23 +13,14 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name, int layer):
|
|||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
|
||||
QGridLayout *status = new QGridLayout;
|
||||
m_statusLabel = new QLabel;
|
||||
m_statusLabel->setText(STATUS_LABEL);
|
||||
m_statusValue = new QLabel;
|
||||
status->addWidget(m_statusLabel, 0, 0);
|
||||
status->addWidget(m_statusValue, 0, 2);
|
||||
m_folderLabel = new QLabel;
|
||||
m_folderLabel->setText(FOLDER_LABEL);
|
||||
status->addWidget(m_statusValue, 1, 1);
|
||||
m_folderValue = new QLabel;
|
||||
m_folderValue->setMaximumWidth(200);
|
||||
status->addWidget(m_folderLabel, 1, 0);
|
||||
status->addWidget(m_folderValue, 1, 1);
|
||||
m_fileLabel = new QLabel;
|
||||
m_fileLabel->setText(FILE_LABEL);
|
||||
m_folderValue->setMaximumWidth(100);
|
||||
status->addWidget(m_folderValue, 0, 0);
|
||||
m_fileValue = new QLabel;
|
||||
m_fileValue->setMaximumWidth(200);
|
||||
status->addWidget(m_fileLabel, 1, 2);
|
||||
status->addWidget(m_fileValue, 1, 3);
|
||||
m_fileValue->setMaximumWidth(100);
|
||||
status->addWidget(m_fileValue, 0, 2);
|
||||
layout->addLayout(status);
|
||||
|
||||
QGridLayout *volumeBox = new QGridLayout;
|
||||
|
@ -126,26 +117,17 @@ AudioLayerWidget::~AudioLayerWidget()
|
|||
// From UI.
|
||||
void AudioLayerWidget::volumeChanged(int value)
|
||||
{
|
||||
(void)value;
|
||||
// ToDo: call the audio engine
|
||||
emit(uiSliderChanged(m_layer, Slider::Volume, value));
|
||||
}
|
||||
|
||||
void AudioLayerWidget::panChanged(int value)
|
||||
{
|
||||
(void)value;
|
||||
// ToDo: call the audio engine
|
||||
emit(uiSliderChanged(m_layer, Slider::Pan, value));
|
||||
}
|
||||
|
||||
void AudioLayerWidget::pitchChanged(int value)
|
||||
{
|
||||
(void)value;
|
||||
// ToDo: call the audio engine
|
||||
}
|
||||
|
||||
void AudioLayerWidget::loopChanged(int value)
|
||||
{
|
||||
(void)value;
|
||||
// ToDo: call the audio engine
|
||||
emit(uiSliderChanged(m_layer, Slider::Pitch, value));
|
||||
}
|
||||
|
||||
void AudioLayerWidget::toggleSuspendResume()
|
||||
|
|
|
@ -65,14 +65,13 @@ public slots:
|
|||
void volumeChanged(int vol);
|
||||
void panChanged(int vol);
|
||||
void pitchChanged(int vol);
|
||||
void loopChanged(int vol);
|
||||
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);
|
||||
void uiSliderChanged(int layer, Slider s, int value);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ AudioWidget::AudioWidget() :
|
|||
for (int i= 0; i < Settings::getInstance()->getLayersNumber(); i++ ) {
|
||||
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(uiSliderChanged(int, Slider, int)), this, SLOT(uiSliderAction(int, Slider, int)));
|
||||
connect(alw, SIGNAL(uiPlaybackChanged(int, Status)), this, SLOT(uiChangePlaybackStatus(int, Status)));
|
||||
}
|
||||
setLayout(m_layout);
|
||||
|
@ -92,20 +92,22 @@ void AudioWidget::refreshUi() {
|
|||
}
|
||||
}
|
||||
|
||||
void AudioWidget::uiSliderAction(int layer, Slider s, qreal value)
|
||||
void AudioWidget::uiSliderAction(int layer, Slider s, int value)
|
||||
{
|
||||
switch (s){
|
||||
case Slider::Volume:
|
||||
this->volChanged(layer, value);
|
||||
m_mae.volChanged(layer, value);
|
||||
break;
|
||||
case Slider::Pan:
|
||||
this->panChanged(layer, value);
|
||||
m_mae.panChanged(layer, value);
|
||||
break;
|
||||
case Slider::Pitch:
|
||||
this->pitchChanged(layer, value);
|
||||
m_mae.pitchChanged(layer, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioWidget::uiChangePlaybackStatus(int layer, Status s) {
|
||||
qDebug("changing playback %i %i", layer, s);
|
||||
m_mae.playbackChanged(layer, s);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QDialog>
|
||||
|
||||
#include "audiomasterwidget.h"
|
||||
|
@ -40,7 +39,7 @@ private:
|
|||
QTimer *m_refreshUi;
|
||||
|
||||
public slots:
|
||||
void uiSliderAction(int layer, Slider s, qreal value);
|
||||
void uiSliderAction(int layer, Slider s, int value);
|
||||
void uiChangePlaybackStatus(int layer, Status s);
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -15,14 +15,11 @@
|
|||
#define STOP_LABEL "Stop"
|
||||
#define PAUSE_LABEL "Pause"
|
||||
#define IDDLE_LABEL "Iddle playback"
|
||||
#define VOLUME_LABEL "Volume"
|
||||
#define VOLUME_LABEL "Vol"
|
||||
#define PROGRESS_LABEL "Progress"
|
||||
#define PROGRESS_TIME_LABEL "Current"
|
||||
#define REMAINING_TIME "Remaining"
|
||||
#define TOTAL_TIME_LABEL "Total"
|
||||
#define FILE_LABEL "File: "
|
||||
#define FOLDER_LABEL "Folder: "
|
||||
#define STATUS_LABEL "Status: "
|
||||
#define NOTIFY_INTERVAL 150
|
||||
#define PULL_TIMER_INTERVAL 10
|
||||
#define MAX_DEVICES 16
|
||||
|
|
|
@ -66,7 +66,7 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
|||
topWidget->setWidget(amw);
|
||||
addDockWidget(Qt::TopDockWidgetArea, topWidget);
|
||||
// ola setup
|
||||
ola = new olaThread();
|
||||
ola = new olaThread(this, set->getLayersNumber());
|
||||
Q_CHECK_PTR(ola);
|
||||
ola->blockSignals(true);
|
||||
connect(set, SIGNAL(registerUniverse(int)), ola, SLOT(registerUniverse(int)));
|
||||
|
@ -82,6 +82,7 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
|||
aw->startEngine();
|
||||
qDebug("Init Complete.");
|
||||
ola->blockSignals(false);
|
||||
ola->resendDmx();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>199</width>
|
||||
<width>114</width>
|
||||
<height>218</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -20,7 +20,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>199</width>
|
||||
<width>114</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -33,7 +33,13 @@
|
|||
<addaction name="action_Settings"/>
|
||||
<addaction name="actionLaunch_OLA_Setup"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include "olathread.h"
|
||||
|
||||
|
||||
olaThread::olaThread(QObject *parent)
|
||||
olaThread::olaThread(QObject *parent, int layers) :
|
||||
m_counter(0)
|
||||
, m_layers(layers)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
m_counter = 0;
|
||||
gettimeofday(&m_last_data, NULL);
|
||||
for (int i=0; i < MAX_LAYERS; i++)
|
||||
{
|
||||
|
@ -41,7 +42,6 @@ void olaThread::init()
|
|||
|
||||
void olaThread::run()
|
||||
{
|
||||
emit toTerminal("Start reading DMX");
|
||||
m_clientWrapper->GetSelectServer()->Run();
|
||||
}
|
||||
|
||||
|
@ -64,15 +64,13 @@ void olaThread::NewDmx(const ola::client::DMXMetadata &data,
|
|||
{
|
||||
m_counter++;
|
||||
gettimeofday(&m_last_data, NULL);
|
||||
uint universe = data.universe;
|
||||
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 < 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);
|
||||
foreach (const dmxSetting &i, Settings::getInstance()->getDmxSettings()) {
|
||||
if(i.universe == data.universe && i.address > -1) {
|
||||
for (int j = 0; j < LAYER_CHANNELS; j++){
|
||||
int value = buffer.Get((i.address) + j);
|
||||
if (m_dmx[i.layer][j] != value) {
|
||||
m_dmx[i.layer][j] = value;
|
||||
emit dmxOutput(i.layer,j,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,17 +80,13 @@ void olaThread::NewDmx(const ola::client::DMXMetadata &data,
|
|||
/**
|
||||
* Check for data loss each 4 seconds.
|
||||
*/
|
||||
|
||||
bool olaThread::CheckDataLoss() {
|
||||
struct timeval now, diff;
|
||||
if (timerisset(&m_last_data)) {
|
||||
gettimeofday(&now, NULL);
|
||||
timersub(&now, &m_last_data, &diff);
|
||||
if (diff.tv_sec > 4 || (diff.tv_sec == 4 && diff.tv_usec > 4000000)) {
|
||||
// loss of data
|
||||
qDebug()<< "olaThread| Can not read one or several universes";
|
||||
emit toTerminal("olaThread: Can not read one universe");
|
||||
// return false; // Retorna false para deshabilitar el callback
|
||||
qInfo()<< "olaThread| Can not read one or several universes";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -100,8 +94,7 @@ bool olaThread::CheckDataLoss() {
|
|||
|
||||
void olaThread::resendDmx()
|
||||
{
|
||||
// qDebug() << "Resending DMX info";
|
||||
for (int i = 0; i < MAX_LAYERS; i++) { // loop for reading the channels by layer.
|
||||
for (int i = 0; i < m_layers; i++) {
|
||||
for (int j = 0; j < LAYER_CHANNELS; j++){
|
||||
emit dmxOutput(i, j, m_dmx[i][j]);
|
||||
}
|
||||
|
@ -110,19 +103,11 @@ void olaThread::resendDmx()
|
|||
|
||||
void olaThread::socketClosed()
|
||||
{
|
||||
qWarning("ola close the connection. Trying reopening it... ");
|
||||
emit toTerminal("OLA closed the connection. Tryin reopening it... ");
|
||||
|
||||
qWarning("ola closed connection. Try reopening it... ");
|
||||
m_clientWrapper->GetSelectServer()->Terminate();
|
||||
m_client = NULL;
|
||||
m_clientWrapper = NULL;
|
||||
|
||||
// setup ola connection
|
||||
init();
|
||||
|
||||
// register universes
|
||||
registerUniverse();
|
||||
|
||||
// start thread
|
||||
run();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
|
||||
#include <ola/DmxBuffer.h>
|
||||
#include <ola/Logging.h>
|
||||
|
@ -25,7 +24,7 @@ class olaThread : public QThread
|
|||
|
||||
public:
|
||||
|
||||
olaThread(QObject *parent = 0);
|
||||
olaThread(QObject *parent = 0, int layers = 0);
|
||||
virtual ~olaThread();
|
||||
|
||||
/** Retorna el valor de un canal
|
||||
|
@ -37,9 +36,6 @@ public:
|
|||
return m_dmx[layer][channel];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief resendDMX emite todo el buffer DMX
|
||||
*/
|
||||
void resendDmx();
|
||||
|
||||
private:
|
||||
|
@ -49,78 +45,49 @@ private:
|
|||
ola::client::OlaClient *m_client;
|
||||
unsigned int m_counter;
|
||||
struct timeval m_last_data; // Last DMX frame received
|
||||
|
||||
int m_dmx[MAX_LAYERS][LAYER_CHANNELS]; // DMX Buffer. Habría que cambiarlo si queremos hacer las capas dinámicas
|
||||
int m_layers;
|
||||
int m_dmx[MAX_LAYERS][LAYER_CHANNELS];
|
||||
|
||||
/**
|
||||
* @brief Callback from ola. Control de errores en el registro de Universos en OLA
|
||||
* typedef SingleUseCallback1<void, const Result&> ola::client::SetCallback
|
||||
* @param ola::client::Result &error
|
||||
* @return void
|
||||
*
|
||||
*
|
||||
*/
|
||||
inline void RegisterComplete(const ola::client::Result &error) {
|
||||
if (error.Success()) {
|
||||
qDebug("Register Universe success");
|
||||
emit toTerminal("Register Universe success");
|
||||
} else {
|
||||
qWarning("Register command failed: %s", error.Error().c_str());
|
||||
emit toTerminal("olaThread| Register command failed " + QString::fromStdString(error.Error()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the dmx info is arriving each 4 seconds
|
||||
* @return bool
|
||||
*/
|
||||
bool CheckDataLoss();
|
||||
|
||||
/**
|
||||
* @brief RepeteableDMXCallBack from ola called when arrives a new dmx frame
|
||||
* typedef Callback2<void, const DMXMetadata&, const DmxBuffer&> ola::client::RepeatableDMXCallback
|
||||
* This is called one for second if there is not updated in the DMX frame. We need emit only the channels that
|
||||
* has changed to save resources.
|
||||
*
|
||||
*
|
||||
* This is called one for second if there is not updated in the DMX frame.
|
||||
* emit only the channels that has been changed.
|
||||
*/
|
||||
void NewDmx(const ola::client::DMXMetadata &dmx_meta, const ola::DmxBuffer &buffer); //
|
||||
|
||||
/**
|
||||
* @brief Sometimes the ola server closes the connection. This is a callback to handle this event an reconect to ola
|
||||
*
|
||||
*
|
||||
*/
|
||||
void socketClosed();
|
||||
|
||||
/**
|
||||
* @brief Open the connection with olad and start processing data.
|
||||
*
|
||||
*
|
||||
*/
|
||||
void init();
|
||||
void init();
|
||||
|
||||
public slots:
|
||||
|
||||
void stop(); // Close the connection with olad.
|
||||
|
||||
/**
|
||||
* @brief register one Universe
|
||||
* void ola::client::OlaClient::RegisterUniverse(unsigned int universe,RegisterAction register_action,SetCallback * callback
|
||||
* @param universe
|
||||
*/
|
||||
void stop();
|
||||
inline void registerUniverse(int universe) {
|
||||
qDebug("Registering universe %d", universe);
|
||||
qInfo("Registering universe %d", universe);
|
||||
m_client->RegisterUniverse(universe,
|
||||
ola::client::REGISTER,
|
||||
ola::NewSingleCallback
|
||||
(this, &olaThread::RegisterComplete));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register all the universes again
|
||||
*
|
||||
*/
|
||||
inline void registerUniverse() {
|
||||
QSet<int> unis = Settings::getInstance()->getUniverses();
|
||||
foreach (const int &universe, unis) {
|
||||
|
@ -128,15 +95,8 @@ public slots:
|
|||
}
|
||||
}
|
||||
|
||||
protected slots:
|
||||
|
||||
signals:
|
||||
|
||||
// void finished(); // Signal for closing. Not used now.
|
||||
void dmxOutput(int layer, int channel, int value); // Signal when a channel has changed
|
||||
void toTerminal(QString message);
|
||||
void universeReceived(uint universe);
|
||||
void layerReceived();
|
||||
void dmxOutput(int layer, int channel, int value);
|
||||
};
|
||||
|
||||
using namespace ola;
|
||||
|
|
|
@ -73,27 +73,22 @@ void Settings::readFromFile(QString file) {
|
|||
m_settings.append(temp);
|
||||
if (!m_universe.contains(temp.universe)) {
|
||||
m_universe.insert(temp.universe);
|
||||
// emit registerUniverse(temp.universe);
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(xmlReader->hasError()) {
|
||||
QMessageBox::critical(NULL,"File xml Parse Error ", xmlReader->errorString(), QMessageBox::Ok);
|
||||
qWarning("File xml Parse Error %s", xmlReader->errorString().toLatin1().constData());
|
||||
return;
|
||||
}
|
||||
//close reader and flush file
|
||||
xmlReader->clear();
|
||||
xmlFile->close();
|
||||
|
||||
delete xmlReader;
|
||||
delete xmlFile;
|
||||
}
|
||||
|
||||
|
||||
/** Read the default file
|
||||
*
|
||||
*/
|
||||
|
@ -110,7 +105,6 @@ void Settings::changeLayerSetup(int layer, int universe, int address)
|
|||
m_settings.replace(layer, temp);
|
||||
if (!m_universe.contains(temp.universe)) {
|
||||
m_universe.insert(temp.universe);
|
||||
// emit registerUniverse(temp.universe);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue