solucionado el glich de verdad...
los loop points y range points no funcionan al final de l loop, es igual que seektoPCMFrame en su estado actual. cambios cosméticos
This commit is contained in:
parent
0d29dda4c1
commit
6a22534686
7 changed files with 87 additions and 35 deletions
|
@ -40,3 +40,5 @@ v 0.3.0
|
|||
- Hardening: check return errors, try/catch exceptions, i'm too happy....
|
||||
- Tests: errors on wrong conf file.
|
||||
- ampliar writer para recibir un número n de entradas y escribirlas cada una en un buffer
|
||||
- aislar miniaudio del callback dmx tal como hemos hecho con la Ui, al menos las operaciones lentas como cargar medios.
|
||||
- en load media usar un fence para actualizar mediaLoaded.
|
||||
|
|
|
@ -39,9 +39,8 @@ SOURCES += src/main.cpp \
|
|||
src/settings.cpp \
|
||||
src/slidergroup.cpp
|
||||
FORMS += src/libremediaserver-audio-gui.ui
|
||||
CCFLAG += -msse2 -mavx2 #-fsanitize=address -g3 -O0
|
||||
CCFLAG += -msse2 -mavx2
|
||||
QMAKE_CXXFLAGS += $$(CXXFLAG)
|
||||
#QMAKE_CXXFLAGS += -fsanitize=address -g3 -O0
|
||||
QMAKE_CFLAGS += $$(CCFLAG)
|
||||
QMAKE_LFLAGS += $$(LDFLAG)
|
||||
LIBS += -lola -lolacommon -ldl -lpthread -lm
|
||||
|
|
|
@ -93,33 +93,35 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
|||
layout->addLayout(volumeBox);
|
||||
QHBoxLayout *labelsBox = new QHBoxLayout;
|
||||
m_level = new QLabel("-inf");
|
||||
m_level->setStyleSheet("border: 1px solid #5a4855;"
|
||||
m_level->setStyleSheet("border: 1px solid #CFB0C9;"
|
||||
"margin: 0px;"
|
||||
"background-color: #180014;"
|
||||
"margin-right: 5px;"
|
||||
"margin-left: 5px;"
|
||||
"background-color: black;"
|
||||
"color: white;"
|
||||
"width:70px;"
|
||||
"width:80px;"
|
||||
"text-align: center;"
|
||||
);
|
||||
m_level->setMinimumWidth(70);
|
||||
m_level->setMinimumWidth(80);
|
||||
m_level->setMaximumWidth(80);
|
||||
m_level->setMinimumHeight(20);
|
||||
m_level->setAlignment(Qt::AlignHCenter);
|
||||
labelsBox->addWidget(m_level);
|
||||
m_bus1Label = new QLabel("dummy");
|
||||
m_bus1Label->setMinimumWidth(80);
|
||||
m_bus1Label->setStyleSheet("border: 1px solid #5a4855;"
|
||||
m_bus1Label->setStyleSheet("border: 1px solid #CFB0C9;"
|
||||
"margin: 0px;"
|
||||
"background-color: #383034;"
|
||||
"width:70px;"
|
||||
);
|
||||
m_bus1Label->setAlignment(Qt::AlignHCenter);
|
||||
"background-color: black;"
|
||||
"color: white;"
|
||||
"font-size: 11px;");
|
||||
labelsBox->addWidget(m_bus1Label);
|
||||
m_bus2Label = new QLabel("dummy");
|
||||
m_bus2Label->setMinimumWidth(80);
|
||||
m_bus2Label->setStyleSheet("border: 1px solid #5a4855;"
|
||||
m_bus2Label->setStyleSheet("border: 1px solid #CFB0C9;"
|
||||
"margin: 0px;"
|
||||
"background-color: #383034;"
|
||||
"width: 70px;"
|
||||
);
|
||||
m_bus2Label->setAlignment(Qt::AlignHCenter);
|
||||
"background-color: black;"
|
||||
"color: white;"
|
||||
"font-size: 11px;");
|
||||
labelsBox->addWidget(m_bus2Label);
|
||||
labelsBox->setSpacing(0);
|
||||
labelsBox->setContentsMargins(0, 0, 0, 0);
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#define FORMAT ma_format_f32 /* Must always be f32. */
|
||||
#define CHANNELS 2
|
||||
#define SAMPLE_RATE 48000
|
||||
#define UI_REFRESH_TIME 97
|
||||
#define FADE_TIME 25 // DMX Frame time, 40 fps, avoid clicks
|
||||
#define UI_REFRESH_TIME 123
|
||||
#define FADE_TIME 20
|
||||
#define FILTER_CHANNELS 16 // number of dmx channels dedicated to filters by layer
|
||||
|
||||
struct dmxSetting {
|
||||
|
|
|
@ -129,6 +129,7 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
|
|||
#ifndef NOGUI
|
||||
if (m_ui) {
|
||||
m_lmsUi->m_aw->playbackChanged(layer, s);
|
||||
m_updateUi[layer][3] = 1;
|
||||
m_played.clear();
|
||||
m_played.append(m_ola->getValue(layer, DMX_FILE));
|
||||
}
|
||||
|
@ -173,6 +174,7 @@ void libreMediaServerAudio::refreshUi() {
|
|||
if (m_mae.getAtEnd(i)) {
|
||||
if (m_currentStatus[i] == Status::PlayingOnce) {
|
||||
m_currentStatus[i] = Status::Stopped;
|
||||
m_lmsUi->m_aw->playbackChanged(i, Status::Stopped);
|
||||
}
|
||||
if (m_currentStatus[i] == Status::PlayingFolder) {
|
||||
uint last = m_played.last();
|
||||
|
@ -187,7 +189,7 @@ void libreMediaServerAudio::refreshUi() {
|
|||
m_lmsUi->m_aw->playbackChanged(i, Status::Stopped);
|
||||
}
|
||||
}
|
||||
if (m_currentStatus[i] == Status::PlayingFolderLoop) {
|
||||
else if (m_currentStatus[i] == Status::PlayingFolderLoop) {
|
||||
uint last = m_played.last();
|
||||
int folder = m_ola->getValue(i, DMX_FOLDER);
|
||||
last++;
|
||||
|
@ -199,7 +201,7 @@ void libreMediaServerAudio::refreshUi() {
|
|||
m_mae.playbackChanged(i, Status::PlayingFolder);
|
||||
}
|
||||
}
|
||||
if (m_currentStatus[i] == Status::PlayingFolderRandom) {
|
||||
else if (m_currentStatus[i] == Status::PlayingFolderRandom) {
|
||||
int last = -1;
|
||||
int folder = m_ola->getValue(i, DMX_FOLDER);
|
||||
if (uint(abs(m_played.size())) >= m_mediaLibrary->getMediaFolderCount(folder))
|
||||
|
|
|
@ -278,7 +278,7 @@ ma_result MiniAudioEngine::startDevices()
|
|||
deviceConfig.dataCallback = audioDataCallback;
|
||||
engineConfig = ma_engine_config_init();
|
||||
engineConfig.pResourceManager = &m_mae.resourceManager;
|
||||
engineConfig.defaultVolumeSmoothTimeInPCMFrames = SAMPLE_RATE / 20;
|
||||
//engineConfig.defaultVolumeSmoothTimeInPCMFrames = SAMPLE_RATE / 20;
|
||||
engineConfig.noAutoStart = MA_TRUE;
|
||||
|
||||
for (uint internalId = 0; internalId < m_mae.audioDevicesQty; internalId++) {
|
||||
|
@ -482,38 +482,85 @@ ma_result MiniAudioEngine::playbackChanged(int layer, Status status)
|
|||
case Status::PlayingLoop:
|
||||
loop = true;
|
||||
case Status::PlayingOnce:
|
||||
ma_sound_set_looping(&m_mae.sounds[layer], loop);
|
||||
if (m_mae.currentStatus[layer].cursor > 0) {
|
||||
this->setRangePoint(layer, m_mae.currentStatus[layer].cursor);
|
||||
this->setLoopPoint(layer, m_mae.currentStatus[layer].cursor);
|
||||
}
|
||||
case Status::PlayingFolder:
|
||||
case Status::PlayingFolderLoop:
|
||||
case Status::PlayingFolderRandom:
|
||||
ma_sound_set_stop_time_in_milliseconds(&m_mae.sounds[layer], ~(ma_uint64)0);
|
||||
ma_sound_set_looping(&m_mae.sounds[layer], loop);
|
||||
result = ma_sound_start(&m_mae.sounds[layer]);
|
||||
//this->volChanged(layer, m_mae.currentStatus[layer].vol);
|
||||
float db = (m_mae.currentStatus[layer].vol / 771.0f) - 85.0f;
|
||||
if (db <= -85.0f) {
|
||||
db = 0;
|
||||
} else
|
||||
db = ma_volume_db_to_linear(db);
|
||||
ma_sound_set_fade_in_milliseconds(&m_mae.sounds[layer], -1, db, 0);
|
||||
result = ma_sound_start(&m_mae.sounds[layer]);
|
||||
ma_sound_group_set_volume(&m_mae.sounds[layer], 0.0f);
|
||||
ma_sound_set_fade_in_milliseconds(&m_mae.sounds[layer], 0, db, FADE_TIME);
|
||||
ma_sound_group_set_volume(&m_mae.sounds[layer], 1.0f);
|
||||
}
|
||||
if (result == MA_SUCCESS)
|
||||
m_mae.currentStatus[layer].status = status;
|
||||
return result;
|
||||
}
|
||||
|
||||
ma_result MiniAudioEngine::seekToCursor(int layer, int cursor)
|
||||
ma_result MiniAudioEngine::setRangePoint(int layer, int cursor)
|
||||
{
|
||||
ma_result result = MA_SUCCESS;
|
||||
ma_uint64 end, start;
|
||||
ma_uint64 end = 0, start;
|
||||
|
||||
if (m_mae.mediaLoaded[layer] == false)
|
||||
return MA_DOES_NOT_EXIST;
|
||||
result = ma_sound_get_length_in_pcm_frames(&m_mae.sounds[layer], &end);
|
||||
if (result != MA_SUCCESS) { return result; }
|
||||
start = (cursor * end) / 65535;
|
||||
Status oldStatus = m_mae.currentStatus[layer].status;
|
||||
if (cursor == 0)
|
||||
start = 0;
|
||||
else {
|
||||
result = ma_sound_get_length_in_pcm_frames(&m_mae.sounds[layer], &end);
|
||||
if (result != MA_SUCCESS) { return result; }
|
||||
start = (cursor * end) / 65535;
|
||||
}
|
||||
result = ma_data_source_set_range_in_pcm_frames(&m_mae.sounds[layer].pDataSource, start, end);
|
||||
if (result != MA_SUCCESS)
|
||||
cout << "ERROR " << result << " :set range point" << endl;
|
||||
return (result);
|
||||
}
|
||||
|
||||
ma_result MiniAudioEngine::setLoopPoint(int layer, int cursor)
|
||||
{
|
||||
ma_result result = MA_SUCCESS;
|
||||
ma_uint64 end = 0, start;
|
||||
|
||||
if (m_mae.mediaLoaded[layer] == false)
|
||||
return MA_DOES_NOT_EXIST;
|
||||
if (cursor == 0)
|
||||
start = 0;
|
||||
else {
|
||||
result = ma_sound_get_length_in_pcm_frames(&m_mae.sounds[layer], &end);
|
||||
if (result != MA_SUCCESS) { return result; }
|
||||
start = (cursor * end) / 65535;
|
||||
}
|
||||
result = ma_data_source_set_loop_point_in_pcm_frames(&m_mae.sounds[layer].pDataSource, start + 1, end - 1);
|
||||
if (result != MA_SUCCESS)
|
||||
cout << "ERROR " << result << " :set loop point" << endl;
|
||||
return (result);
|
||||
}
|
||||
|
||||
ma_result MiniAudioEngine::seekToCursor(int layer, int cursor)
|
||||
{
|
||||
ma_result result = MA_SUCCESS;
|
||||
ma_uint64 end = 0, start;
|
||||
|
||||
if (m_mae.mediaLoaded[layer] == false)
|
||||
return MA_DOES_NOT_EXIST;
|
||||
if (cursor == 0)
|
||||
start = 0;
|
||||
else {
|
||||
result = ma_sound_get_length_in_pcm_frames(&m_mae.sounds[layer], &end);
|
||||
if (result != MA_SUCCESS) { return result; }
|
||||
start = (cursor * end) / 65535;
|
||||
}
|
||||
result = ma_sound_seek_to_pcm_frame(&m_mae.sounds[layer], start);
|
||||
//result = ma_data_source_set_loop_point_in_pcm_frames(&m_mae.sounds[layer], start, end); // this do nothing here, it must be done after set_looping or start?
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
@ -533,12 +580,9 @@ Status MiniAudioEngine::getStatus(int layer)
|
|||
|
||||
void MiniAudioEngine::refreshValues(int layer)
|
||||
{
|
||||
this->seekToCursor(layer, m_mae.currentStatus[layer].cursor);
|
||||
this->panChanged(layer, m_mae.currentStatus[layer].pan);
|
||||
this->pitchChanged(layer, m_mae.currentStatus[layer].pitch);
|
||||
ma_sound_group_set_fade_in_milliseconds(&m_mae.sounds[layer], -1, 0, 0.0f);
|
||||
this->playbackChanged(layer, m_mae.currentStatus[layer].status);
|
||||
this->volChanged(layer, m_mae.currentStatus[layer].vol);
|
||||
}
|
||||
|
||||
ma_result MiniAudioEngine::filterParamChanged(int layer, int channel, int value)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#define MA_ENABLE_ONLY_SPECIFIC_BACKENDS
|
||||
#define MA_ENABLE_JACK
|
||||
#define MA_DISABLE_PULSE
|
||||
#define MA_NO_GENERATION
|
||||
#define MA_DEBUG_OUTPUT
|
||||
#define MA_LOG_LEVEL_DEBUG DEBUG
|
||||
|
@ -97,6 +98,8 @@ private:
|
|||
ma_result seekToCursor(int layer, int cursor);
|
||||
ma_result setNodeGraph();
|
||||
ma_result createFilterBank(uint layer);
|
||||
ma_result setLoopPoint(int layer, int cursor);
|
||||
ma_result setRangePoint(int layer, int cursor);
|
||||
};
|
||||
|
||||
#endif // MINIAUDIOENGINE_H
|
||||
|
|
Loading…
Add table
Reference in a new issue