Skip to content

Commit

Permalink
Fix build with FluidSynth 2.x (#7)
Browse files Browse the repository at this point in the history
fluid_preset_t has been made opaque, so use the new accessor functions
to fix the build when using FluidSynth 2.x.  Fixes #6.

Signed-off-by: Tobias Kortkamp <t@tobik.me>
  • Loading branch information
Tobias Kortkamp authored and falkTX committed Dec 9, 2018
1 parent 889b256 commit 8457f10
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions source/FluidPlug.c
Expand Up @@ -130,11 +130,19 @@ static LV2_Handle lv2_instantiate(const struct _LV2_Descriptor* descriptor, doub
goto cleanup_synth;

size_t count;
#if FLUIDSYNTH_VERSION_MAJOR < 2
fluid_preset_t preset;

sfont->iteration_start(sfont);
for (count = 0; sfont->iteration_next(sfont, &preset) != 0;)
++count;
#else
fluid_preset_t *preset = NULL;

fluid_sfont_iteration_start(sfont);
for (count = 0; (preset = fluid_sfont_iteration_next(sfont)) != NULL;)
++count;
#endif

if (count == 0)
goto cleanup_synth;
Expand All @@ -144,6 +152,7 @@ static LV2_Handle lv2_instantiate(const struct _LV2_Descriptor* descriptor, doub
if (programs == NULL)
goto cleanup_synth;

#if FLUIDSYNTH_VERSION_MAJOR < 2
sfont->iteration_start(sfont);
for (count = 0; sfont->iteration_next(sfont, &preset) != 0;)
{
Expand All @@ -153,6 +162,17 @@ static LV2_Handle lv2_instantiate(const struct _LV2_Descriptor* descriptor, doub
};
programs[count++] = bp;
}
#else
fluid_sfont_iteration_start(sfont);
for (count = 0; (preset = fluid_sfont_iteration_next(sfont)) != NULL;)
{
const BankProgram bp = {
fluid_preset_get_banknum(preset),
fluid_preset_get_num(preset)
};
programs[count++] = bp;
}
#endif

fluid_synth_program_select(synth, 0, synthId, programs[0].bank, programs[0].prog);

Expand Down

0 comments on commit 8457f10

Please sign in to comment.