Skip to content

Commit

Permalink
fix for ticket #24
Browse files Browse the repository at this point in the history
* RT: FluidSynth backend, ability to set several soundfonts
* Widgets: FluidSynth settings dialog, select several soundfonts
  • Loading branch information
pedrolcl committed Jul 7, 2024
1 parent 155bd23 commit 6bab495
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
9 changes: 7 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
2024-07-07
* fix for ticket #24
RT: FluidSynth backend, ability to set several soundfonts
Widgets: FluidSynth settings dialog, select several soundfonts.

2024-04-14
* RT: preliminary support for PipeWire:
initialization of the FluidSynth backend

2024-03-06
* github workflows:
* fix for #21: github workflows:
check-branches, rejects PRs targeting master
cmake-win: build and test on Windows with msys2 using mingw and clang
cmake: build and test on Linux

2024-01-08
* preliminary support for Sysexes under windows. Thanks to Luca Santini
* Fix for #19: preliminary support for Sysexes under windows. Thanks to Luca Santini

2023-12-23
* Documentation updated
Expand Down
3 changes: 1 addition & 2 deletions library/rt-backends/fluidsynth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ target_include_directories(drumstick-rt-fluidsynth PRIVATE
)

if(HAVE_PIPEWIRE)
target_compile_definitions(drumstick-rt-fluidsynth
PRIVATE USE_PIPEWIRE)
target_compile_definitions(drumstick-rt-fluidsynth PRIVATE USE_PIPEWIRE)
endif()

target_link_libraries(drumstick-rt-fluidsynth PRIVATE
Expand Down
24 changes: 17 additions & 7 deletions library/rt-backends/fluidsynth/fluidsynthengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,11 @@ SynthEngine_log_function(int level, const char* message, void* data)

FluidSynthEngine::FluidSynthEngine(QObject *parent)
: QObject(parent),
m_sfid(0),
m_settings(nullptr),
m_synth(nullptr),
m_driver(nullptr)
{
//qDebug() << Q_FUNC_INFO;
//qDebug() << Q_FUNC_INFO;
m_runtimeLibraryVersion = ::fluid_version_str();
//qDebug() << "Compiled FluidSynth Version:" << QSTR_FLUIDSYNTH_VERSION;
//qDebug() << "Runtime FluidSynth Version:" << m_runtimeLibraryVersion;
Expand Down Expand Up @@ -150,10 +149,21 @@ void FluidSynthEngine::noteOff(int channel, int midiNote, int /*velocity*/)

void FluidSynthEngine::loadSoundFont()
{
if (m_sfid != -1) {
::fluid_synth_sfunload(m_synth, unsigned(m_sfid), 1);
if (!m_sfids.isEmpty()) {
foreach (const int id, m_sfids) {
if (id > -1) {
::fluid_synth_sfunload(m_synth, unsigned(id), 1);
}
}
m_sfids.clear();
}
const QStringList soundfonts = m_soundFont.split(';', Qt::SkipEmptyParts);
foreach (const QString &sf, soundfonts) {
int id = ::fluid_synth_sfload(m_synth, qPrintable(sf), 1);
if (id > -1) {
m_sfids.append(id);
}
}
m_sfid = ::fluid_synth_sfload(m_synth, qPrintable(m_soundFont), 1);
}

void FluidSynthEngine::retrieveDefaultSoundfont()
Expand Down Expand Up @@ -182,7 +192,7 @@ void FluidSynthEngine::initialize()
m_soundFont = m_defSoundFont;
}
loadSoundFont();
m_status = (m_synth != nullptr) && (m_driver != nullptr) && (m_sfid >= 0);
m_status = (m_synth != nullptr) && (m_driver != nullptr) && (!m_sfids.isEmpty());
}

void FluidSynthEngine::panic()
Expand Down Expand Up @@ -347,7 +357,7 @@ void FluidSynthEngine::scanSoundFonts()

void FluidSynthEngine::readSettings(QSettings *settings)
{
m_sfid = -1;
m_sfids.clear();
settings->beginGroup(QSTR_PREFERENCES);
m_soundFont = settings->value(QSTR_INSTRUMENTSDEFINITION, m_defSoundFont).toString();
fs_audiodriver = settings->value(QSTR_AUDIODRIVER, QSTR_DEFAULT_AUDIODRIVER).toString();
Expand Down
2 changes: 1 addition & 1 deletion library/rt-backends/fluidsynth/fluidsynthengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class FluidSynthEngine : public QObject
void loadSoundFont();
void retrieveDefaultSoundfont();

int m_sfid;
QList<int> m_sfids;
MIDIConnection m_currentConnection;
QString m_runtimeLibraryVersion;
QString m_soundFont;
Expand Down
10 changes: 7 additions & 3 deletions library/widgets/fluidsettingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,13 @@ void FluidSettingsDialog::showFileDialog()
if (!dir.exists()) {
dir = QDir(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QSTR_DATADIR2, QStandardPaths::LocateDirectory));
}
QString fileName = QFileDialog::getOpenFileName(this, tr("Select SoundFont"), dir.absolutePath(), tr("SoundFont Files (*.sf2 *.sf3 *.dls)"));
if (!fileName.isEmpty()) {
ui->soundFont->setText(fileName);
QStringList fileNames
= QFileDialog::getOpenFileNames(this,
tr("Select SoundFont"),
dir.absolutePath(),
tr("SoundFont Files (*.sf2 *.sf3 *.dls)"));
if (!fileNames.isEmpty()) {
ui->soundFont->setText(fileNames.join(';'));
}
}

Expand Down

0 comments on commit 6bab495

Please sign in to comment.