indicador de volumen con dos decimales

This commit is contained in:
snt 2024-04-24 20:23:20 +02:00
parent 32a1e5cb0c
commit 3613d8fa51
12 changed files with 53 additions and 187 deletions

View file

@ -17,6 +17,7 @@ v 0.2.0 Antigona (24/04/2024)
+ mp3, flac, wav (mp3 has given some errors seeking cursor...). + mp3, flac, wav (mp3 has given some errors seeking cursor...).
+ settings dialog not working, only read the conf file at startup. + settings dialog not working, only read the conf file at startup.
+ variable number of layers. + variable number of layers.
+ olathread, send double channels only once for each dmx frame buffer.
v 0.1.3 Unreleased (19/04/2024) v 0.1.3 Unreleased (19/04/2024)

View file

@ -27,7 +27,6 @@ v 0.2.2
v 0.2.1 v 0.2.1
- Multi devices output. - Multi devices output.
- Rose noise and sine generator in menu to test system.
- Play Mode: - Play Mode:
- Play all medias found in folder consecutevily or random, with loop. - Play all medias found in folder consecutevily or random, with loop.
- Play all medias, consecutevily and random, with loop. - Play all medias, consecutevily and random, with loop.
@ -41,6 +40,7 @@ v 0.2.1
- magicq .hed - magicq .hed
- audio device linked, outputs will be redirected there. - audio device linked, outputs will be redirected there.
- dmx address + universe settings. - dmx address + universe settings.
- Rose noise and sine generator in menu to test system.
- Keyboards strokes, load media files from ui. - Keyboards strokes, load media files from ui.
- Dar la opción clickeando en el widget de tiempo de poner una cuenta atrás en vez de hacia delante. - Dar la opción clickeando en el widget de tiempo de poner una cuenta atrás en vez de hacia delante.
- Logs, verbosity, timestamp. - Logs, verbosity, timestamp.
@ -51,6 +51,5 @@ v 0.2.1
- Load/save conf file. - Load/save conf file.
- ¿stop offset? is it needed? - ¿stop offset? is it needed?
- decouple MiniAudioEngine from AudioWidget, starts whith no gui or with audio in a dedicated thread. - decouple MiniAudioEngine from AudioWidget, starts whith no gui or with audio in a dedicated thread.
- olathread, send double channels only once for each dmx frame buffer.
- New Status "Iddle" in playbacks if is not loaded. - New Status "Iddle" in playbacks if is not loaded.
- check return errors, we are too happy.... - check return errors, we are too happy....

View file

@ -10,9 +10,6 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name, int layer):
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
QHBoxLayout *progressTime = new QHBoxLayout; QHBoxLayout *progressTime = new QHBoxLayout;
//m_progressTimeLabel = new QLabel;
//m_progressTimeLabel->setText(PROGRESS_TIME_LABEL);
//progressTime->addWidget(m_progressTimeLabel);
m_progressTime = new QTimeEdit; m_progressTime = new QTimeEdit;
m_progressTime->text(); m_progressTime->text();
m_progressTime->setDisplayFormat("h:mm:ss:zzz"); m_progressTime->setDisplayFormat("h:mm:ss:zzz");
@ -21,9 +18,6 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name, int layer):
m_progressTime->setMaximumWidth(90); m_progressTime->setMaximumWidth(90);
m_progressTime->setFocusPolicy(Qt::NoFocus); m_progressTime->setFocusPolicy(Qt::NoFocus);
progressTime->addWidget(m_progressTime); progressTime->addWidget(m_progressTime);
//m_totalTimeLabel = new QLabel;
//m_totalTimeLabel->setText(TOTAL_TIME_LABEL);
//progressTime->addWidget(m_totalTimeLabel);
m_totalTimeValue = new QTimeEdit; m_totalTimeValue = new QTimeEdit;
m_totalTimeValue->setDisplayFormat("h:mm:ss:zzz"); m_totalTimeValue->setDisplayFormat("h:mm:ss:zzz");
m_totalTimeValue->setReadOnly(true); m_totalTimeValue->setReadOnly(true);
@ -49,19 +43,19 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name, int layer):
layout->addLayout(status); layout->addLayout(status);
QHBoxLayout *volumeBox = new QHBoxLayout; QHBoxLayout *volumeBox = new QHBoxLayout;
m_volume = new SliderGroup("Vol", 0 , 100, NULL); m_volume = new SliderGroup("Vol", 0 , 100, 2, NULL);
volumeBox->addWidget(m_volume); volumeBox->addWidget(m_volume);
connect(m_volume, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int))); connect(m_volume, SIGNAL(valueChanged(float)), this, SLOT(volumeChanged(float)));
m_pan = new SliderGroup("Pan", 0 , 255, NULL); m_pan = new SliderGroup("Pan", 0 , 255, 0, NULL);
volumeBox->addWidget(m_pan); volumeBox->addWidget(m_pan);
connect(m_pan, SIGNAL(valueChanged(int)), this, SLOT(panChanged(int))); connect(m_pan, SIGNAL(valueChanged(float)), this, SLOT(panChanged(float)));
m_pitch = new SliderGroup("Pitch", 0 , 255, NULL); m_pitch = new SliderGroup("Pitch", 0 , 255, 0, NULL);
volumeBox->addWidget(m_pitch); volumeBox->addWidget(m_pitch);
connect(m_pitch, SIGNAL(valueChanged(int)), this, SLOT(pitchChanged(int))); connect(m_pitch, SIGNAL(valueChanged(float)), this, SLOT(pitchChanged(float)));
layout->addLayout(volumeBox); layout->addLayout(volumeBox);
m_suspendResumeButton = new QPushButton(this); m_suspendResumeButton = new QPushButton(this);
m_suspendResumeButton->setText(tr(SUSPEND_LABEL)); m_suspendResumeButton->setText(StatusStr[Status::Stopped]);
connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspendResume())); connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspendResume()));
layout->addWidget(m_suspendResumeButton); layout->addWidget(m_suspendResumeButton);
@ -74,17 +68,17 @@ AudioLayerWidget::~AudioLayerWidget()
} }
// From UI. // From UI.
void AudioLayerWidget::volumeChanged(int value) void AudioLayerWidget::volumeChanged(float value)
{ {
emit(uiSliderChanged(m_layer, Slider::Volume, value)); emit(uiSliderChanged(m_layer, Slider::Volume, value));
} }
void AudioLayerWidget::panChanged(int value) void AudioLayerWidget::panChanged(float value)
{ {
emit(uiSliderChanged(m_layer, Slider::Pan, value)); emit(uiSliderChanged(m_layer, Slider::Pan, value));
} }
void AudioLayerWidget::pitchChanged(int value) void AudioLayerWidget::pitchChanged(float value)
{ {
emit(uiSliderChanged(m_layer, Slider::Pitch, value)); emit(uiSliderChanged(m_layer, Slider::Pitch, value));
} }
@ -106,7 +100,7 @@ void AudioLayerWidget::toggleSuspendResume()
} }
// from DMX signals // from DMX signals
void AudioLayerWidget::setVol(int vol) void AudioLayerWidget::setVol(float vol)
{ {
m_volume->blockSignals(true); m_volume->blockSignals(true);
m_volume->setValue(vol); m_volume->setValue(vol);

View file

@ -26,7 +26,7 @@ class AudioLayerWidget : public QGroupBox
public: public:
explicit AudioLayerWidget(QWidget *parent = 0, QString name = "Layer", int layer = 0); explicit AudioLayerWidget(QWidget *parent = 0, QString name = "Layer", int layer = 0);
~AudioLayerWidget(); ~AudioLayerWidget();
void setVol(int vol); void setVol(float vol);
void resume(); void resume();
void setPan(int pan); void setPan(int pan);
void setPitch(int pitch); void setPitch(int pitch);
@ -38,27 +38,21 @@ private:
Status m_status; Status m_status;
int m_layer; int m_layer;
QPushButton *m_suspendResumeButton; QPushButton *m_suspendResumeButton;
QLabel *m_statusLabel;
QLabel * m_statusValue; QLabel * m_statusValue;
QLabel *m_fileLabel;
QLabel *m_fileValue; QLabel *m_fileValue;
QLabel * m_folderLabel;
QLabel * m_folderValue; QLabel * m_folderValue;
SliderGroup *m_volume; SliderGroup *m_volume;
SliderGroup *m_pan; SliderGroup *m_pan;
SliderGroup *m_pitch; SliderGroup *m_pitch;
QLabel * m_progressLabel;
QSlider *m_progressSlider; QSlider *m_progressSlider;
QLabel *m_progressTimeLabel;
QTimeEdit *m_progressTime; QTimeEdit *m_progressTime;
QLabel *m_totalTimeLabel;
QTimeEdit *m_totalTimeValue; QTimeEdit *m_totalTimeValue;
public slots: public slots:
void toggleSuspendResume(); void toggleSuspendResume();
void volumeChanged(int vol); void volumeChanged(float vol);
void panChanged(int vol); void panChanged(float pan);
void pitchChanged(int vol); void pitchChanged(float pitch);
void fileLoaded(QString file); void fileLoaded(QString file);
void durationChanged(float dur); void durationChanged(float dur);
void refreshUi(float progress); void refreshUi(float progress);

View file

@ -56,7 +56,7 @@ void AudioWidget::mediaLoaded(int layer, QString file)
dynamic_cast<AudioLayerWidget *>(item->widget())->durationChanged(pLength); dynamic_cast<AudioLayerWidget *>(item->widget())->durationChanged(pLength);
} }
void AudioWidget::volChanged(int layer, int vol) { void AudioWidget::volChanged(int layer, float vol) {
m_mae.volChanged(layer, vol); m_mae.volChanged(layer, vol);
QLayoutItem * const item = m_layout->itemAt(layer); QLayoutItem * const item = m_layout->itemAt(layer);
dynamic_cast<AudioLayerWidget *>(item->widget())->setVol(vol); dynamic_cast<AudioLayerWidget *>(item->widget())->setVol(vol);

View file

@ -27,7 +27,7 @@ public:
protected: protected:
void mediaLoaded(int layer, QString media ); void mediaLoaded(int layer, QString media );
void volChanged(int layer, int vol); void volChanged(int layer, float vol);
void panChanged(int layer, int pan); void panChanged(int layer, int pan);
void pitchChanged(int layer, int pitch); void pitchChanged(int layer, int pitch);
void playbackChanged(int layer, Status status); void playbackChanged(int layer, Status status);

View file

@ -9,23 +9,8 @@
#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 DEFAULT_FILE "lms-audio.xlm" #define DEFAULT_FILE "lms-audio.xlm"
#define SUSPEND_LABEL "Pause"
#define RESUME_LABEL "Resume"
#define PLAY_LABEL "Play"
#define STOP_LABEL "Stop"
#define PAUSE_LABEL "Pause"
#define IDDLE_LABEL "Iddle playback"
#define VOLUME_LABEL "Vol"
#define PROGRESS_LABEL "Progress"
#define PROGRESS_TIME_LABEL "Current"
#define REMAINING_TIME "Remaining"
#define TOTAL_TIME_LABEL "Total"
#define NOTIFY_INTERVAL 150
#define PULL_TIMER_INTERVAL 10
#define MAX_DEVICES 16
#define MAX_SOUNDS 4096
#define MAX_LAYERS 16 #define MAX_LAYERS 16
#define UI_REFRESH_TIME 100 #define UI_REFRESH_TIME 200
// struct where save the DMX settings for each layer // struct where save the DMX settings for each layer
struct dmxSetting { struct dmxSetting {
@ -64,6 +49,7 @@ static const char* StatusStr[] =
"Pause", "Pause",
"Playing One", "Playing One",
"Playing Loop", "Playing Loop",
NULL
}; };
enum Slider enum Slider

View file

@ -122,7 +122,7 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
break; break;
case VOLUME_COARSE: case VOLUME_COARSE:
case VOLUME_FINE: case VOLUME_FINE:
aw->volChanged(layer, (value / 650.25)); aw->volChanged(layer, (value / 65025.0f));
break; break;
case PAN: case PAN:
aw->panChanged(layer, value); aw->panChanged(layer, value);

View file

@ -20,133 +20,11 @@
#include "libremediaserver-audio.h" #include "libremediaserver-audio.h"
// Handler for pipe the stderr to a log file and texEdit
//bool initMessageHandler = false;
//QFile outFile;
//QMutex mutex;
//QMutexLocker mutexLocker(mutex);
/*
void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
Q_UNUSED(context);
// mutex.lock();
// Create the log dir and log file
if (!initMessageHandler) {
QDir dir;
if (!dir.exists("log")) {
if (!dir.mkdir("log")) {
qDebug()<<"MessageHandler: Can not create log folder";
return;
}
}
QString filename;
QDate date = QDate::currentDate();
QTime time = QTime::currentTime();
filename.append("./log/log_");
filename.append(date.toString("ddMMyy-"));
filename.append(time.toString("hhmmss.txt"));
outFile.setFileName(filename);
if (!outFile.open(QIODevice::WriteOnly | QIODevice::Append)) {
qWarning("main/MessageHandler/Qfile::open: can not open log file");
return;
}
initMessageHandler = true;
}
QTextStream ts(&outFile);*/
/* if (libreMediaServerAudio::textEdit == 0)
{
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
abort();
}
}
else
{
QString txt;
switch (type) {
case QtDebugMsg:
txt.append("Debug from File: ");
txt.append(context.file);
txt.append(" Line: ");
txt.append(QString::number(context.line));
// txt.append(" Function: ");
// txt.append(context.function);
txt.append(" Message: ");
txt.append(msg);
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
libreMediaServerAudio::textEdit->append(txt);
break;
case QtWarningMsg:
txt.append("Warning from File: ");
txt.append(context.file);
txt.append(" Line: ");
txt.append(QString::number(context.line));
txt.append(" Function: ");
txt.append(context.function);
txt.append(" Message: ");
txt.append(msg);
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
libreMediaServerAudio::textEdit->append(txt);
abort();
break;
case QtCriticalMsg:
// txt.append("Critical from File: ");
txt.append(context.file);
txt.append(" Line: ");
txt.append(QString::number(context.line));
txt.append(" Function: ");
txt.append(context.function);
txt.append(" Message ");
txt.append(msg);
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
libreMediaServerAudio::textEdit->append(txt);
abort();
break;
case QtFatalMsg:
// txt.append("Fatal from File: ");
txt.append(context.file);
txt.append(" Line: ");
txt.append(QString::number(context.line));
txt.append(" Function: ");
txt.append(context.function);
txt.append(" Message: ");
txt.append(msg);
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
libreMediaServerAudio::textEdit->append(txt);// ts << txt << endl;
abort();
}
// outFile.write(txt.toLatin1().constData(), txt.size());
// ts << txt << endl;
// libreMediaServerAudio::textEdit->append(txt);
}
// mutex.unlock();
}*/
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// ToDo: discriminar niveles de log y log a fichero segúna argumentos
/*
if (args.contains("-log"))
{
qInstallMessageHandler(MessageHandler);
}*/
QApplication app(argc, argv); QApplication app(argc, argv);
QStringList args = app.arguments(); QStringList args = app.arguments();
if (args.size() > 1) if (args.size() > 1)
{ {
if (args.contains("-v")) if (args.contains("-v"))
@ -163,7 +41,6 @@ int main(int argc, char *argv[])
qDebug() << LICENSE; qDebug() << LICENSE;
qDebug() << "Help for command line options:"; qDebug() << "Help for command line options:";
qDebug() << "-v show the version and exits"; qDebug() << "-v show the version and exits";
qDebug() << "-log write the debug information to a log file instead stderr";
qDebug() << "-h this help"; qDebug() << "-h this help";
return 0; return 0;
} }
@ -172,5 +49,3 @@ int main(int argc, char *argv[])
libreMediaServerAudio.show(); libreMediaServerAudio.show();
return app.exec(); return app.exec();
} }

View file

@ -183,15 +183,16 @@ ma_result MiniAudioEngine::printFormatInfo(int layer)
return result; return result;
} }
// Expects between 0 and 100 vol value in db // Expects between 0 and 1 vol value in db
void MiniAudioEngine::volChanged(int layer, float vol) void MiniAudioEngine::volChanged(int layer, float vol)
{ {
float result; //float result;
if (m_mediaLoaded[layer] == false) if (m_mediaLoaded[layer] == false)
return; return;
result = ma_volume_linear_to_db(1.00000000 + (vol / 800.0)); //result = ma_volume_linear_to_db(1.00000000 + (vol / 8.0));
ma_sound_group_set_volume(&m_currentSound[layer], result); //qInfo("vol %f %f", vol, result);
ma_sound_group_set_volume(&m_currentSound[layer], vol);
} }
void MiniAudioEngine::panChanged(int layer, float value) void MiniAudioEngine::panChanged(int layer, float value)

View file

@ -3,6 +3,7 @@
SliderGroup::SliderGroup(const QString &title, \ SliderGroup::SliderGroup(const QString &title, \
int min, int min,
int max, int max,
int decimals,
QWidget *parent) QWidget *parent)
: QGroupBox(title, parent) : QGroupBox(title, parent)
{ {
@ -14,17 +15,31 @@ SliderGroup::SliderGroup(const QString &title, \
slider->setTickInterval((max - min) / 11); slider->setTickInterval((max - min) / 11);
slider->setSingleStep(1); slider->setSingleStep(1);
slider->setRange(min, max); slider->setRange(min, max);
//slider->setInvertedAppearance(false); valueBox = new QDoubleSpinBox();
//slider->setInvertedControls(false);
valueBox = new QSpinBox();
valueBox->setFocusPolicy(Qt::NoFocus); valueBox->setFocusPolicy(Qt::NoFocus);
valueBox->setButtonSymbols(QAbstractSpinBox::NoButtons); valueBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
valueBox->setMaximumWidth(40); valueBox->setMaximumWidth(45);
valueBox->setRange(min, max); valueBox->setRange(min, max);
connect(slider, &QSlider::valueChanged, valueBox, &QSpinBox::setValue); valueBox->setDecimals(decimals);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int))); connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
QVBoxLayout *slidersLayout = new QVBoxLayout(); QVBoxLayout *slidersLayout = new QVBoxLayout();
slidersLayout->addWidget(valueBox); slidersLayout->addWidget(valueBox);
slidersLayout->addWidget(slider); slidersLayout->addWidget(slider);
setLayout(slidersLayout); setLayout(slidersLayout);
} }
void SliderGroup::sliderValueChanged(int value)
{
if (valueBox->decimals() > 1)
value /= 100.0f;
emit valueChanged(value);
valueBox->setValue(value);
};
void SliderGroup::setValue(float value)
{
if (valueBox->decimals() > 1)
value *= 100.0f;
slider->setValue(value);
valueBox->setValue(value);
}

View file

@ -21,18 +21,19 @@ public:
SliderGroup(const QString &title, SliderGroup(const QString &title,
int min, int min,
int max, int max,
int decimals,
QWidget *parent = nullptr); QWidget *parent = nullptr);
signals: signals:
void valueChanged(int value); void valueChanged(float value);
public slots: public slots:
inline void setValue(int value) { slider->setValue(value); }; void setValue(float value);
inline void sliderValueChanged(int value) { emit valueChanged(value); }; void sliderValueChanged(int value);
private: private:
QSlider *slider; QSlider *slider;
QSpinBox *valueBox; QDoubleSpinBox *valueBox;
}; };
#endif #endif