diff --git a/guisynth/mainwindow.cpp b/guisynth/mainwindow.cpp index bd0edc9..0f03f14 100644 --- a/guisynth/mainwindow.cpp +++ b/guisynth/mainwindow.cpp @@ -30,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent) : m_synth = new SynthController(ProgramSettings::instance()->bufferTime(), this); ui->setupUi(this); + ui->combo_Reverb->addItem(QStringLiteral("Large Hall"), 0); ui->combo_Reverb->addItem(QStringLiteral("Hall"), 1); ui->combo_Reverb->addItem(QStringLiteral("Chamber"), 2); @@ -46,9 +47,14 @@ MainWindow::MainWindow(QWidget *parent) : ui->libSonivoxVersion->setText(m_synth->renderer()->libVersion()); setWindowTitle(windowTitle() + " v" + qApp->applicationVersion()); + ui->qtVersion->setText(qVersion()); - connect(ui->combo_Reverb, SIGNAL(currentIndexChanged(int)), SLOT(reverbTypeChanged(int))); - connect(ui->combo_Chorus, SIGNAL(currentIndexChanged(int)), SLOT(chorusTypeChanged(int))); + connect(ui->combo_ALSAConn, + &QComboBox::currentTextChanged, + this, + &MainWindow::alsaConnectionChanged); + connect(ui->combo_Reverb, SIGNAL(currentIndexChanged(int)), this, SLOT(reverbTypeChanged(int))); + connect(ui->combo_Chorus, SIGNAL(currentIndexChanged(int)), this, SLOT(chorusTypeChanged(int))); connect(ui->dial_Reverb, &QDial::valueChanged, this, &MainWindow::reverbChanged); connect(ui->dial_Chorus, &QDial::valueChanged, this, &MainWindow::chorusChanged); connect(ui->openMIDIbtn, &QToolButton::clicked, this, &MainWindow::openMIDIFile); @@ -56,6 +62,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->playButton, &QToolButton::clicked, this, &MainWindow::playSong); connect(ui->stopButton, &QToolButton::clicked, this, &MainWindow::stopSong); connect(m_synth->renderer(), &SynthRenderer::playbackStopped, this, &MainWindow::songStopped); + m_songFile = QString(); updateState(EmptyState); initialize(); @@ -82,11 +89,17 @@ MainWindow::initialize() } int reverb = ui->combo_Reverb->findData(ProgramSettings::instance()->reverbType()); ui->combo_Reverb->setCurrentIndex(reverb); - ui->dial_Reverb->setValue(ProgramSettings::instance()->reverbWet()); //0..32765 + ui->dial_Reverb->setValue(ProgramSettings::instance()->reverbWet()); //0..32767 int chorus = ui->combo_Chorus->findData(ProgramSettings::instance()->chorusType()); ui->combo_Chorus->setCurrentIndex(chorus); ui->dial_Chorus->setValue(ProgramSettings::instance()->chorusLevel()); m_synth->start(); + + ui->combo_ALSAConn->blockSignals(true); + ui->combo_ALSAConn->clear(); + ui->combo_ALSAConn->addItems(m_synth->renderer()->alsaConnections()); + ui->combo_ALSAConn->blockSignals(false); + ui->combo_ALSAConn->setCurrentText(ProgramSettings::instance()->ALSAConnection()); } void @@ -103,6 +116,17 @@ MainWindow::closeEvent(QCloseEvent* ev) ev->accept(); } +void MainWindow::alsaConnectionChanged(QString name) +{ + qDebug() << Q_FUNC_INFO << name; + if (!m_subscription.isEmpty()) { + m_synth->renderer()->unsubscribe(m_subscription); + } + m_synth->renderer()->subscribe(name); + ProgramSettings::instance()->setALSAConnection(name); + m_subscription = name; +} + void MainWindow::reverbTypeChanged(int index) { @@ -112,6 +136,10 @@ MainWindow::reverbTypeChanged(int index) if (value < 0) { ui->dial_Reverb->setValue(0); ProgramSettings::instance()->setReverbWet(0); + } else { + int wet = m_synth->renderer()->reverbWet(); + ui->dial_Reverb->setValue(wet); + ProgramSettings::instance()->setReverbWet(wet); } } @@ -131,6 +159,10 @@ MainWindow::chorusTypeChanged(int index) if (value < 0) { ui->dial_Chorus->setValue(0); ProgramSettings::instance()->setChorusLevel(0); + } else { + int level = m_synth->renderer()->chorusLevel(); + ui->dial_Chorus->setValue(level); + ProgramSettings::instance()->setChorusLevel(level); } } diff --git a/guisynth/mainwindow.h b/guisynth/mainwindow.h index f9b8934..d34088a 100644 --- a/guisynth/mainwindow.h +++ b/guisynth/mainwindow.h @@ -51,6 +51,7 @@ class MainWindow : public QMainWindow virtual void closeEvent(QCloseEvent *ev); private slots: + void alsaConnectionChanged(QString name); void reverbTypeChanged(int index); void chorusTypeChanged(int index); void reverbChanged(int value); @@ -68,6 +69,7 @@ private slots: QString m_songFile; QString m_dlsFile; PlayerState m_state; + QString m_subscription; }; #endif // MAINWINDOW_H diff --git a/guisynth/mainwindow.ui b/guisynth/mainwindow.ui index 4c77f44..3e45d71 100644 --- a/guisynth/mainwindow.ui +++ b/guisynth/mainwindow.ui @@ -6,14 +6,14 @@ 0 0 - 280 - 290 + 420 + 420 - 280 - 290 + 420 + 420 @@ -25,7 +25,211 @@ - + + + + Reverb + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + 0 + 0 + + + + wet: + + + + + + + + 0 + 0 + + + + 0 + + + + + + + + + + 0 + 0 + + + + 32767 + + + + + + + 0 + + + + + + 0 + 0 + + + + preset: + + + + + + + + 0 + 0 + + + + + + + + + + + + + Qt::Orientation::Vertical + + + + 20 + 8 + + + + + + + + Chorus + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + 0 + 0 + + + + level: + + + + + + + + 0 + 0 + + + + 0 + + + + + + + + + + 0 + 0 + + + + 32767 + + + + + + + + + + 0 + 0 + + + + preset: + + + + + + + + 0 + 0 + + + + + + + + + + @@ -55,59 +259,6 @@ - - - - Reverb - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 8 - - - - - - - - Chorus - - - Qt::AlignCenter - - - - - - - 32765 - - - - - - - 32765 - - - - - - - - - @@ -161,7 +312,7 @@ - + @@ -175,7 +326,7 @@ Buffer Time: - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter @@ -188,10 +339,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Plain + QFrame::Shadow::Plain 60 ms @@ -250,12 +401,108 @@ + + + + + + + 0 + 0 + + + + Qt Version: + + + + + + + + 0 + 0 + + + + + + + + + + + + + 0 + 0 + + + + MIDI Input Connection: + + + + + + + + 0 + 0 + + + + + + + + playButton + stopButton + openMIDIbtn + openDLSbtn + dial_Chorus + combo_Reverb + combo_Chorus + - + + + dial_Reverb + valueChanged(int) + reverbWet + setNum(int) + + + 90 + 313 + + + 149 + 244 + + + + + dial_Chorus + valueChanged(int) + chorusLevel + setNum(int) + + + 311 + 317 + + + 368 + 247 + + + + diff --git a/libsvoxeas/programsettings.cpp b/libsvoxeas/programsettings.cpp index 99085d3..d1eedb4 100644 --- a/libsvoxeas/programsettings.cpp +++ b/libsvoxeas/programsettings.cpp @@ -37,6 +37,7 @@ void ProgramSettings::ResetDefaults() m_chorusType = -1; m_chorusLevel = 0; m_DLSsoundfont.clear(); + m_ALSAConnection.clear(); emit ValuesChanged(); } @@ -74,6 +75,7 @@ void ProgramSettings::internalRead(QSettings &settings) m_chorusType = settings.value("ChorusType", -1).toInt(); m_chorusLevel = settings.value("ChorusLevel", 0).toInt(); m_DLSsoundfont = settings.value("DLSsoundFont", QString()).toString(); + m_ALSAConnection = settings.value("ALSAConnection", QString()).toString(); emit ValuesChanged(); } @@ -85,9 +87,20 @@ void ProgramSettings::internalSave(QSettings &settings) settings.setValue("ChorusType", m_chorusType); settings.setValue("ChorusLevel", m_chorusLevel); settings.setValue("DLSsoundFont", m_DLSsoundfont); + settings.setValue("ALSAConnection", m_ALSAConnection); settings.sync(); } +QString ProgramSettings::ALSAConnection() const +{ + return m_ALSAConnection; +} + +void ProgramSettings::setALSAConnection(const QString &newALSAConnection) +{ + m_ALSAConnection = newALSAConnection; +} + QString ProgramSettings::dlsSoundfont() const { return m_DLSsoundfont; diff --git a/libsvoxeas/programsettings.h b/libsvoxeas/programsettings.h index 065c8ad..027998c 100644 --- a/libsvoxeas/programsettings.h +++ b/libsvoxeas/programsettings.h @@ -48,6 +48,9 @@ class ProgramSettings : public QObject QString dlsSoundfont() const; void setDLSsoundfont(const QString &newDLSsoundfont); + QString ALSAConnection() const; + void setALSAConnection(const QString &newALSAConnection); + signals: void ValuesChanged(); @@ -69,6 +72,7 @@ public slots: int m_chorusType; int m_chorusLevel; QString m_DLSsoundfont; + QString m_ALSAConnection; }; #endif // PROGRAMSETTINGS_H diff --git a/libsvoxeas/synthrenderer.cpp b/libsvoxeas/synthrenderer.cpp index c25cd34..b14c2d9 100644 --- a/libsvoxeas/synthrenderer.cpp +++ b/libsvoxeas/synthrenderer.cpp @@ -213,6 +213,17 @@ QString SynthRenderer::libVersion() const return vn.toString(); } +QStringList SynthRenderer::alsaConnections() const +{ + QStringList items; + QListIterator it(m_Client->getAvailableInputs()); + while (it.hasNext()) { + PortInfo p = it.next(); + items << QString("%1:%2").arg(p.getClientName()).arg(p.getPort()); + } + return items; +} + SynthRenderer::~SynthRenderer() { uninitALSA(); @@ -239,16 +250,20 @@ SynthRenderer::stop() void SynthRenderer::subscription(MidiPort*, Subscription* subs) { - qDebug() << "Subscription made from " - << subs->getSender()->client << ":" - << subs->getSender()->port; + Q_UNUSED(subs) + + qDebug() << Q_FUNC_INFO; + // auto *sender = subs->getSender(); + // if (sender) { + // qDebug() << "Subscription made from " << sender->client << ":" << sender->port; + // } } void SynthRenderer::subscribe(const QString& portName) { try { - qDebug() << "Trying to subscribe " << portName.toLocal8Bit().data(); + qDebug() << "Trying to subscribe" << portName.toLocal8Bit().data(); m_Port->subscribeFrom(portName); } catch (const SequencerError& err) { qWarning() << "SequencerError exception. Error code: " << err.code() @@ -258,6 +273,19 @@ SynthRenderer::subscribe(const QString& portName) } } +void SynthRenderer::unsubscribe(const QString &portName) +{ + try { + qDebug() << "Trying to unsubscribe" << portName.toLocal8Bit().data(); + m_Port->unsubscribeFrom(portName); + } catch (const SequencerError &err) { + qWarning() << "SequencerError exception. Error code: " << err.code() << " (" + << err.qstrError() << ")"; + qWarning() << "Location: " << err.location(); + throw err; + } +} + void SynthRenderer::run() { @@ -372,6 +400,7 @@ SynthRenderer::initReverb(int reverb_type) if (eas_res != EAS_SUCCESS) { qWarning() << "EAS_SetParameter error: " << eas_res; } + //qDebug() << Q_FUNC_INFO << reverb_type << sw; } void @@ -390,6 +419,18 @@ SynthRenderer::initChorus(int chorus_type) if (eas_res != EAS_SUCCESS) { qWarning() << "EAS_SetParameter error:" << eas_res; } + //qDebug() << Q_FUNC_INFO << chorus_type << sw; +} + +int SynthRenderer::reverbWet() +{ + EAS_I32 wet = 0; + EAS_RESULT eas_res = EAS_GetParameter(m_easData, EAS_MODULE_REVERB, EAS_PARAM_REVERB_WET, &wet); + if (eas_res != EAS_SUCCESS) { + qWarning() << "EAS_GetParameter error:" << eas_res; + } + //qDebug() << Q_FUNC_INFO << wet; + return wet; } void @@ -399,6 +440,21 @@ SynthRenderer::setReverbWet(int amount) if (eas_res != EAS_SUCCESS) { qWarning() << "EAS_SetParameter error:" << eas_res; } + //qDebug() << Q_FUNC_INFO << amount; +} + +int SynthRenderer::chorusLevel() +{ + EAS_I32 level = 0; + EAS_RESULT eas_res = EAS_GetParameter(m_easData, + EAS_MODULE_CHORUS, + EAS_PARAM_CHORUS_LEVEL, + &level); + if (eas_res != EAS_SUCCESS) { + qWarning() << "EAS_GetParameter error:" << eas_res; + } + //qDebug() << Q_FUNC_INFO << level; + return level; } void @@ -408,6 +464,7 @@ SynthRenderer::setChorusLevel(int amount) if (eas_res != EAS_SUCCESS) { qWarning() << "EAS_SetParameter error:" << eas_res; } + //qDebug() << Q_FUNC_INFO << amount; } void SynthRenderer::initSoundfont(const QString &dlsFile) diff --git a/libsvoxeas/synthrenderer.h b/libsvoxeas/synthrenderer.h index 432183d..e4c4ef9 100644 --- a/libsvoxeas/synthrenderer.h +++ b/libsvoxeas/synthrenderer.h @@ -37,12 +37,16 @@ class SynthRenderer : public QObject virtual ~SynthRenderer(); void subscribe(const QString& portName); + void unsubscribe(const QString &portName); + void stop(); bool stopped(); void initReverb(int reverb_type); void initChorus(int chorus_type); + int reverbWet(); void setReverbWet(int amount); + int chorusLevel(); void setChorusLevel(int amount); void initSoundfont(const QString& dlsFile); @@ -54,6 +58,7 @@ class SynthRenderer : public QObject void uninitPulse(); QString libVersion() const; + QStringList alsaConnections() const; private: void initALSA(); diff --git a/screenshot.png b/screenshot.png index d4d7405..0a14d01 100644 Binary files a/screenshot.png and b/screenshot.png differ