CueTrackListWidget ahora posee el contenedor de CueTracks y muestra un QTableWidget con info de las CueTracks.
360 lines
12 KiB
C++
360 lines
12 KiB
C++
#include "audiolayerwidget.h"
|
|
#include "dmxPersonality.h"
|
|
|
|
#include <QBoxLayout>
|
|
#include <QFileDialog>
|
|
|
|
AudioLayerWidget::AudioLayerWidget(QWidget *parent, int layer):
|
|
QWidget(parent)
|
|
, m_oldStatus(Status::PlayingLoop)
|
|
, m_layer(layer)
|
|
, m_suspendResumeButton(0)
|
|
{
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
|
m_folderValue = new ClickableLabel;
|
|
m_folderValue->setAlignment(Qt::AlignLeft);
|
|
m_folderValue->setFocusPolicy(Qt::NoFocus);
|
|
m_folderValue->setMinimumWidth(MIN_WIDTH);
|
|
m_folderValue->setMaximumWidth(MAX_WIDTH);
|
|
m_folderValue->setContentsMargins(3,1,3,1);
|
|
m_folderValue->setText("Click to open media file (mp3, wav, flac)");
|
|
m_folderValue->setStyleSheet(
|
|
"margin: 0px;"
|
|
"color: white;"
|
|
"background-color: black;"
|
|
"font-size: 12px;"
|
|
);
|
|
layout->addWidget(m_folderValue);
|
|
m_fileValue = new ClickableLabel;
|
|
m_fileValue->setAlignment(Qt::AlignLeft);
|
|
m_fileValue->setFocusPolicy(Qt::NoFocus);
|
|
m_fileValue->setMinimumWidth(MIN_WIDTH);
|
|
m_fileValue->setMaximumWidth(MAX_WIDTH);
|
|
m_fileValue->setContentsMargins(3,1,3,1);
|
|
m_fileValue->setText("++ empty ++");
|
|
connect(m_fileValue, SIGNAL(clicked()), this, SLOT(openMediaDialog()));
|
|
connect(m_folderValue, SIGNAL(clicked()), this, SLOT(openMediaDialog()));
|
|
m_fileValue->setStyleSheet(
|
|
"margin: 0px;"
|
|
"color: white;"
|
|
"background-color: black;"
|
|
"font-size: 14px;"
|
|
);
|
|
layout->addWidget(m_fileValue);
|
|
|
|
m_suspendResumeButton = new QPushButton(this);
|
|
m_suspendResumeButton->setText(statusToString(Status::Iddle));
|
|
connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspendResume()));
|
|
layout->addWidget(m_suspendResumeButton);
|
|
|
|
m_progress = new QProgressBar(this);
|
|
m_progress->setOrientation(Qt::Horizontal);
|
|
m_progress->setFocusPolicy(Qt::NoFocus);
|
|
m_progress->setAlignment(Qt::AlignHCenter);
|
|
m_progress->setContentsMargins(0, 1, 0, 1);
|
|
m_progress->setMinimumWidth(MIN_WIDTH);
|
|
m_progress->setMaximumWidth(MAX_WIDTH);
|
|
m_progress->setMaximumHeight(15);
|
|
m_progress->setRange(0, 0);
|
|
m_progress->setValue(0);
|
|
m_progress->setFormat("%v / %m");
|
|
m_progress->setStyleSheet(
|
|
"margin: 0px;"
|
|
"font-size: 10px;"
|
|
"background-color: black;"
|
|
);
|
|
layout->addWidget(m_progress);
|
|
|
|
m_progressTime = new QTimeEdit;
|
|
m_progressTime->setToolTip("Current Time");
|
|
m_progressTime->setObjectName("Current Time");
|
|
m_progressTime->setDisplayFormat("mm:ss:zzz");
|
|
m_progressTime->setReadOnly(true);
|
|
m_progressTime->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
|
m_progressTime->setFocusPolicy(Qt::NoFocus);
|
|
m_progressTime->setAlignment(Qt::AlignHCenter);
|
|
m_progressTime->setContentsMargins(0,0,0,0);
|
|
m_progressTime->setMinimumWidth(MIN_WIDTH);
|
|
m_progressTime->setMaximumWidth(MAX_WIDTH);
|
|
m_progressTime->setStyleSheet(
|
|
"margin: 0px;"
|
|
"color: white;"
|
|
"background-color: black;"
|
|
"font-size: 16px;"
|
|
);
|
|
m_totalTimeValue = new QTimeEdit;
|
|
m_totalTimeValue->setObjectName("Track Length");
|
|
m_totalTimeValue->setToolTip("Track Length");
|
|
m_totalTimeValue->setDisplayFormat("mm:ss:zzz");
|
|
m_totalTimeValue->setReadOnly(true);
|
|
m_totalTimeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
|
m_totalTimeValue->setFocusPolicy(Qt::NoFocus);
|
|
m_totalTimeValue->setAlignment(Qt::AlignHCenter);
|
|
m_totalTimeValue->setContentsMargins(0,0,0,0);
|
|
m_totalTimeValue->setMinimumWidth(MIN_WIDTH);
|
|
m_totalTimeValue->setMaximumWidth(MAX_WIDTH);
|
|
m_totalTimeValue->setStyleSheet(
|
|
"margin: 0px;"
|
|
"color: white;"
|
|
"background-color: black;"
|
|
"font-size: 16px;"
|
|
);
|
|
QHBoxLayout *status = new QHBoxLayout;
|
|
status->addWidget(m_progressTime);
|
|
status->addWidget(m_totalTimeValue);
|
|
layout->addLayout(status);
|
|
|
|
m_filterBank = new FilterBankWidget(this);
|
|
m_filterBank->setMaximumWidth(MAX_WIDTH);
|
|
m_filterBank->setMinimumWidth(MIN_WIDTH);
|
|
connect(m_filterBank, SIGNAL(setBypass(bool)), this, SLOT(setBypass(bool)));
|
|
layout->addWidget(m_filterBank);
|
|
m_pitch = new SliderGroup("Pitch", 0 , 255, 0, NULL);
|
|
layout->addWidget(m_pitch);
|
|
connect(m_pitch, SIGNAL(valueChanged(int)), this, SLOT(pitchChanged(int)));
|
|
m_pan = new SliderGroup("Pan", 0 , 255, 0, NULL);
|
|
layout->addWidget(m_pan);
|
|
connect(m_pan, SIGNAL(valueChanged(int)), this, SLOT(panChanged(int)));
|
|
|
|
QHBoxLayout *volumeBox = new QHBoxLayout;
|
|
m_volume = new SliderGroup("Vol", 0, 65535, 2, NULL);
|
|
volumeBox->addWidget(m_volume);
|
|
connect(m_volume, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)));
|
|
m_bus1 = new SliderGroup("Bus 1", 0, 65535, 2, NULL);
|
|
volumeBox->addWidget(m_bus1);
|
|
connect(m_bus1, SIGNAL(valueChanged(int)), this, SLOT(bus1VolumeChanged(int)));
|
|
m_bus2 = new SliderGroup("Bus 2", 0, 65535, 2, NULL);
|
|
volumeBox->addWidget(m_bus2);
|
|
connect(m_bus2, SIGNAL(valueChanged(int)), this, SLOT(bus2VolumeChanged(int)));
|
|
volumeBox->setSpacing(0);
|
|
volumeBox->setContentsMargins(0, 0, 0, 0);
|
|
layout->addLayout(volumeBox);
|
|
QHBoxLayout *labelsBox = new QHBoxLayout;
|
|
m_level = new QLabel("-inf");
|
|
m_level->setStyleSheet("border: 1px solid #CFB0C9;"
|
|
"margin: 0px;"
|
|
"background-color: black;"
|
|
"color: white;"
|
|
"text-align: center;"
|
|
"font-size: 15px;");
|
|
m_level->setMinimumWidth(MIN_WIDTH / 2);
|
|
m_level->setMaximumWidth(MAX_WIDTH / 3);
|
|
m_level->setMinimumHeight(25);
|
|
m_level->setAlignment(Qt::AlignHCenter);
|
|
m_level->setContentsMargins(0, 4, 0, 4);
|
|
labelsBox->addWidget(m_level);
|
|
m_bus1Label = new QLabel("dummy");
|
|
m_bus1Label->setAlignment(Qt::AlignHCenter);
|
|
m_bus1Label->setContentsMargins(0, 6, 0, 6);
|
|
m_bus1Label->setMinimumHeight(25);
|
|
m_bus1Label->setMinimumWidth(MIN_WIDTH / 4);
|
|
m_bus1Label->setMaximumWidth(MAX_WIDTH / 3);
|
|
m_bus1Label->setStyleSheet("border: 1px solid #CFB0C9;"
|
|
"margin: 0px;"
|
|
"background-color: black;"
|
|
"color: white;"
|
|
"font-size: 10px;");
|
|
labelsBox->addWidget(m_bus1Label);
|
|
m_bus2Label = new QLabel("dummy");
|
|
m_bus2Label->setAlignment(Qt::AlignHCenter);
|
|
m_bus2Label->setMinimumWidth(MIN_WIDTH / 4);
|
|
m_bus2Label->setMaximumWidth(MAX_WIDTH / 3);
|
|
m_bus2Label->setContentsMargins(0, 6, 0, 6);
|
|
m_bus2Label->setMinimumHeight(25);
|
|
m_bus2Label->setStyleSheet("border: 1px solid #CFB0C9;"
|
|
"margin: 0px;"
|
|
"background-color: black;"
|
|
"color: white;"
|
|
"font-size: 10px;");
|
|
labelsBox->addWidget(m_bus2Label);
|
|
labelsBox->setSpacing(0);
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
layout->addLayout(labelsBox);
|
|
layout->setAlignment(Qt::AlignHCenter);
|
|
layout->setSpacing(1);
|
|
this->setLayout(layout);
|
|
}
|
|
|
|
AudioLayerWidget::~AudioLayerWidget() {}
|
|
|
|
// From UI.
|
|
void AudioLayerWidget::volumeChanged(int value)
|
|
{
|
|
emit(uiSliderChanged(m_layer, Slider::Volume, value));
|
|
}
|
|
|
|
void AudioLayerWidget::bus1VolumeChanged(int value)
|
|
{
|
|
emit(uiSliderChanged(m_layer, Slider::Bus1, value));
|
|
}
|
|
|
|
void AudioLayerWidget::bus2VolumeChanged(int value)
|
|
{
|
|
emit(uiSliderChanged(m_layer, Slider::Bus2, value));
|
|
}
|
|
|
|
void AudioLayerWidget::panChanged(int value)
|
|
{
|
|
emit(uiSliderChanged(m_layer, Slider::Pan, value));
|
|
}
|
|
|
|
void AudioLayerWidget::pitchChanged(int value)
|
|
{
|
|
emit(uiSliderChanged(m_layer, Slider::Pitch, value));
|
|
}
|
|
|
|
void AudioLayerWidget::setBypass(bool value)
|
|
{
|
|
emit(uiSliderChanged(m_layer, Slider::Bypass, value));
|
|
}
|
|
|
|
|
|
void AudioLayerWidget::toggleSuspendResume()
|
|
{
|
|
switch (m_status) {
|
|
case Status::PlayingLoop:
|
|
case Status::PlayingOnce:
|
|
case Status::PlayingFolder:
|
|
case Status::PlayingFolderLoop:
|
|
case Status::PlayingFolderRandom:
|
|
m_oldStatus = m_status;
|
|
this->setPlaybackStatus(Status::Paused);
|
|
emit uiPlaybackChanged(m_layer, Status::Paused);
|
|
break;
|
|
case Status::Paused:
|
|
case Status::Stopped:
|
|
this->setPlaybackStatus(m_oldStatus);
|
|
emit uiPlaybackChanged(m_layer, m_oldStatus);
|
|
case Status::Iddle:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void AudioLayerWidget::openMediaDialog()
|
|
{
|
|
QFileDialog dialog(this);
|
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
|
dialog.setNameFilter(tr("Sound Tracks (*.mp3 *.mp3 *.flac *.wav"));
|
|
dialog.setViewMode(QFileDialog::Detail);
|
|
dialog.setDirectory(Settings::getInstance()->getPathMedia());
|
|
if (!dialog.exec())
|
|
return;
|
|
QStringList fileNames;
|
|
fileNames = dialog.selectedFiles();
|
|
emit uiLoadMedia(m_layer, fileNames.at(0));
|
|
this->setMediaFile(fileNames.at(0));
|
|
this->setPlaybackStatus(Status::Stopped);
|
|
}
|
|
|
|
// from DMX signals
|
|
void AudioLayerWidget::setVol(float vol)
|
|
{
|
|
m_volume->blockSignals(true);
|
|
m_volume->setValue(vol);
|
|
m_volume->blockSignals(false);
|
|
}
|
|
|
|
void AudioLayerWidget::setPan(int pan)
|
|
{
|
|
m_pan->blockSignals(true);
|
|
m_pan->setValue(pan);
|
|
m_pan->blockSignals(false);
|
|
}
|
|
|
|
void AudioLayerWidget::setPitch(int pitch)
|
|
{
|
|
m_pitch->blockSignals(true);
|
|
m_pitch->setValue(pitch);
|
|
m_pitch->blockSignals(false);
|
|
}
|
|
|
|
void AudioLayerWidget::setMediaFile(QString file)
|
|
{
|
|
QStringList list = file.split("/");
|
|
int size = list.size();
|
|
if (size >= 2) {
|
|
QString tmp = list.at(size - 2);
|
|
tmp.truncate(64);
|
|
m_folderValue->setText(tmp);
|
|
tmp = list.at(size - 1);
|
|
tmp.truncate(64);
|
|
m_fileValue->setText(tmp);
|
|
}
|
|
}
|
|
|
|
void AudioLayerWidget::setPlaybackStatus(Status s)
|
|
{
|
|
m_suspendResumeButton->blockSignals(true);
|
|
m_status = s;
|
|
m_suspendResumeButton->setText(statusToString(s));
|
|
m_suspendResumeButton->blockSignals(false);
|
|
}
|
|
|
|
void AudioLayerWidget::setDuration(float dur)
|
|
{
|
|
m_progress->blockSignals(true);
|
|
m_progressTime->blockSignals(true);
|
|
m_totalTimeValue->blockSignals(true);
|
|
m_progress->setRange(0, dur);
|
|
m_progress->setValue(0);
|
|
m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(0));
|
|
m_totalTimeValue->setTime(QTime::fromMSecsSinceStartOfDay(dur));
|
|
m_progress->blockSignals(false);
|
|
m_progressTime->blockSignals(false);
|
|
m_totalTimeValue->blockSignals(false);
|
|
}
|
|
|
|
void AudioLayerWidget::setCurrentTime(float progress)
|
|
{
|
|
progress *= 1000;
|
|
m_progress->blockSignals(true);
|
|
m_progressTime->blockSignals(true);
|
|
m_progress->setValue(progress);
|
|
m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(progress));
|
|
m_progress->blockSignals(false);
|
|
m_progressTime->blockSignals(false);
|
|
}
|
|
|
|
void AudioLayerWidget::setFilterParam(int channel, int value)
|
|
{
|
|
if (channel <= FILTER_BANK_GAIN - HP_FREQ){
|
|
m_filterBank->blockSignals(true);
|
|
m_filterBank->setValue(channel, value);
|
|
m_filterBank->blockSignals(false);
|
|
} else if (channel == SEND1 - HP_FREQ) {
|
|
m_bus1->blockSignals(true);
|
|
m_bus1->setValue((value * 256) + 255);
|
|
m_bus1->blockSignals(false);
|
|
} else if (channel == SEND2 - HP_FREQ) {
|
|
m_bus2->blockSignals(true);
|
|
m_bus2->setValue(value * 256 + 255);
|
|
m_bus2->blockSignals(false);
|
|
}
|
|
}
|
|
|
|
void AudioLayerWidget::setLevel(float db)
|
|
{
|
|
m_level->blockSignals(true);
|
|
if (db > -140)
|
|
|
|
m_level->setText(QString::number(db, 'f', 2));
|
|
else
|
|
m_level->setText("-inf");
|
|
m_level->blockSignals(false);
|
|
}
|
|
|
|
void AudioLayerWidget::setBusName(uint bus, char *name)
|
|
{
|
|
if (name && strlen(name) > 17)
|
|
name[16] = '\0';
|
|
if (bus == 0) {
|
|
m_bus1Label->blockSignals(true);
|
|
m_bus1Label->setText(name);
|
|
m_bus1Label->blockSignals(false);
|
|
} else if (bus == 1) {
|
|
m_bus2Label->blockSignals(true);
|
|
m_bus2Label->setText(name);
|
|
m_bus2Label->blockSignals(false);
|
|
}
|
|
}
|