mejor rendimiento
This commit is contained in:
parent
246a8a2f98
commit
d34b972a54
11 changed files with 47 additions and 48 deletions
|
@ -51,7 +51,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
||||||
m_progressTime->setDisplayFormat("mm:ss:zz");
|
m_progressTime->setDisplayFormat("mm:ss:zz");
|
||||||
m_progressTime->setReadOnly(true);
|
m_progressTime->setReadOnly(true);
|
||||||
m_progressTime->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
m_progressTime->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||||
m_progressTime->setMaximumWidth(75);
|
m_progressTime->setMinimumWidth(80);
|
||||||
m_progressTime->setFocusPolicy(Qt::NoFocus);
|
m_progressTime->setFocusPolicy(Qt::NoFocus);
|
||||||
m_progressTime->setAlignment(Qt::AlignHCenter);
|
m_progressTime->setAlignment(Qt::AlignHCenter);
|
||||||
m_progressTime->setContentsMargins(0,0,0,0);
|
m_progressTime->setContentsMargins(0,0,0,0);
|
||||||
|
@ -61,7 +61,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
||||||
m_totalTimeValue->setDisplayFormat("mm:ss:zz");
|
m_totalTimeValue->setDisplayFormat("mm:ss:zz");
|
||||||
m_totalTimeValue->setReadOnly(true);
|
m_totalTimeValue->setReadOnly(true);
|
||||||
m_totalTimeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
m_totalTimeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||||
m_totalTimeValue->setMaximumWidth(75);
|
m_totalTimeValue->setMinimumWidth(80);
|
||||||
m_totalTimeValue->setFocusPolicy(Qt::NoFocus);
|
m_totalTimeValue->setFocusPolicy(Qt::NoFocus);
|
||||||
m_totalTimeValue->setAlignment(Qt::AlignHCenter);
|
m_totalTimeValue->setAlignment(Qt::AlignHCenter);
|
||||||
m_totalTimeValue->setContentsMargins(0,0,0,0);
|
m_totalTimeValue->setContentsMargins(0,0,0,0);
|
||||||
|
@ -119,8 +119,8 @@ void AudioLayerWidget::toggleSuspendResume()
|
||||||
break;
|
break;
|
||||||
case Status::Paused:
|
case Status::Paused:
|
||||||
case Status::Stopped:
|
case Status::Stopped:
|
||||||
//this->setPlaybackStatus(Status::PlayingOnce);
|
this->setPlaybackStatus(Status::PlayingLoop);
|
||||||
emit uiPlaybackChanged(m_layer, Status::PlayingOnce);
|
emit uiPlaybackChanged(m_layer, Status::PlayingLoop);
|
||||||
case Status::Iddle:
|
case Status::Iddle:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -176,12 +176,12 @@ void AudioLayerWidget::fileLoaded(QString file)
|
||||||
|
|
||||||
void AudioLayerWidget::setPlaybackStatus(Status status)
|
void AudioLayerWidget::setPlaybackStatus(Status status)
|
||||||
{
|
{
|
||||||
if (StatusStr[status] == m_suspendResumeButton->text())
|
if (!strcmp(StatusStr[status], m_suspendResumeButton->text().toLatin1().constData()))
|
||||||
return;
|
return;
|
||||||
m_suspendResumeButton->blockSignals(true);
|
m_suspendResumeButton->blockSignals(true);
|
||||||
m_status = status;
|
m_status = status;
|
||||||
if (status == Status::Stopped)
|
if (status == Status::Stopped)
|
||||||
m_progress->setValue(0);
|
refreshCurrentTime(0);
|
||||||
m_suspendResumeButton->setText(StatusStr[status]);
|
m_suspendResumeButton->setText(StatusStr[status]);
|
||||||
m_suspendResumeButton->blockSignals(false);
|
m_suspendResumeButton->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ void AudioLayerWidget::durationChanged(float dur)
|
||||||
m_totalTimeValue->blockSignals(false);
|
m_totalTimeValue->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::refreshUi(float progress)
|
void AudioLayerWidget::refreshCurrentTime(float progress)
|
||||||
{
|
{
|
||||||
progress *= 1000;
|
progress *= 1000;
|
||||||
m_progress->blockSignals(true);
|
m_progress->blockSignals(true);
|
||||||
|
|
|
@ -46,7 +46,7 @@ public slots:
|
||||||
void pitchChanged(int pitch);
|
void pitchChanged(int pitch);
|
||||||
void fileLoaded(QString file);
|
void fileLoaded(QString file);
|
||||||
void durationChanged(float dur);
|
void durationChanged(float dur);
|
||||||
void refreshUi(float progress);
|
void refreshCurrentTime(float progress);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void openMediaDialog();
|
void openMediaDialog();
|
||||||
|
|
|
@ -49,5 +49,5 @@ void AudioWidget::cursorChanged(int layer, float cursor)
|
||||||
{
|
{
|
||||||
QLayoutItem * const item = m_layout->itemAt(layer);
|
QLayoutItem * const item = m_layout->itemAt(layer);
|
||||||
AudioLayerWidget *alw = dynamic_cast<AudioLayerWidget *>(item->widget());
|
AudioLayerWidget *alw = dynamic_cast<AudioLayerWidget *>(item->widget());
|
||||||
alw->refreshUi(cursor);
|
alw->refreshCurrentTime(cursor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#define LICENSE "GPL 3 Licensed. See LICENSE.txt."
|
#define LICENSE "GPL 3 Licensed. See LICENSE.txt."
|
||||||
#define DEFAULT_FILE "lms-audio.xlm"
|
#define DEFAULT_FILE "lms-audio.xlm"
|
||||||
#define MAX_LAYERS 4
|
#define MAX_LAYERS 4
|
||||||
#define UI_REFRESH_TIME 200
|
#define UI_REFRESH_TIME 93
|
||||||
|
|
||||||
// struct where save the DMX settings for each layer
|
// struct where save the DMX settings for each layer
|
||||||
struct dmxSetting {
|
struct dmxSetting {
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<author>Santi Noreña lms@criptomart.net</author>
|
<author>Santi Noreña lms@criptomart.net</author>
|
||||||
<class>LibreMediaServerAudio</class>
|
<class>LibreMediaServerAudio</class>
|
||||||
<widget class="QMainWindow" name="LibreMediaServer Audio">
|
<widget class="QMainWindow" name="LibreMediaServerAudio">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>500</width>
|
||||||
<height>800</height>
|
<height>400</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>114</width>
|
<width>500</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -40,16 +40,9 @@ libreMediaServerAudio::libreMediaServerAudio(bool gui)
|
||||||
connect(m_ola, SIGNAL(dmxOutput(int, int, int)), this, SLOT(dmxInput(int, int, int)));
|
connect(m_ola, SIGNAL(dmxOutput(int, int, int)), this, SLOT(dmxInput(int, int, int)));
|
||||||
m_ola->registerUniverse();
|
m_ola->registerUniverse();
|
||||||
m_mae.startEngine(set->getAudioDeviceId());
|
m_mae.startEngine(set->getAudioDeviceId());
|
||||||
qDebug("Init Complete.");
|
qDebug("Core init Complete. Start reading DMX.");
|
||||||
m_ola->blockSignals(false);
|
m_ola->blockSignals(false);
|
||||||
m_ola->start(QThread::TimeCriticalPriority );
|
m_ola->start(QThread::TimeCriticalPriority );
|
||||||
#ifndef NOGUI
|
|
||||||
if (m_ui) {
|
|
||||||
m_refreshUi = new QTimer(this);
|
|
||||||
connect(m_refreshUi, SIGNAL(timeout()), this, SLOT(refreshUi()));
|
|
||||||
m_refreshUi->start(UI_REFRESH_TIME);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
libreMediaServerAudio::~libreMediaServerAudio()
|
libreMediaServerAudio::~libreMediaServerAudio()
|
||||||
|
@ -73,7 +66,7 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
|
||||||
if (QFile::exists(mediaFile)){
|
if (QFile::exists(mediaFile)){
|
||||||
m_mae.loadMedia(layer, mediaFile.toLatin1().data());
|
m_mae.loadMedia(layer, mediaFile.toLatin1().data());
|
||||||
m_currentMedia[layer] = mediaFile;
|
m_currentMedia[layer] = mediaFile;
|
||||||
#ifndef NOGIO
|
#ifndef NOGUI
|
||||||
if (m_ui)
|
if (m_ui)
|
||||||
m_lmsUi->m_aw->mediaLoaded(layer, mediaFile, m_mae.getDuration(layer));
|
m_lmsUi->m_aw->mediaLoaded(layer, mediaFile, m_mae.getDuration(layer));
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,7 +75,7 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
|
||||||
} else if (channel == VOLUME_COARSE || channel == VOLUME_FINE) {
|
} else if (channel == VOLUME_COARSE || channel == VOLUME_FINE) {
|
||||||
float tmp = value / 65025.0f;
|
float tmp = value / 65025.0f;
|
||||||
m_mae.volChanged(layer, tmp);
|
m_mae.volChanged(layer, tmp);
|
||||||
m_updateUi[layer][0] = tmp * 100;
|
m_updateUi[layer][0] = tmp * 100.0f;
|
||||||
} else if (channel == PAN) {
|
} else if (channel == PAN) {
|
||||||
m_mae.panChanged(layer, value);
|
m_mae.panChanged(layer, value);
|
||||||
m_updateUi[layer][1] = value;
|
m_updateUi[layer][1] = value;
|
||||||
|
@ -98,21 +91,19 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
|
||||||
} else if (channel == PLAYBACK && value > 0) {
|
} else if (channel == PLAYBACK && value > 0) {
|
||||||
aux = value / 25;
|
aux = value / 25;
|
||||||
Status s = m_currentStatus[layer];
|
Status s = m_currentStatus[layer];
|
||||||
if (s != aux) {
|
if (aux == 0)
|
||||||
if (aux == 0)
|
s = Status::PlayingOnce;
|
||||||
s = Status::PlayingOnce;
|
else if (aux == 1)
|
||||||
else if (aux == 1)
|
s = Status::Stopped;
|
||||||
s = Status::Stopped;
|
else if (aux == 2)
|
||||||
else if (aux == 2)
|
s = Status::Paused;
|
||||||
s = Status::Paused;
|
else if (aux == 3)
|
||||||
else if (aux == 3)
|
s = Status::PlayingLoop;
|
||||||
s = Status::PlayingLoop;
|
m_mae.playbackChanged(layer, s);
|
||||||
m_mae.playbackChanged(layer, s);
|
m_currentStatus[layer] = s;
|
||||||
m_currentStatus[layer] = s;
|
|
||||||
#ifndef NOGUI
|
#ifndef NOGUI
|
||||||
if (m_ui) m_lmsUi->m_aw->playbackChanged(layer, s);
|
if (m_ui) m_lmsUi->m_aw->playbackChanged(layer, s);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +127,7 @@ void libreMediaServerAudio::refreshUi() {
|
||||||
m_lmsUi->m_aw->pitchChanged(i, m_updateUi[i][2]);
|
m_lmsUi->m_aw->pitchChanged(i, m_updateUi[i][2]);
|
||||||
m_updateUi[i][2] = -1;
|
m_updateUi[i][2] = -1;
|
||||||
}
|
}
|
||||||
|
//m_lmsUi->m_aw->playbackChanged(i, m_currentStatus[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +138,9 @@ void libreMediaServerAudio::setUi(libreMediaServerAudioUi *lmsUi)
|
||||||
connect(m_lmsUi->m_aw, SIGNAL(uiSliderChanged(int, Slider, int)), this, SLOT(uiSliderChanged(int, Slider, int)));
|
connect(m_lmsUi->m_aw, SIGNAL(uiSliderChanged(int, Slider, int)), this, SLOT(uiSliderChanged(int, Slider, int)));
|
||||||
connect(m_lmsUi->m_aw, SIGNAL(uiPlaybackChanged(int, Status)), this, SLOT(uiPlaybackChanged(int, Status)));
|
connect(m_lmsUi->m_aw, SIGNAL(uiPlaybackChanged(int, Status)), this, SLOT(uiPlaybackChanged(int, Status)));
|
||||||
connect(m_lmsUi->m_aw, SIGNAL(uiLoadMedia(int, QString)), this, SLOT(uiLoadMedia(int, QString)));
|
connect(m_lmsUi->m_aw, SIGNAL(uiLoadMedia(int, QString)), this, SLOT(uiLoadMedia(int, QString)));
|
||||||
|
m_refreshUi = new QTimer(this);
|
||||||
|
connect(m_refreshUi, SIGNAL(timeout()), this, SLOT(refreshUi()));
|
||||||
|
m_refreshUi->start(UI_REFRESH_TIME);
|
||||||
};
|
};
|
||||||
|
|
||||||
void libreMediaServerAudio::uiSliderChanged(int layer, Slider s, int value)
|
void libreMediaServerAudio::uiSliderChanged(int layer, Slider s, int value)
|
||||||
|
@ -166,6 +161,7 @@ void libreMediaServerAudio::uiSliderChanged(int layer, Slider s, int value)
|
||||||
void libreMediaServerAudio::uiPlaybackChanged(int layer, Status s)
|
void libreMediaServerAudio::uiPlaybackChanged(int layer, Status s)
|
||||||
{
|
{
|
||||||
m_mae.playbackChanged(layer, s);
|
m_mae.playbackChanged(layer, s);
|
||||||
|
m_currentStatus[layer] = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void libreMediaServerAudio::uiLoadMedia(int layer, QString s)
|
void libreMediaServerAudio::uiLoadMedia(int layer, QString s)
|
||||||
|
|
|
@ -49,7 +49,7 @@ private:
|
||||||
bool m_ui;
|
bool m_ui;
|
||||||
QTimer *m_refreshUi;
|
QTimer *m_refreshUi;
|
||||||
libreMediaServerAudioUi *m_lmsUi;
|
libreMediaServerAudioUi *m_lmsUi;
|
||||||
int m_updateUi[MAX_LAYERS][3];
|
float m_updateUi[MAX_LAYERS][3];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -32,7 +32,6 @@ bool hasUi(int &argc, char *argv[])
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
libreMediaServerAudio lms(hasUi(argc, argv));
|
libreMediaServerAudio lms(hasUi(argc, argv));
|
||||||
#ifndef NOGUI
|
#ifndef NOGUI
|
||||||
if (hasUi(argc, argv))
|
if (hasUi(argc, argv))
|
||||||
|
|
|
@ -195,8 +195,9 @@ void MiniAudioEngine::volChanged(int layer, float vol)
|
||||||
{
|
{
|
||||||
if (m_mediaLoaded[layer] == false)
|
if (m_mediaLoaded[layer] == false)
|
||||||
return;
|
return;
|
||||||
|
if (vol > 1)
|
||||||
|
vol = 1;
|
||||||
ma_sound_group_set_volume(&m_currentSound[layer], vol);
|
ma_sound_group_set_volume(&m_currentSound[layer], vol);
|
||||||
qDebug() << "vol: " << vol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MiniAudioEngine::panChanged(int layer, float value)
|
void MiniAudioEngine::panChanged(int layer, float value)
|
||||||
|
|
|
@ -27,6 +27,7 @@ protected:
|
||||||
void setCursor(int layer, int cursor);
|
void setCursor(int layer, int cursor);
|
||||||
ma_result printFormatInfo(int layer);
|
ma_result printFormatInfo(int layer);
|
||||||
Status getStatus(int layer);
|
Status getStatus(int layer);
|
||||||
|
inline float getVol(int layer) { return ma_sound_get_volume(&m_currentSound[layer]); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ma_resource_manager_config resourceManagerConfig;
|
ma_resource_manager_config resourceManagerConfig;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "slidergroup.h"
|
#include "slidergroup.h"
|
||||||
|
#include <QCursor>
|
||||||
SliderGroup::SliderGroup(QString name,
|
SliderGroup::SliderGroup(QString name,
|
||||||
int min,
|
int min,
|
||||||
int max,
|
int max,
|
||||||
|
@ -15,22 +15,22 @@ SliderGroup::SliderGroup(QString name,
|
||||||
slider->setFocusPolicy(Qt::StrongFocus);
|
slider->setFocusPolicy(Qt::StrongFocus);
|
||||||
slider->setTickPosition(QSlider::TicksBothSides);
|
slider->setTickPosition(QSlider::TicksBothSides);
|
||||||
slider->setTickInterval((max - min) / 11);
|
slider->setTickInterval((max - min) / 11);
|
||||||
slider->setMinimumHeight(100);
|
slider->setMinimumHeight(0);
|
||||||
slider->setSingleStep(1);
|
slider->setSingleStep(1);
|
||||||
slider->setRange(min, max);
|
slider->setRange(min, max);
|
||||||
//slider->setMaximumWidth(40);
|
slider->setMinimumWidth(50);
|
||||||
slider->setToolTip(name);
|
slider->setToolTip(name);
|
||||||
slider->setStyleSheet("QSlider {"
|
slider->setStyleSheet("QSlider {"
|
||||||
"border: 1px solid #999999;"
|
"border: 2px solid #685060;"
|
||||||
"margin: 0px;"
|
"margin: 0px;"
|
||||||
"height: 200px;"
|
"height: 200px;"
|
||||||
"width: 40px;}"
|
"width: 50px;}"
|
||||||
);
|
);
|
||||||
slider->setContentsMargins(0, 0, 0, 0);
|
slider->setContentsMargins(0, 0, 0, 0);
|
||||||
valueBox = new QDoubleSpinBox();
|
valueBox = new QDoubleSpinBox();
|
||||||
valueBox->setFocusPolicy(Qt::NoFocus);
|
valueBox->setFocusPolicy(Qt::NoFocus);
|
||||||
valueBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
valueBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||||
//valueBox->setMaximumWidth(40);
|
valueBox->setMinimumWidth(50);
|
||||||
valueBox->setRange(min, max);
|
valueBox->setRange(min, max);
|
||||||
valueBox->setDecimals(decimals);
|
valueBox->setDecimals(decimals);
|
||||||
valueBox->setObjectName(name);
|
valueBox->setObjectName(name);
|
||||||
|
@ -40,8 +40,8 @@ SliderGroup::SliderGroup(QString name,
|
||||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
|
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
|
||||||
layout->addWidget(slider);
|
layout->addWidget(slider);
|
||||||
layout->addWidget(valueBox);
|
layout->addWidget(valueBox);
|
||||||
this->setStyleSheet("border: 1px solid #999999;"
|
this->setStyleSheet("border: 2px solid #685060;"
|
||||||
"width: 40px;"
|
"width: 50px;"
|
||||||
"margin: 0px;"
|
"margin: 0px;"
|
||||||
);
|
);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
|
@ -51,7 +51,9 @@ SliderGroup::SliderGroup(QString name,
|
||||||
|
|
||||||
void SliderGroup::sliderValueChanged(int value)
|
void SliderGroup::sliderValueChanged(int value)
|
||||||
{
|
{
|
||||||
|
valueBox->blockSignals(true);
|
||||||
valueBox->setValue(value);
|
valueBox->setValue(value);
|
||||||
|
valueBox->blockSignals(false);
|
||||||
emit valueChanged(value);
|
emit valueChanged(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue