From 29c55500a731bc18094e29e81435d903ff05302a Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 19 May 2020 01:33:52 +0100 Subject: [PATCH] Pass DLS/GIG files into fluidsynth if version is recent enough Signed-off-by: falkTX --- Makefile | 5 + source/Makefile.mk | 8 + source/backend/CarlaPlugin.hpp | 2 +- source/backend/engine/CarlaEngine.cpp | 8 +- .../backend/plugin/CarlaPluginFluidSynth.cpp | 214 ++++++++++++------ source/backend/utils/Information.cpp | 6 + source/discovery/carla-discovery.cpp | 31 ++- 7 files changed, 198 insertions(+), 76 deletions(-) diff --git a/Makefile b/Makefile index d2f8a8929..eb48bf92c 100644 --- a/Makefile +++ b/Makefile @@ -976,6 +976,11 @@ ifeq ($(HAVE_FFMPEG),true) else @printf -- "Extra: $(ANS_NO) $(mS)FFmpeg missing or too new$(mE)\n" endif +# ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true) +# @printf -- "DLS: $(ANS_YES)\n" +# else +# @printf -- "DLS: $(ANS_NO) $(mS)FluidSynth/instpatch missing or too old$(mE)\n" +# endif ifeq ($(HAVE_FLUIDSYNTH),true) @printf -- "SF2/3: $(ANS_YES)\n" else diff --git a/source/Makefile.mk b/source/Makefile.mk index 9444d4533..ef864d91f 100644 --- a/source/Makefile.mk +++ b/source/Makefile.mk @@ -244,6 +244,11 @@ HAVE_QT5 = $(shell $(PKG_CONFIG) --exists Qt5Core Qt5Gui Qt5Widgets && \ $(PKG_CONFIG) --variable=qt_config Qt5Core | grep -q -v "static" && echo true) HAVE_SNDFILE = $(shell $(PKG_CONFIG) --exists sndfile && echo true) +ifeq ($(HAVE_FLUIDSYNTH),true) +HAVE_FLUIDSYNTH_INSTPATCH = $(shell $(PKG_CONFIG) --atleast-version=2.1.0 fluidsynth && \ + $(PKG_CONFIG) --atleast-version=1.1.4 libinstpatch-1.0 && echo true) +endif + ifeq ($(LINUX),true) # juce only supports the most common architectures ifneq (,$(findstring arm,$(TARGET_MACHINE))) @@ -377,6 +382,9 @@ endif ifeq ($(HAVE_FLUIDSYNTH),true) BASE_FLAGS += -DHAVE_FLUIDSYNTH +ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true) +BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH +endif endif ifeq ($(HAVE_FFMPEG),true) diff --git a/source/backend/CarlaPlugin.hpp b/source/backend/CarlaPlugin.hpp index d7db9e02d..5ca67c271 100644 --- a/source/backend/CarlaPlugin.hpp +++ b/source/backend/CarlaPlugin.hpp @@ -954,7 +954,7 @@ public: static CarlaPlugin* newAU(const Initializer& init); static CarlaPlugin* newJuce(const Initializer& init, const char* format); - static CarlaPlugin* newFluidSynth(const Initializer& init, bool use16Outs); + static CarlaPlugin* newFluidSynth(const Initializer& init, PluginType ptype, bool use16Outs); static CarlaPlugin* newSFZero(const Initializer& init); static CarlaPlugin* newJackApp(const Initializer& init); diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index ef2aa941f..7f791817f 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -621,7 +621,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, case PLUGIN_GIG: case PLUGIN_SF2: use16Outs = (extra != nullptr && std::strcmp((const char*)extra, "true") == 0); - plugin = CarlaPlugin::newFluidSynth(initializer, use16Outs); + plugin = CarlaPlugin::newFluidSynth(initializer, ptype, use16Outs); break; case PLUGIN_SFZ: @@ -1085,6 +1085,12 @@ bool CarlaEngine::loadFile(const char* const filename) // ------------------------------------------------------------------- + if (extension == "dls") + return addPlugin(PLUGIN_DLS, filename, baseName, baseName, 0, nullptr); + + if (extension == "gig") + return addPlugin(PLUGIN_GIG, filename, baseName, baseName, 0, nullptr); + if (extension == "sf2" || extension == "sf3") return addPlugin(PLUGIN_SF2, filename, baseName, baseName, 0, nullptr); diff --git a/source/backend/plugin/CarlaPluginFluidSynth.cpp b/source/backend/plugin/CarlaPluginFluidSynth.cpp index ecce3b337..e49c608e0 100644 --- a/source/backend/plugin/CarlaPluginFluidSynth.cpp +++ b/source/backend/plugin/CarlaPluginFluidSynth.cpp @@ -67,8 +67,15 @@ public: fluid_settings_setint(fSettings, "synth.audio-groups", use16Outs ? 16 : 1); fluid_settings_setnum(fSettings, "synth.sample-rate", pData->engine->getSampleRate()); //fluid_settings_setnum(fSettings, "synth.cpu-cores", 2); + fluid_settings_setint(fSettings, "synth.ladspa.active", 0); + fluid_settings_setint(fSettings, "synth.lock-memory", 1); +#if FLUIDSYNTH_VERSION_MAJOR < 2 fluid_settings_setint(fSettings, "synth.parallel-render", 1); +#endif fluid_settings_setint(fSettings, "synth.threadsafe-api", 0); +#ifdef DEBUG + fluid_settings_setint(fSettings, "synth.verbose", 1); +#endif // create synth fSynth = new_fluid_synth(fSettings); @@ -76,7 +83,9 @@ public: initializeFluidDefaultsIfNeeded(); - fluid_synth_set_sample_rate(fSynth, (float)pData->engine->getSampleRate()); +#if FLUIDSYNTH_VERSION_MAJOR < 2 + fluid_synth_set_sample_rate(fSynth, static_cast(pData->engine->getSampleRate())); +#endif // set default values fluid_synth_set_reverb_on(fSynth, 1); @@ -458,17 +467,17 @@ public: case FluidSynthChorusType: try { fluid_synth_set_chorus(fSynth, - (int)fParamBuffers[FluidSynthChorusNr], + static_cast(fParamBuffers[FluidSynthChorusNr] + 0.5f), fParamBuffers[FluidSynthChorusLevel], fParamBuffers[FluidSynthChorusSpeedHz], fParamBuffers[FluidSynthChorusDepthMs], - (int)fParamBuffers[FluidSynthChorusType]); + static_cast(fParamBuffers[FluidSynthChorusType] + 0.5f)); } CARLA_SAFE_EXCEPTION("fluid_synth_set_chorus") break; case FluidSynthPolyphony: try { - fluid_synth_set_polyphony(fSynth, (int)value); + fluid_synth_set_polyphony(fSynth, static_cast(value + 0.5f)); } CARLA_SAFE_EXCEPTION("fluid_synth_set_polyphony") break; @@ -476,7 +485,7 @@ public: for (int i=0; i < MAX_MIDI_CHANNELS; ++i) { try { - fluid_synth_set_interp_method(fSynth, i, (int)value); + fluid_synth_set_interp_method(fSynth, i, static_cast(value + 0.5f)); } CARLA_SAFE_EXCEPTION_BREAK("fluid_synth_set_interp_method") } break; @@ -519,7 +528,15 @@ public: const uint32_t bank = pData->midiprog.data[index].bank; const uint32_t program = pData->midiprog.data[index].program; +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fluid_synth_program_select(fSynth, + static_cast(channel), + fSynthId, + static_cast(bank), + static_cast(program)); +#else fluid_synth_program_select(fSynth, channel, fSynthId, bank, program); +#endif fCurMidiProgs[channel] = index; if (pData->ctrlChannel == static_cast(channel)) @@ -555,7 +572,12 @@ public: const ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback)); try { +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId, + static_cast(bank), static_cast(program)); +#else fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId, bank, program); +#endif } CARLA_SAFE_EXCEPTION("fluid_synth_program_select") fCurMidiProgs[pData->ctrlChannel] = index; @@ -576,7 +598,12 @@ public: const uint32_t program = pData->midiprog.data[uindex].program; try { +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId, + static_cast(bank), static_cast(program)); +#else fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId, bank, program); +#endif } CARLA_SAFE_EXCEPTION("fluid_synth_program_select") fCurMidiProgs[pData->ctrlChannel] = static_cast(uindex); @@ -752,7 +779,7 @@ public: pData->param.data[j].index = j; pData->param.data[j].rindex = j; pData->param.ranges[j].min = 0.0f; - pData->param.ranges[j].max = 1.2f; + pData->param.ranges[j].max = 1.0f; pData->param.ranges[j].def = sFluidDefaults[j]; pData->param.ranges[j].step = 0.01f; pData->param.ranges[j].stepSmall = 0.0001f; @@ -857,7 +884,11 @@ public: pData->param.data[j].index = j; pData->param.data[j].rindex = j; pData->param.ranges[j].min = 0.0f; +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + pData->param.ranges[j].max = 256.0f; +#else pData->param.ranges[j].max = float(2048.0 * 1000.0 / pData->engine->getSampleRate()); // FIXME? +#endif pData->param.ranges[j].def = sFluidDefaults[j]; pData->param.ranges[j].step = 0.01f; pData->param.ranges[j].stepSmall = 0.0001f; @@ -910,7 +941,7 @@ public: pData->param.data[j].rindex = j; pData->param.ranges[j].min = 0.0f; pData->param.ranges[j].max = 65535.0f; - pData->param.ranges[j].def = sFluidDefaults[j]; + pData->param.ranges[j].def = 0.0f; pData->param.ranges[j].step = 1.0f; pData->param.ranges[j].stepSmall = 1.0f; pData->param.ranges[j].stepLarge = 1.0f; @@ -960,12 +991,12 @@ public: if (fluid_sfont_t* const f_sfont = fluid_synth_get_sfont_by_id(fSynth, fSynthId)) { -#if FLUIDSYNTH_VERSION_MAJOR < 2 - fluid_preset_t f_preset; +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fluid_preset_t* f_preset; // initial check to know how many midi-programs we have - f_sfont->iteration_start(f_sfont); - for (; f_sfont->iteration_next(f_sfont, &f_preset);) + fluid_sfont_iteration_start(f_sfont); + for (; fluid_sfont_iteration_next(f_sfont);) ++count; // sound kits must always have at least 1 midi-program @@ -976,25 +1007,25 @@ public: // Update data int tmp; uint32_t i = 0; - f_sfont->iteration_start(f_sfont); + fluid_sfont_iteration_start(f_sfont); - for (; f_sfont->iteration_next(f_sfont, &f_preset);) + for (; (f_preset = fluid_sfont_iteration_next(f_sfont));) { CARLA_SAFE_ASSERT_BREAK(i < count); - tmp = f_preset.get_banknum(&f_preset); + tmp = fluid_preset_get_banknum(f_preset); pData->midiprog.data[i].bank = (tmp >= 0) ? static_cast(tmp) : 0; - tmp = f_preset.get_num(&f_preset); + tmp = fluid_preset_get_num(f_preset); pData->midiprog.data[i].program = (tmp >= 0) ? static_cast(tmp) : 0; - pData->midiprog.data[i].name = carla_strdup(f_preset.get_name(&f_preset)); + pData->midiprog.data[i].name = carla_strdup(fluid_preset_get_name(f_preset)); #else - fluid_preset_t* f_preset; + fluid_preset_t f_preset; // initial check to know how many midi-programs we have - fluid_sfont_iteration_start(f_sfont); - for (; fluid_sfont_iteration_next(f_sfont);) + f_sfont->iteration_start(f_sfont); + for (; f_sfont->iteration_next(f_sfont, &f_preset);) ++count; // sound kits must always have at least 1 midi-program @@ -1005,19 +1036,19 @@ public: // Update data int tmp; uint32_t i = 0; - fluid_sfont_iteration_start(f_sfont); + f_sfont->iteration_start(f_sfont); - for (; (f_preset = fluid_sfont_iteration_next(f_sfont));) + for (; f_sfont->iteration_next(f_sfont, &f_preset);) { CARLA_SAFE_ASSERT_BREAK(i < count); - tmp = fluid_preset_get_banknum(f_preset); + tmp = f_preset.get_banknum(&f_preset); pData->midiprog.data[i].bank = (tmp >= 0) ? static_cast(tmp) : 0; - tmp = fluid_preset_get_num(f_preset); + tmp = f_preset.get_num(&f_preset); pData->midiprog.data[i].program = (tmp >= 0) ? static_cast(tmp) : 0; - pData->midiprog.data[i].name = carla_strdup(fluid_preset_get_name(f_preset)); + pData->midiprog.data[i].name = carla_strdup(f_preset.get_name(&f_preset)); #endif if (pData->midiprog.data[i].bank == 128 && ! hasDrums) @@ -1045,23 +1076,38 @@ public: for (int i=0; i < MAX_MIDI_CHANNELS && i != 9; ++i) { fluid_synth_set_channel_type(fSynth, i, CHANNEL_TYPE_MELODIC); - fluid_synth_program_select(fSynth, i, fSynthId, pData->midiprog.data[0].bank, pData->midiprog.data[0].program); - +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fluid_synth_program_select(fSynth, i, fSynthId, + static_cast(pData->midiprog.data[0].bank), + static_cast(pData->midiprog.data[0].program)); +#else + fluid_synth_program_select(fSynth, i, fSynthId, + pData->midiprog.data[0].bank, pData->midiprog.data[0].program); +#endif fCurMidiProgs[i] = 0; } if (hasDrums) { fluid_synth_set_channel_type(fSynth, 9, CHANNEL_TYPE_DRUM); +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fluid_synth_program_select(fSynth, 9, fSynthId, 128, static_cast(drumProg)); +#else fluid_synth_program_select(fSynth, 9, fSynthId, 128, drumProg); - +#endif fCurMidiProgs[9] = static_cast(drumIndex); } else { fluid_synth_set_channel_type(fSynth, 9, CHANNEL_TYPE_MELODIC); - fluid_synth_program_select(fSynth, 9, fSynthId, pData->midiprog.data[0].bank, pData->midiprog.data[0].program); - +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fluid_synth_program_select(fSynth, 9, fSynthId, + static_cast(pData->midiprog.data[0].bank), + static_cast(pData->midiprog.data[0].program)); +#else + fluid_synth_program_select(fSynth, 9, fSynthId, + pData->midiprog.data[0].bank, pData->midiprog.data[0].program); +#endif fCurMidiProgs[9] = 0; } @@ -1274,7 +1320,12 @@ public: { if (pData->midiprog.data[k].bank == bankId && pData->midiprog.data[k].program == progId) { +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fluid_synth_program_select(fSynth, event.channel, fSynthId, + static_cast(bankId), static_cast(progId)); +#else fluid_synth_program_select(fSynth, event.channel, fSynthId, bankId, progId); +#endif fCurMidiProgs[event.channel] = static_cast(k); if (event.channel == pData->ctrlChannel) @@ -1560,8 +1611,10 @@ public: CARLA_SAFE_ASSERT_RETURN(fSettings != nullptr,); fluid_settings_setnum(fSettings, "synth.sample-rate", newSampleRate); +#if FLUIDSYNTH_VERSION_MAJOR < 2 CARLA_SAFE_ASSERT_RETURN(fSynth != nullptr,); - fluid_synth_set_sample_rate(fSynth, float(newSampleRate)); + fluid_synth_set_sample_rate(fSynth, static_cast(newSampleRate)); +#endif } // ------------------------------------------------------------------- @@ -1636,7 +1689,7 @@ public: // --------------------------------------------------------------- // open soundfont - const int synthId(fluid_synth_sfload(fSynth, filename, 0)); + const int synthId = fluid_synth_sfload(fSynth, filename, 0); if (synthId < 0) { @@ -1644,7 +1697,12 @@ public: return false; } +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fSynthId = synthId; +#else fSynthId = static_cast(synthId); +#endif + // --------------------------------------------------------------- // get info @@ -1700,43 +1758,60 @@ private: sFluidDefaultsStored = true; // reverb defaults sFluidDefaults[FluidSynthReverbOnOff] = 1.0f; -#if FLUIDSYNTH_VERSION_MAJOR < 2 - sFluidDefaults[FluidSynthReverbRoomSize] = FLUID_REVERB_DEFAULT_ROOMSIZE; - sFluidDefaults[FluidSynthReverbDamp] = FLUID_REVERB_DEFAULT_DAMP; - sFluidDefaults[FluidSynthReverbLevel] = FLUID_REVERB_DEFAULT_LEVEL; - sFluidDefaults[FluidSynthReverbWidth] = FLUID_REVERB_DEFAULT_WIDTH; -#else +#if FLUIDSYNTH_VERSION_MAJOR >= 2 double reverbVal; + + reverbVal = 0.2; fluid_settings_getnum_default(fSettings, "synth.reverb.room-size", &reverbVal); - sFluidDefaults[FluidSynthReverbRoomSize] = reverbVal; + sFluidDefaults[FluidSynthReverbRoomSize] = static_cast(reverbVal); + + reverbVal = 0.0; fluid_settings_getnum_default(fSettings, "synth.reverb.damp", &reverbVal); - sFluidDefaults[FluidSynthReverbDamp] = reverbVal; + sFluidDefaults[FluidSynthReverbDamp] = static_cast(reverbVal); + + reverbVal = 0.9; fluid_settings_getnum_default(fSettings, "synth.reverb.level", &reverbVal); - sFluidDefaults[FluidSynthReverbLevel] = reverbVal; + sFluidDefaults[FluidSynthReverbLevel] = static_cast(reverbVal); + + reverbVal = 0.5; fluid_settings_getnum_default(fSettings, "synth.reverb.width", &reverbVal); - sFluidDefaults[FluidSynthReverbWidth] = reverbVal; + sFluidDefaults[FluidSynthReverbWidth] = static_cast(reverbVal); +#else + sFluidDefaults[FluidSynthReverbRoomSize] = FLUID_REVERB_DEFAULT_ROOMSIZE; + sFluidDefaults[FluidSynthReverbDamp] = FLUID_REVERB_DEFAULT_DAMP; + sFluidDefaults[FluidSynthReverbLevel] = FLUID_REVERB_DEFAULT_LEVEL; + sFluidDefaults[FluidSynthReverbWidth] = FLUID_REVERB_DEFAULT_WIDTH; #endif // chorus defaults sFluidDefaults[FluidSynthChorusOnOff] = 1.0f; -#if FLUIDSYNTH_VERSION_MAJOR < 2 - sFluidDefaults[FluidSynthChorusNr] = FLUID_CHORUS_DEFAULT_N; - sFluidDefaults[FluidSynthChorusLevel] = FLUID_CHORUS_DEFAULT_LEVEL; - sFluidDefaults[FluidSynthChorusSpeedHz] = FLUID_CHORUS_DEFAULT_SPEED; - sFluidDefaults[FluidSynthChorusDepthMs] = FLUID_CHORUS_DEFAULT_DEPTH; - sFluidDefaults[FluidSynthChorusType] = FLUID_CHORUS_DEFAULT_TYPE; -#else +#if FLUIDSYNTH_VERSION_MAJOR >= 2 double chorusVal; + + chorusVal = 3.0; fluid_settings_getnum_default(fSettings, "synth.chorus.nr", &chorusVal); - sFluidDefaults[FluidSynthChorusNr] = chorusVal; + sFluidDefaults[FluidSynthChorusNr] = static_cast(chorusVal); + + chorusVal = 2.0; fluid_settings_getnum_default(fSettings, "synth.chorus.level", &chorusVal); - sFluidDefaults[FluidSynthChorusLevel] = chorusVal; + sFluidDefaults[FluidSynthChorusLevel] = static_cast(chorusVal); + + chorusVal = 0.3; fluid_settings_getnum_default(fSettings, "synth.chorus.speed", &chorusVal); - sFluidDefaults[FluidSynthChorusSpeedHz] = chorusVal; + sFluidDefaults[FluidSynthChorusSpeedHz] = static_cast(chorusVal); + + chorusVal = 8.0; fluid_settings_getnum_default(fSettings, "synth.chorus.depth", &chorusVal); - sFluidDefaults[FluidSynthChorusDepthMs] = chorusVal; + sFluidDefaults[FluidSynthChorusDepthMs] = static_cast(chorusVal); + // There is no settings for chorus default type - sFluidDefaults[FluidSynthChorusType] = (float)fluid_synth_get_chorus_type(fSynth); + sFluidDefaults[FluidSynthChorusType] = static_cast(fluid_synth_get_chorus_type(fSynth)); +#else + sFluidDefaults[FluidSynthChorusNr] = FLUID_CHORUS_DEFAULT_N; + sFluidDefaults[FluidSynthChorusLevel] = FLUID_CHORUS_DEFAULT_LEVEL; + sFluidDefaults[FluidSynthChorusSpeedHz] = FLUID_CHORUS_DEFAULT_SPEED; + sFluidDefaults[FluidSynthChorusDepthMs] = FLUID_CHORUS_DEFAULT_DEPTH; + sFluidDefaults[FluidSynthChorusType] = FLUID_CHORUS_DEFAULT_TYPE; #endif // misc. defaults @@ -1765,12 +1840,16 @@ private: fluid_settings_t* fSettings; fluid_synth_t* fSynth; - uint fSynthId; +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + int fSynthId; +#else + uint fSynthId; +#endif float** fAudio16Buffers; float fParamBuffers[FluidSynthParametersMax]; - static bool sFluidDefaultsStored; + static bool sFluidDefaultsStored; static float sFluidDefaults[FluidSynthParametersMax]; int32_t fCurMidiProgs[MAX_MIDI_CHANNELS]; @@ -1793,23 +1872,32 @@ CARLA_BACKEND_START_NAMESPACE // ------------------------------------------------------------------------------------------------------------------- -CarlaPlugin* CarlaPlugin::newFluidSynth(const Initializer& init, const bool use16Outs) +CarlaPlugin* CarlaPlugin::newFluidSynth(const Initializer& init, PluginType ptype, bool use16Outs) { - carla_debug("CarlaPlugin::newFluidSynth({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %s)", init.engine, init.filename, init.name, init.label, init.uniqueId, bool2str(use16Outs)); + carla_debug("CarlaPlugin::newFluidSynth({%p, \"%s\", \"%s\", \"%s\", " P_INT64 "}, %s)", + init.engine, init.filename, init.name, init.label, init.uniqueId, bool2str(use16Outs)); #ifdef HAVE_FLUIDSYNTH - if (init.engine->getProccessMode() == ENGINE_PROCESS_MODE_CONTINUOUS_RACK && use16Outs) + if (init.engine->getProccessMode() == ENGINE_PROCESS_MODE_CONTINUOUS_RACK) + use16Outs = false; + + if (ptype == PLUGIN_SF2 && ! fluid_is_soundfont(init.filename)) { - init.engine->setLastError("Carla's rack mode can only work with Stereo modules," - "please choose the 2-channel only SoundFont version"); + init.engine->setLastError("Requested file is not a valid SoundFont"); return nullptr; } - - if (! fluid_is_soundfont(init.filename)) +#ifndef HAVE_FLUIDSYNTH_INSTPATCH + if (ptype == PLUGIN_DLS) { - init.engine->setLastError("Requested file is not a valid SoundFont"); + init.engine->setLastError("DLS file support not available"); + return nullptr; + } + if (ptype == PLUGIN_GIG) + { + init.engine->setLastError("GIG file support not available"); return nullptr; } +#endif CarlaPluginFluidSynth* const plugin(new CarlaPluginFluidSynth(init.engine, init.id, use16Outs)); diff --git a/source/backend/utils/Information.cpp b/source/backend/utils/Information.cpp index de844871c..436e1ed81 100644 --- a/source/backend/utils/Information.cpp +++ b/source/backend/utils/Information.cpp @@ -143,6 +143,9 @@ const char* const* carla_get_supported_file_extensions() #ifdef HAVE_FLUIDSYNTH "sf2", "sf3", #endif +#ifdef HAVE_FLUIDSYNTH_INSTPATCH + "dls", "gig", +#endif #ifdef HAVE_ZYN_DEPS "xmz", "xiz", #endif @@ -188,6 +191,9 @@ const char* const* carla_get_supported_features() #ifdef HAVE_FLUIDSYNTH "sf2", #endif +#ifdef HAVE_FLUIDSYNTH_INSTPATCH + "dls", "gig", +#endif #ifdef HAVE_HYLIA "link", #endif diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index ea52950ae..2195f7e23 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -1496,7 +1496,7 @@ static void do_juce_check(const char* const filename_, const char* const stype, } #endif // USING_JUCE_FOR_VST2 -static void do_fluidsynth_check(const char* const filename, const bool doInit) +static void do_fluidsynth_check(const char* const filename, const PluginType type, const bool doInit) { #ifdef HAVE_FLUIDSYNTH const water::String jfilename = water::String(CharPointer_UTF8(filename)); @@ -1508,7 +1508,7 @@ static void do_fluidsynth_check(const char* const filename, const bool doInit) return; } - if (! fluid_is_soundfont(filename)) + if (type == PLUGIN_SF2 && ! fluid_is_soundfont(filename)) { DISCOVERY_OUT("error", "Not a SF2 file"); return; @@ -1524,26 +1524,33 @@ static void do_fluidsynth_check(const char* const filename, const bool doInit) fluid_synth_t* const f_synth = new_fluid_synth(f_settings); CARLA_SAFE_ASSERT_RETURN(f_synth != nullptr,); - const int f_id = fluid_synth_sfload(f_synth, filename, 0); + const int f_id_test = fluid_synth_sfload(f_synth, filename, 0); - if (f_id < 0) + if (f_id_test < 0) { DISCOVERY_OUT("error", "Failed to load SF2 file"); return; } - if (fluid_sfont_t* const f_sfont = fluid_synth_get_sfont_by_id(f_synth, static_cast(f_id))) +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + const int f_id = f_id_test; +#else + const uint f_id = static_cast(f_id_test); +#endif + + if (fluid_sfont_t* const f_sfont = fluid_synth_get_sfont_by_id(f_synth, f_id)) { -#if FLUIDSYNTH_VERSION_MAJOR < 2 +#if FLUIDSYNTH_VERSION_MAJOR >= 2 + fluid_sfont_iteration_start(f_sfont); + for (; fluid_sfont_iteration_next(f_sfont);) + ++programs; +#else fluid_preset_t f_preset; f_sfont->iteration_start(f_sfont); for (; f_sfont->iteration_next(f_sfont, &f_preset);) -#else - fluid_sfont_iteration_start(f_sfont); - for (; fluid_sfont_iteration_next(f_sfont);) -#endif ++programs; +#endif } delete_fluid_synth(f_synth); @@ -1734,8 +1741,10 @@ int main(int argc, char* argv[]) #endif break; + case PLUGIN_DLS: + case PLUGIN_GIG: case PLUGIN_SF2: - do_fluidsynth_check(filename, doInit); + do_fluidsynth_check(filename, type, doInit); break; default: