Browse Source

Pass DLS/GIG files into fluidsynth if version is recent enough

Signed-off-by: falkTX <falktx@falktx.com>
tags/v2.2.0-RC1
falkTX 4 years ago
parent
commit
29c55500a7
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
7 changed files with 198 additions and 76 deletions
  1. +5
    -0
      Makefile
  2. +8
    -0
      source/Makefile.mk
  3. +1
    -1
      source/backend/CarlaPlugin.hpp
  4. +7
    -1
      source/backend/engine/CarlaEngine.cpp
  5. +151
    -63
      source/backend/plugin/CarlaPluginFluidSynth.cpp
  6. +6
    -0
      source/backend/utils/Information.cpp
  7. +20
    -11
      source/discovery/carla-discovery.cpp

+ 5
- 0
Makefile View File

@@ -976,6 +976,11 @@ ifeq ($(HAVE_FFMPEG),true)
else else
@printf -- "Extra: $(ANS_NO) $(mS)FFmpeg missing or too new$(mE)\n" @printf -- "Extra: $(ANS_NO) $(mS)FFmpeg missing or too new$(mE)\n"
endif 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) ifeq ($(HAVE_FLUIDSYNTH),true)
@printf -- "SF2/3: $(ANS_YES)\n" @printf -- "SF2/3: $(ANS_YES)\n"
else else


+ 8
- 0
source/Makefile.mk View File

@@ -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) $(PKG_CONFIG) --variable=qt_config Qt5Core | grep -q -v "static" && echo true)
HAVE_SNDFILE = $(shell $(PKG_CONFIG) --exists sndfile && 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) ifeq ($(LINUX),true)
# juce only supports the most common architectures # juce only supports the most common architectures
ifneq (,$(findstring arm,$(TARGET_MACHINE))) ifneq (,$(findstring arm,$(TARGET_MACHINE)))
@@ -377,6 +382,9 @@ endif


ifeq ($(HAVE_FLUIDSYNTH),true) ifeq ($(HAVE_FLUIDSYNTH),true)
BASE_FLAGS += -DHAVE_FLUIDSYNTH BASE_FLAGS += -DHAVE_FLUIDSYNTH
ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
endif
endif endif


ifeq ($(HAVE_FFMPEG),true) ifeq ($(HAVE_FFMPEG),true)


+ 1
- 1
source/backend/CarlaPlugin.hpp View File

@@ -954,7 +954,7 @@ public:
static CarlaPlugin* newAU(const Initializer& init); static CarlaPlugin* newAU(const Initializer& init);


static CarlaPlugin* newJuce(const Initializer& init, const char* format); 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* newSFZero(const Initializer& init);


static CarlaPlugin* newJackApp(const Initializer& init); static CarlaPlugin* newJackApp(const Initializer& init);


+ 7
- 1
source/backend/engine/CarlaEngine.cpp View File

@@ -621,7 +621,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype,
case PLUGIN_GIG: case PLUGIN_GIG:
case PLUGIN_SF2: case PLUGIN_SF2:
use16Outs = (extra != nullptr && std::strcmp((const char*)extra, "true") == 0); use16Outs = (extra != nullptr && std::strcmp((const char*)extra, "true") == 0);
plugin = CarlaPlugin::newFluidSynth(initializer, use16Outs);
plugin = CarlaPlugin::newFluidSynth(initializer, ptype, use16Outs);
break; break;


case PLUGIN_SFZ: 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") if (extension == "sf2" || extension == "sf3")
return addPlugin(PLUGIN_SF2, filename, baseName, baseName, 0, nullptr); return addPlugin(PLUGIN_SF2, filename, baseName, baseName, 0, nullptr);




+ 151
- 63
source/backend/plugin/CarlaPluginFluidSynth.cpp View File

@@ -67,8 +67,15 @@ public:
fluid_settings_setint(fSettings, "synth.audio-groups", use16Outs ? 16 : 1); 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.sample-rate", pData->engine->getSampleRate());
//fluid_settings_setnum(fSettings, "synth.cpu-cores", 2); //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); fluid_settings_setint(fSettings, "synth.parallel-render", 1);
#endif
fluid_settings_setint(fSettings, "synth.threadsafe-api", 0); fluid_settings_setint(fSettings, "synth.threadsafe-api", 0);
#ifdef DEBUG
fluid_settings_setint(fSettings, "synth.verbose", 1);
#endif


// create synth // create synth
fSynth = new_fluid_synth(fSettings); fSynth = new_fluid_synth(fSettings);
@@ -76,7 +83,9 @@ public:


initializeFluidDefaultsIfNeeded(); initializeFluidDefaultsIfNeeded();


fluid_synth_set_sample_rate(fSynth, (float)pData->engine->getSampleRate());
#if FLUIDSYNTH_VERSION_MAJOR < 2
fluid_synth_set_sample_rate(fSynth, static_cast<float>(pData->engine->getSampleRate()));
#endif


// set default values // set default values
fluid_synth_set_reverb_on(fSynth, 1); fluid_synth_set_reverb_on(fSynth, 1);
@@ -458,17 +467,17 @@ public:
case FluidSynthChorusType: case FluidSynthChorusType:
try { try {
fluid_synth_set_chorus(fSynth, fluid_synth_set_chorus(fSynth,
(int)fParamBuffers[FluidSynthChorusNr],
static_cast<int>(fParamBuffers[FluidSynthChorusNr] + 0.5f),
fParamBuffers[FluidSynthChorusLevel], fParamBuffers[FluidSynthChorusLevel],
fParamBuffers[FluidSynthChorusSpeedHz], fParamBuffers[FluidSynthChorusSpeedHz],
fParamBuffers[FluidSynthChorusDepthMs], fParamBuffers[FluidSynthChorusDepthMs],
(int)fParamBuffers[FluidSynthChorusType]);
static_cast<int>(fParamBuffers[FluidSynthChorusType] + 0.5f));
} CARLA_SAFE_EXCEPTION("fluid_synth_set_chorus") } CARLA_SAFE_EXCEPTION("fluid_synth_set_chorus")
break; break;


case FluidSynthPolyphony: case FluidSynthPolyphony:
try { try {
fluid_synth_set_polyphony(fSynth, (int)value);
fluid_synth_set_polyphony(fSynth, static_cast<int>(value + 0.5f));
} CARLA_SAFE_EXCEPTION("fluid_synth_set_polyphony") } CARLA_SAFE_EXCEPTION("fluid_synth_set_polyphony")
break; break;


@@ -476,7 +485,7 @@ public:
for (int i=0; i < MAX_MIDI_CHANNELS; ++i) for (int i=0; i < MAX_MIDI_CHANNELS; ++i)
{ {
try { try {
fluid_synth_set_interp_method(fSynth, i, (int)value);
fluid_synth_set_interp_method(fSynth, i, static_cast<int>(value + 0.5f));
} CARLA_SAFE_EXCEPTION_BREAK("fluid_synth_set_interp_method") } CARLA_SAFE_EXCEPTION_BREAK("fluid_synth_set_interp_method")
} }
break; break;
@@ -519,7 +528,15 @@ public:
const uint32_t bank = pData->midiprog.data[index].bank; const uint32_t bank = pData->midiprog.data[index].bank;
const uint32_t program = pData->midiprog.data[index].program; const uint32_t program = pData->midiprog.data[index].program;


#if FLUIDSYNTH_VERSION_MAJOR >= 2
fluid_synth_program_select(fSynth,
static_cast<int>(channel),
fSynthId,
static_cast<int>(bank),
static_cast<int>(program));
#else
fluid_synth_program_select(fSynth, channel, fSynthId, bank, program); fluid_synth_program_select(fSynth, channel, fSynthId, bank, program);
#endif
fCurMidiProgs[channel] = index; fCurMidiProgs[channel] = index;


if (pData->ctrlChannel == static_cast<int32_t>(channel)) if (pData->ctrlChannel == static_cast<int32_t>(channel))
@@ -555,7 +572,12 @@ public:
const ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback)); const ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback));


try { try {
#if FLUIDSYNTH_VERSION_MAJOR >= 2
fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId,
static_cast<int>(bank), static_cast<int>(program));
#else
fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId, bank, program); fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId, bank, program);
#endif
} CARLA_SAFE_EXCEPTION("fluid_synth_program_select") } CARLA_SAFE_EXCEPTION("fluid_synth_program_select")


fCurMidiProgs[pData->ctrlChannel] = index; fCurMidiProgs[pData->ctrlChannel] = index;
@@ -576,7 +598,12 @@ public:
const uint32_t program = pData->midiprog.data[uindex].program; const uint32_t program = pData->midiprog.data[uindex].program;


try { try {
#if FLUIDSYNTH_VERSION_MAJOR >= 2
fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId,
static_cast<int>(bank), static_cast<int>(program));
#else
fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId, bank, program); fluid_synth_program_select(fSynth, pData->ctrlChannel, fSynthId, bank, program);
#endif
} CARLA_SAFE_EXCEPTION("fluid_synth_program_select") } CARLA_SAFE_EXCEPTION("fluid_synth_program_select")


fCurMidiProgs[pData->ctrlChannel] = static_cast<int32_t>(uindex); fCurMidiProgs[pData->ctrlChannel] = static_cast<int32_t>(uindex);
@@ -752,7 +779,7 @@ public:
pData->param.data[j].index = j; pData->param.data[j].index = j;
pData->param.data[j].rindex = j; pData->param.data[j].rindex = j;
pData->param.ranges[j].min = 0.0f; 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].def = sFluidDefaults[j];
pData->param.ranges[j].step = 0.01f; pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f; pData->param.ranges[j].stepSmall = 0.0001f;
@@ -857,7 +884,11 @@ public:
pData->param.data[j].index = j; pData->param.data[j].index = j;
pData->param.data[j].rindex = j; pData->param.data[j].rindex = j;
pData->param.ranges[j].min = 0.0f; 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? 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].def = sFluidDefaults[j];
pData->param.ranges[j].step = 0.01f; pData->param.ranges[j].step = 0.01f;
pData->param.ranges[j].stepSmall = 0.0001f; pData->param.ranges[j].stepSmall = 0.0001f;
@@ -910,7 +941,7 @@ public:
pData->param.data[j].rindex = j; pData->param.data[j].rindex = j;
pData->param.ranges[j].min = 0.0f; pData->param.ranges[j].min = 0.0f;
pData->param.ranges[j].max = 65535.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].step = 1.0f;
pData->param.ranges[j].stepSmall = 1.0f; pData->param.ranges[j].stepSmall = 1.0f;
pData->param.ranges[j].stepLarge = 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 (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 // 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; ++count;


// sound kits must always have at least 1 midi-program // sound kits must always have at least 1 midi-program
@@ -976,25 +1007,25 @@ public:
// Update data // Update data
int tmp; int tmp;
uint32_t i = 0; 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); 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<uint32_t>(tmp) : 0; pData->midiprog.data[i].bank = (tmp >= 0) ? static_cast<uint32_t>(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<uint32_t>(tmp) : 0; pData->midiprog.data[i].program = (tmp >= 0) ? static_cast<uint32_t>(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 #else
fluid_preset_t* f_preset;
fluid_preset_t f_preset;


// initial check to know how many midi-programs we have // 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; ++count;


// sound kits must always have at least 1 midi-program // sound kits must always have at least 1 midi-program
@@ -1005,19 +1036,19 @@ public:
// Update data // Update data
int tmp; int tmp;
uint32_t i = 0; 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); 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<uint32_t>(tmp) : 0; pData->midiprog.data[i].bank = (tmp >= 0) ? static_cast<uint32_t>(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<uint32_t>(tmp) : 0; pData->midiprog.data[i].program = (tmp >= 0) ? static_cast<uint32_t>(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 #endif


if (pData->midiprog.data[i].bank == 128 && ! hasDrums) if (pData->midiprog.data[i].bank == 128 && ! hasDrums)
@@ -1045,23 +1076,38 @@ public:
for (int i=0; i < MAX_MIDI_CHANNELS && i != 9; ++i) for (int i=0; i < MAX_MIDI_CHANNELS && i != 9; ++i)
{ {
fluid_synth_set_channel_type(fSynth, i, CHANNEL_TYPE_MELODIC); 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<int>(pData->midiprog.data[0].bank),
static_cast<int>(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; fCurMidiProgs[i] = 0;
} }


if (hasDrums) if (hasDrums)
{ {
fluid_synth_set_channel_type(fSynth, 9, CHANNEL_TYPE_DRUM); 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<int>(drumProg));
#else
fluid_synth_program_select(fSynth, 9, fSynthId, 128, drumProg); fluid_synth_program_select(fSynth, 9, fSynthId, 128, drumProg);

#endif
fCurMidiProgs[9] = static_cast<int32_t>(drumIndex); fCurMidiProgs[9] = static_cast<int32_t>(drumIndex);
} }
else else
{ {
fluid_synth_set_channel_type(fSynth, 9, CHANNEL_TYPE_MELODIC); 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<int>(pData->midiprog.data[0].bank),
static_cast<int>(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; fCurMidiProgs[9] = 0;
} }


@@ -1274,7 +1320,12 @@ public:
{ {
if (pData->midiprog.data[k].bank == bankId && pData->midiprog.data[k].program == progId) 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<int>(bankId), static_cast<int>(progId));
#else
fluid_synth_program_select(fSynth, event.channel, fSynthId, bankId, progId); fluid_synth_program_select(fSynth, event.channel, fSynthId, bankId, progId);
#endif
fCurMidiProgs[event.channel] = static_cast<int32_t>(k); fCurMidiProgs[event.channel] = static_cast<int32_t>(k);


if (event.channel == pData->ctrlChannel) if (event.channel == pData->ctrlChannel)
@@ -1560,8 +1611,10 @@ public:
CARLA_SAFE_ASSERT_RETURN(fSettings != nullptr,); CARLA_SAFE_ASSERT_RETURN(fSettings != nullptr,);
fluid_settings_setnum(fSettings, "synth.sample-rate", newSampleRate); fluid_settings_setnum(fSettings, "synth.sample-rate", newSampleRate);


#if FLUIDSYNTH_VERSION_MAJOR < 2
CARLA_SAFE_ASSERT_RETURN(fSynth != nullptr,); CARLA_SAFE_ASSERT_RETURN(fSynth != nullptr,);
fluid_synth_set_sample_rate(fSynth, float(newSampleRate));
fluid_synth_set_sample_rate(fSynth, static_cast<float>(newSampleRate));
#endif
} }


// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -1636,7 +1689,7 @@ public:
// --------------------------------------------------------------- // ---------------------------------------------------------------
// open soundfont // open soundfont


const int synthId(fluid_synth_sfload(fSynth, filename, 0));
const int synthId = fluid_synth_sfload(fSynth, filename, 0);


if (synthId < 0) if (synthId < 0)
{ {
@@ -1644,7 +1697,12 @@ public:
return false; return false;
} }


#if FLUIDSYNTH_VERSION_MAJOR >= 2
fSynthId = synthId;
#else
fSynthId = static_cast<uint>(synthId); fSynthId = static_cast<uint>(synthId);
#endif



// --------------------------------------------------------------- // ---------------------------------------------------------------
// get info // get info
@@ -1700,43 +1758,60 @@ private:
sFluidDefaultsStored = true; sFluidDefaultsStored = true;
// reverb defaults // reverb defaults
sFluidDefaults[FluidSynthReverbOnOff] = 1.0f; 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; double reverbVal;

reverbVal = 0.2;
fluid_settings_getnum_default(fSettings, "synth.reverb.room-size", &reverbVal); fluid_settings_getnum_default(fSettings, "synth.reverb.room-size", &reverbVal);
sFluidDefaults[FluidSynthReverbRoomSize] = reverbVal;
sFluidDefaults[FluidSynthReverbRoomSize] = static_cast<float>(reverbVal);

reverbVal = 0.0;
fluid_settings_getnum_default(fSettings, "synth.reverb.damp", &reverbVal); fluid_settings_getnum_default(fSettings, "synth.reverb.damp", &reverbVal);
sFluidDefaults[FluidSynthReverbDamp] = reverbVal;
sFluidDefaults[FluidSynthReverbDamp] = static_cast<float>(reverbVal);

reverbVal = 0.9;
fluid_settings_getnum_default(fSettings, "synth.reverb.level", &reverbVal); fluid_settings_getnum_default(fSettings, "synth.reverb.level", &reverbVal);
sFluidDefaults[FluidSynthReverbLevel] = reverbVal;
sFluidDefaults[FluidSynthReverbLevel] = static_cast<float>(reverbVal);

reverbVal = 0.5;
fluid_settings_getnum_default(fSettings, "synth.reverb.width", &reverbVal); fluid_settings_getnum_default(fSettings, "synth.reverb.width", &reverbVal);
sFluidDefaults[FluidSynthReverbWidth] = reverbVal;
sFluidDefaults[FluidSynthReverbWidth] = static_cast<float>(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 #endif


// chorus defaults // chorus defaults
sFluidDefaults[FluidSynthChorusOnOff] = 1.0f; 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; double chorusVal;

chorusVal = 3.0;
fluid_settings_getnum_default(fSettings, "synth.chorus.nr", &chorusVal); fluid_settings_getnum_default(fSettings, "synth.chorus.nr", &chorusVal);
sFluidDefaults[FluidSynthChorusNr] = chorusVal;
sFluidDefaults[FluidSynthChorusNr] = static_cast<float>(chorusVal);

chorusVal = 2.0;
fluid_settings_getnum_default(fSettings, "synth.chorus.level", &chorusVal); fluid_settings_getnum_default(fSettings, "synth.chorus.level", &chorusVal);
sFluidDefaults[FluidSynthChorusLevel] = chorusVal;
sFluidDefaults[FluidSynthChorusLevel] = static_cast<float>(chorusVal);

chorusVal = 0.3;
fluid_settings_getnum_default(fSettings, "synth.chorus.speed", &chorusVal); fluid_settings_getnum_default(fSettings, "synth.chorus.speed", &chorusVal);
sFluidDefaults[FluidSynthChorusSpeedHz] = chorusVal;
sFluidDefaults[FluidSynthChorusSpeedHz] = static_cast<float>(chorusVal);

chorusVal = 8.0;
fluid_settings_getnum_default(fSettings, "synth.chorus.depth", &chorusVal); fluid_settings_getnum_default(fSettings, "synth.chorus.depth", &chorusVal);
sFluidDefaults[FluidSynthChorusDepthMs] = chorusVal;
sFluidDefaults[FluidSynthChorusDepthMs] = static_cast<float>(chorusVal);

// There is no settings for chorus default type // There is no settings for chorus default type
sFluidDefaults[FluidSynthChorusType] = (float)fluid_synth_get_chorus_type(fSynth);
sFluidDefaults[FluidSynthChorusType] = static_cast<float>(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 #endif


// misc. defaults // misc. defaults
@@ -1765,12 +1840,16 @@ private:


fluid_settings_t* fSettings; fluid_settings_t* fSettings;
fluid_synth_t* fSynth; fluid_synth_t* fSynth;
uint fSynthId;
#if FLUIDSYNTH_VERSION_MAJOR >= 2
int fSynthId;
#else
uint fSynthId;
#endif


float** fAudio16Buffers; float** fAudio16Buffers;
float fParamBuffers[FluidSynthParametersMax]; float fParamBuffers[FluidSynthParametersMax];


static bool sFluidDefaultsStored;
static bool sFluidDefaultsStored;
static float sFluidDefaults[FluidSynthParametersMax]; static float sFluidDefaults[FluidSynthParametersMax];


int32_t fCurMidiProgs[MAX_MIDI_CHANNELS]; 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 #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; 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; return nullptr;
} }
#endif


CarlaPluginFluidSynth* const plugin(new CarlaPluginFluidSynth(init.engine, init.id, use16Outs)); CarlaPluginFluidSynth* const plugin(new CarlaPluginFluidSynth(init.engine, init.id, use16Outs));




+ 6
- 0
source/backend/utils/Information.cpp View File

@@ -143,6 +143,9 @@ const char* const* carla_get_supported_file_extensions()
#ifdef HAVE_FLUIDSYNTH #ifdef HAVE_FLUIDSYNTH
"sf2", "sf3", "sf2", "sf3",
#endif #endif
#ifdef HAVE_FLUIDSYNTH_INSTPATCH
"dls", "gig",
#endif
#ifdef HAVE_ZYN_DEPS #ifdef HAVE_ZYN_DEPS
"xmz", "xiz", "xmz", "xiz",
#endif #endif
@@ -188,6 +191,9 @@ const char* const* carla_get_supported_features()
#ifdef HAVE_FLUIDSYNTH #ifdef HAVE_FLUIDSYNTH
"sf2", "sf2",
#endif #endif
#ifdef HAVE_FLUIDSYNTH_INSTPATCH
"dls", "gig",
#endif
#ifdef HAVE_HYLIA #ifdef HAVE_HYLIA
"link", "link",
#endif #endif


+ 20
- 11
source/discovery/carla-discovery.cpp View File

@@ -1496,7 +1496,7 @@ static void do_juce_check(const char* const filename_, const char* const stype,
} }
#endif // USING_JUCE_FOR_VST2 #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 #ifdef HAVE_FLUIDSYNTH
const water::String jfilename = water::String(CharPointer_UTF8(filename)); 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; return;
} }


if (! fluid_is_soundfont(filename))
if (type == PLUGIN_SF2 && ! fluid_is_soundfont(filename))
{ {
DISCOVERY_OUT("error", "Not a SF2 file"); DISCOVERY_OUT("error", "Not a SF2 file");
return; 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); fluid_synth_t* const f_synth = new_fluid_synth(f_settings);
CARLA_SAFE_ASSERT_RETURN(f_synth != nullptr,); 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"); DISCOVERY_OUT("error", "Failed to load SF2 file");
return; return;
} }


if (fluid_sfont_t* const f_sfont = fluid_synth_get_sfont_by_id(f_synth, static_cast<uint>(f_id)))
#if FLUIDSYNTH_VERSION_MAJOR >= 2
const int f_id = f_id_test;
#else
const uint f_id = static_cast<uint>(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; fluid_preset_t f_preset;


f_sfont->iteration_start(f_sfont); f_sfont->iteration_start(f_sfont);
for (; f_sfont->iteration_next(f_sfont, &f_preset);) 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; ++programs;
#endif
} }


delete_fluid_synth(f_synth); delete_fluid_synth(f_synth);
@@ -1734,8 +1741,10 @@ int main(int argc, char* argv[])
#endif #endif
break; break;


case PLUGIN_DLS:
case PLUGIN_GIG:
case PLUGIN_SF2: case PLUGIN_SF2:
do_fluidsynth_check(filename, doInit);
do_fluidsynth_check(filename, type, doInit);
break; break;


default: default:


Loading…
Cancel
Save