Cleaned old code. Changed the GUI refresh. Now there is a global receive
dmx instead one by layer
This commit is contained in:
		
							parent
							
								
									90f3b093c0
								
							
						
					
					
						commit
						d7db568784
					
				
					 10 changed files with 78 additions and 67 deletions
				
			
		|  | @ -7,14 +7,14 @@ | |||
| #include <QFile> | ||||
| #include <QTime> | ||||
| 
 | ||||
| #include <time.h> // nanosleep y la chapuza de liberar el buffer
 | ||||
| //#include <time.h> // nanosleep y la chapuza de liberar el buffer
 | ||||
| 
 | ||||
| AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name): | ||||
|     QGroupBox(parent) | ||||
|   ,   m_suspendResumeButton(0) | ||||
|   , m_watchDMX(new QTimer(this)) | ||||
|   , m_progressCounter(new QTime(0,0,0,1)) | ||||
|   , m_progressMs(0) | ||||
| //  , m_progressCounter(new QTime(0,0,0,1))
 | ||||
| //  , m_progressMs(0)
 | ||||
|   , m_currentMedia(" ") | ||||
|   , m_running(false) | ||||
| { | ||||
|  | @ -26,9 +26,9 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name): | |||
|     m_statusLabel = new QLabel; | ||||
|     m_statusLabel->setText(STATUS_LABEL); | ||||
|     m_statusValue = new QLabel; | ||||
|     m_receiveDMX = new QCheckBox("Receiving DMX", this); | ||||
|     m_receiveDMX->setChecked(false); | ||||
|     status->addWidget(m_receiveDMX); | ||||
| //    m_receiveDMX = new QCheckBox("Receiving DMX", this);
 | ||||
| //    m_receiveDMX->setChecked(false);
 | ||||
| //    status->addWidget(m_receiveDMX);
 | ||||
|     status->addWidget(m_statusLabel); | ||||
|     status->addWidget(m_statusValue); | ||||
|     layout->addLayout(status); | ||||
|  | @ -37,7 +37,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name): | |||
|     m_folderLabel = new QLabel; | ||||
|     m_folderLabel->setText(FOLDER_LABEL); | ||||
|     m_folderValue = new QLabel; | ||||
|     m_folderValue->setMaximumWidth(250); | ||||
|     m_folderValue->setMaximumWidth(200); | ||||
|     folderLoaded->addWidget(m_folderLabel); | ||||
|     folderLoaded->addWidget(m_folderValue); | ||||
|     layout->addLayout(folderLoaded); | ||||
|  | @ -46,7 +46,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name): | |||
|     m_fileLabel = new QLabel; | ||||
|     m_fileLabel->setText(FILE_LABEL); | ||||
|     m_fileValue = new QLabel; | ||||
|     m_fileValue->setMaximumWidth(250); | ||||
|     m_fileValue->setMaximumWidth(200); | ||||
|     fileLoaded->addWidget(m_fileLabel); | ||||
|     fileLoaded->addWidget(m_fileValue); | ||||
|     layout->addLayout(fileLoaded); | ||||
|  | @ -102,7 +102,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name): | |||
| 
 | ||||
|     connect(m_watchDMX, SIGNAL(timeout()), | ||||
|             this, SLOT(watchDMXExpired())); | ||||
|     m_watchDMX->start(123); | ||||
|     m_watchDMX->start(243); | ||||
| } | ||||
| 
 | ||||
| AudioLayerWidget::~AudioLayerWidget() | ||||
|  | @ -141,7 +141,7 @@ void AudioLayerWidget::loadMedia(QString file) | |||
|     } | ||||
|     m_music.setAttenuation(0); | ||||
| 
 | ||||
|     m_progressCounter->restart(); | ||||
| //    m_progressCounter->restart();
 | ||||
|     durationChanged(m_music.getDuration().asMilliseconds()); | ||||
|     fileLoaded(file); | ||||
| 
 | ||||
|  | @ -160,15 +160,15 @@ void AudioLayerWidget::fileLoaded(QString file) | |||
|        m_folderValue->setText(list.at(size - 2)); | ||||
|        m_fileValue->setText(list.at(size - 1)); | ||||
|     } | ||||
|     m_progressMs = 0; | ||||
|     m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(m_progressMs)); | ||||
| //    m_progressMs = 0;
 | ||||
| //    m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(m_progressMs));
 | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
| void AudioLayerWidget::notified() | ||||
| { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| */ | ||||
| // duration in miliseconds
 | ||||
| void AudioLayerWidget::durationChanged(qint64 dur) | ||||
| { | ||||
|  | @ -179,13 +179,13 @@ void AudioLayerWidget::durationChanged(qint64 dur) | |||
| void AudioLayerWidget::play() | ||||
| { | ||||
|     m_music.play(); | ||||
|     m_progressCounter->restart(); | ||||
| //    m_progressCounter->restart();
 | ||||
| } | ||||
| 
 | ||||
| void AudioLayerWidget::pause() | ||||
| { | ||||
|     m_music.pause(); | ||||
|     m_progressCounter->restart(); | ||||
| //    m_progressCounter->restart();
 | ||||
| } | ||||
| 
 | ||||
| void AudioLayerWidget::stop() | ||||
|  | @ -194,34 +194,45 @@ void AudioLayerWidget::stop() | |||
| } | ||||
| 
 | ||||
| void AudioLayerWidget::watchDMXExpired() { | ||||
|     m_receiveDMX->setChecked(false); | ||||
| //    m_receiveDMX->setChecked(false);
 | ||||
|     int progress; | ||||
|     switch (m_music.getStatus()) { | ||||
|       case sf::SoundSource::Playing: | ||||
|          m_progressMs += m_progressCounter->restart(); | ||||
|          m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(m_progressMs)); | ||||
| //         m_progressMs += m_progressCounter->restart();
 | ||||
|          progress = m_music.getPlayingOffset().asMilliseconds(); | ||||
|          m_progressSlider->setValue(progress); | ||||
|          m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(progress)); | ||||
|          m_statusValue->setText(PLAY_LABEL); | ||||
|          m_progressSlider->setValue(m_progressMs); | ||||
|          m_suspendResumeButton->setText(tr(PLAY_LABEL)); | ||||
|          break; | ||||
|       case sf::SoundSource::Paused: | ||||
|          m_statusValue->setText(PAUSE_LABEL); | ||||
|          m_suspendResumeButton->setText(tr(SUSPEND_LABEL)); | ||||
|          break; | ||||
|       case sf::SoundSource::Stopped: | ||||
|         m_progressCounter->restart(); | ||||
|         m_progressMs = 0; | ||||
|         m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(m_progressMs)); | ||||
| //        m_progressCounter->restart();
 | ||||
| //        m_progressMs = 0;
 | ||||
|         m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(0)); | ||||
|         m_statusValue->setText(STOP_LABEL); | ||||
|         m_progressSlider->setValue(m_progressMs); | ||||
|         m_suspendResumeButton->setText(tr(SUSPEND_LABEL)); | ||||
|         m_progressSlider->setValue(0); | ||||
|         break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
| void AudioLayerWidget::updateWatchDMX(bool b) | ||||
| { | ||||
|     m_receiveDMX->setChecked(b); | ||||
| //    m_receiveDMX->setChecked(b);
 | ||||
| } | ||||
| 
 | ||||
| */ | ||||
| void AudioLayerWidget::toggleSuspendResume() | ||||
| { | ||||
| 
 | ||||
|     if (m_music.getStatus() == sf::SoundSource::Playing) { | ||||
|         m_music.pause(); | ||||
| //        m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
 | ||||
|     } else { | ||||
|         m_music.play(); | ||||
| //        m_suspendResumeButton->setText(tr(PLAY_LABEL));
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -32,7 +32,7 @@ public: | |||
|     void pause(); | ||||
|     void setVol(qreal vol); | ||||
|     void resume(); | ||||
|     void updateWatchDMX(bool b); | ||||
| //    void updateWatchDMX(bool b);
 | ||||
| 
 | ||||
| public slots: | ||||
| 
 | ||||
|  | @ -66,8 +66,8 @@ private: | |||
|     QCheckBox *m_receiveDMX; | ||||
|     QTimer *m_watchDMX; | ||||
| 
 | ||||
|     QTime *m_progressCounter; | ||||
|     quint64 m_progressMs; | ||||
| //    QTime *m_progressCounter;
 | ||||
| //    quint64 m_progressMs;
 | ||||
| 
 | ||||
|     QString m_currentMedia; | ||||
| 
 | ||||
|  | @ -76,7 +76,7 @@ private: | |||
|     sf::Music m_music; | ||||
| 
 | ||||
| private slots: | ||||
|     void notified(); | ||||
| //    void notified();
 | ||||
|     void fileLoaded(QString file); | ||||
|     void durationChanged(qint64 dur); | ||||
|     void watchDMXExpired(); | ||||
|  |  | |||
|  | @ -38,3 +38,4 @@ void AudioMasterWidget::updateWatchDMX() | |||
| { | ||||
|     m_receiveDMX->setChecked(true); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -42,9 +42,9 @@ void AudioWidget::playbackChanged(int layer, Status status) | |||
|       break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
| void AudioWidget::layerReceived(int layer) | ||||
| { | ||||
|     QLayoutItem * const item = layout->itemAt(layer); | ||||
|     dynamic_cast<AudioLayerWidget *>(item->widget())->updateWatchDMX(true); | ||||
| } | ||||
| }*/ | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ public slots: | |||
|     void mediaLoaded(int layer, QString media ); | ||||
|     void volChanged(int layer, qreal vol); | ||||
|     void playbackChanged(int layer, Status status); | ||||
|     void layerReceived(int layer); | ||||
| //    void layerReceived(int layer);
 | ||||
| }; | ||||
| 
 | ||||
| #endif // AUDIOWIDGET_H
 | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ | |||
| */ | ||||
| #include "libremediaserver-audio.h" | ||||
| 
 | ||||
| QTextEdit * libreMediaServerAudio::textEdit = 0; | ||||
| // QTextEdit * libreMediaServerAudio::textEdit = 0;
 | ||||
| 
 | ||||
| /**
 | ||||
| / Constructor | ||||
|  | @ -33,7 +33,7 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent) | |||
|      // Inicia la lectura de dmx a través de ola
 | ||||
|      ola = new olaThread(); | ||||
|      Q_CHECK_PTR(ola); | ||||
| 
 | ||||
| /*
 | ||||
|      if (args.contains("-log")) { | ||||
|         // Inicia el widget Terminal
 | ||||
|         textEdit = new QTextEdit; | ||||
|  | @ -44,7 +44,16 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent) | |||
|         addDockWidget(Qt::BottomDockWidgetArea, bottomWidget); | ||||
|         connect(ola, SIGNAL(toTerminal(QString)), | ||||
|         textEdit, SLOT(append(QString)), Qt::QueuedConnection); | ||||
|     } | ||||
|     }*/ | ||||
| 
 | ||||
|      /*     connect(MediaLibrary::getInstance(), SIGNAL(debug(QString)),
 | ||||
|           textEdit, SLOT(append(QString)), Qt::QueuedConnection); | ||||
| 
 | ||||
|           connect(MediaLibrary::getInstance(), SIGNAL(warning(QString)), | ||||
|           textEdit, SLOT(append(QString)), Qt::QueuedConnection); | ||||
|      */ | ||||
| 
 | ||||
| 
 | ||||
|      this->setWindowTitle(VERSION); | ||||
| 
 | ||||
| //     qDebug() <<  QDate::currentDate().toString() << " "<< QTime::currentTime().toString();
 | ||||
|  | @ -60,12 +69,6 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent) | |||
|      ola->blockSignals(true); | ||||
|      ola->start(QThread::TimeCriticalPriority ); | ||||
| 
 | ||||
| /*     connect(MediaLibrary::getInstance(), SIGNAL(debug(QString)),
 | ||||
|      textEdit, SLOT(append(QString)), Qt::QueuedConnection); | ||||
| 
 | ||||
|      connect(MediaLibrary::getInstance(), SIGNAL(warning(QString)), | ||||
|      textEdit, SLOT(append(QString)), Qt::QueuedConnection); | ||||
| */ | ||||
|      // Inicia el widget Master.
 | ||||
|      amw = new AudioMasterWidget(this); | ||||
|      QDockWidget *topWidget = new QDockWidget(tr("Master"), this); | ||||
|  | @ -85,8 +88,8 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent) | |||
|             ola, SLOT( setLayersNumber(int))); | ||||
|     connect(set, SIGNAL( DMXConf(dmxSetting ) ), | ||||
|             ola, SLOT( setDMXConf(dmxSetting) ) ); | ||||
|     connect(ola, SIGNAL (layerReceived(int)), | ||||
|             aw, SLOT(layerReceived(int))); | ||||
|     connect(ola, SIGNAL (layerReceived()), | ||||
|             amw, SLOT(updateWatchDMX())); | ||||
| 
 | ||||
|     // Lee la configuración por defecto
 | ||||
|     set->readDefaultFile(); | ||||
|  | @ -224,7 +227,7 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value) | |||
| /**
 | ||||
|  * Send the DMX info to Pure Data in init | ||||
|  * | ||||
|  */ | ||||
|  * | ||||
| void libreMediaServerAudio::loadbang() { | ||||
|     ola->resendDmx(); | ||||
| } | ||||
| }*/ | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ | |||
| #include <QFileDialog> | ||||
| #include <QTextStream> | ||||
| #include <QWebView> | ||||
| #include <QUrl> | ||||
| //#include <QUrl>
 | ||||
| #include <QVBoxLayout> | ||||
| #include <QTextEdit> | ||||
| 
 | ||||
|  | @ -51,7 +51,7 @@ public: | |||
| 
 | ||||
|     Ui::LibreMediaServerAudio ui; | ||||
| 
 | ||||
|     static QTextEdit *textEdit; // Terminal de feedback
 | ||||
| //    static QTextEdit *textEdit; // Terminal de feedback
 | ||||
| 
 | ||||
| protected: | ||||
| 
 | ||||
|  | @ -74,11 +74,7 @@ public slots: | |||
| 
 | ||||
| private slots: | ||||
| 
 | ||||
|     /**
 | ||||
|      * @brief loadbang The audio motor engine is setup. Resend the dmx info to maintain aupdated to the current state | ||||
|      */ | ||||
| 
 | ||||
|     void loadbang(); | ||||
| //    void loadbang();
 | ||||
|     void olasetup(); | ||||
|     void dmxInput(int layer, int channel, int value); | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										18
									
								
								src/main.cpp
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								src/main.cpp
									
										
									
									
									
								
							|  | @ -19,16 +19,16 @@ | |||
| */ | ||||
| 
 | ||||
| #include <QApplication> | ||||
| #include <QMutex> | ||||
| #include <QMutexLocker> | ||||
| //#include <QMutex>
 | ||||
| //#include <QMutexLocker>
 | ||||
| #include "libremediaserver-audio.h" | ||||
| 
 | ||||
| // Handler for pipe the stderr to a log file and texEdit
 | ||||
| bool initMessageHandler = false; | ||||
| QFile outFile; | ||||
| QMutex mutex; | ||||
| //bool initMessageHandler = false;
 | ||||
| //QFile outFile;
 | ||||
| //QMutex mutex;
 | ||||
| //QMutexLocker mutexLocker(mutex);
 | ||||
| 
 | ||||
| /*
 | ||||
| void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) | ||||
| { | ||||
|     Q_UNUSED(context); | ||||
|  | @ -56,7 +56,7 @@ void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QSt | |||
|         initMessageHandler = true; | ||||
|     } | ||||
|     QTextStream ts(&outFile);*/ | ||||
|     if (libreMediaServerAudio::textEdit == 0) | ||||
| /*    if (libreMediaServerAudio::textEdit == 0)
 | ||||
|      { | ||||
|          QByteArray localMsg = msg.toLocal8Bit(); | ||||
|          switch (type) { | ||||
|  | @ -134,7 +134,7 @@ void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QSt | |||
| //    libreMediaServerAudio::textEdit->append(txt);
 | ||||
|     } | ||||
| //    mutex.unlock();
 | ||||
| } | ||||
| }*/ | ||||
| 
 | ||||
| int main(int argc, char *argv[]) | ||||
| { | ||||
|  | @ -145,7 +145,7 @@ int main(int argc, char *argv[]) | |||
|     { | ||||
|           qInstallMessageHandler(MessageHandler); | ||||
|     }*/ | ||||
|   qInstallMessageHandler(MessageHandler); | ||||
| //  qInstallMessageHandler(MessageHandler);
 | ||||
|   QApplication app(argc, argv); | ||||
| 
 | ||||
|   QStringList args = app.arguments(); | ||||
|  |  | |||
|  | @ -88,11 +88,11 @@ void olaThread::NewDmx(const ola::client::DMXMetadata &data, | |||
|     m_counter++; | ||||
|     gettimeofday(&m_last_data, NULL); | ||||
|     uint universe = data.universe; | ||||
|     emit layerReceived(); | ||||
|     for (int i = 0; i < m_layersNumber; i++) { // loop for reading the channels by layer.
 | ||||
|       if(m_settings.at(i).universe == universe) { // Compare if the layer is from this universe
 | ||||
|         if ( m_settings.at(i).address > -1 ) { //  AND if the DMX address is 0 or greater, process this layer.
 | ||||
|             emit layerReceived(i); | ||||
|             for (int j = 0; j < LAYER_CHANNELS; j++){ | ||||
|            for (int j = 0; j < LAYER_CHANNELS; j++){ | ||||
|             int value = buffer.Get((m_settings.at(i).address) + j); // Get the value for this channel.
 | ||||
|             if (m_dmx[i][j] != value) { // Compare the new value with the old value.
 | ||||
|               emit dmxOutput(i,j,value); | ||||
|  |  | |||
|  | @ -100,7 +100,7 @@ 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 layerReceived(int i); | ||||
|     void layerReceived(); | ||||
| }; | ||||
| 
 | ||||
| using namespace ola; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue