midi_fluidsynth.c: Don't use API functions deprecated in FluidSynth v2.2.0 if building with v2.2.0 or later

This commit is contained in:
Alexander Babikov
2023-07-13 03:27:22 +05:00
parent 8d07acd0b5
commit 908108b6ef

View File

@@ -21,6 +21,12 @@
# define RENDER_RATE 100
# define BUFFER_SEGMENTS 10
/* Check the FluidSynth version to determine wheteher to use the older reverb/chorus
control functions that were deprecated in 2.2.0, or their newer replacements */
# if (FLUIDSYNTH_VERSION_MAJOR < 2) || ((FLUIDSYNTH_VERSION_MAJOR == 2) && (FLUIDSYNTH_VERSION_MINOR < 2))
# define USE_OLD_FLUIDSYNTH_API
# endif
extern void givealbuffer_midi(void *buf, uint32_t size);
extern void al_set_midi(int freq, int buf_size);
@@ -168,7 +174,11 @@ fluidsynth_init(const device_t *info)
data->sound_font = fluid_synth_sfload(data->synth, sound_font, 1);
if (device_get_config_int("chorus")) {
# ifndef USE_OLD_FLUIDSYNTH_API
fluid_synth_chorus_on(data->synth, -1, 1);
# else
fluid_synth_set_chorus_on(data->synth, 1);
# endif
int chorus_voices = device_get_config_int("chorus_voices");
double chorus_level = device_get_config_int("chorus_level") / 100.0;
@@ -181,21 +191,48 @@ fluidsynth_init(const device_t *info)
else
chorus_waveform = FLUID_CHORUS_MOD_TRIANGLE;
# ifndef USE_OLD_FLUIDSYNTH_API
fluid_synth_set_chorus_group_nr(data->synth, -1, chorus_voices);
fluid_synth_set_chorus_group_level(data->synth, -1, chorus_level);
fluid_synth_set_chorus_group_speed(data->synth, -1, chorus_speed);
fluid_synth_set_chorus_group_depth(data->synth, -1, chorus_depth);
fluid_synth_set_chorus_group_type(data->synth, -1, chorus_waveform);
# else
fluid_synth_set_chorus(data->synth, chorus_voices, chorus_level, chorus_speed, chorus_depth, chorus_waveform);
# endif
} else
# ifndef USE_OLD_FLUIDSYNTH_API
fluid_synth_chorus_on(data->synth, -1, 0);
# else
fluid_synth_set_chorus_on(data->synth, 0);
# endif
if (device_get_config_int("reverb")) {
# ifndef USE_OLD_FLUIDSYNTH_API
fluid_synth_reverb_on(data->synth, -1, 1);
# else
fluid_synth_set_reverb_on(data->synth, 1);
# endif
double reverb_room_size = device_get_config_int("reverb_room_size") / 100.0;
double reverb_damping = device_get_config_int("reverb_damping") / 100.0;
int reverb_width = device_get_config_int("reverb_width");
double reverb_level = device_get_config_int("reverb_level") / 100.0;
# ifndef USE_OLD_FLUIDSYNTH_API
fluid_synth_set_reverb_group_roomsize(data->synth, -1, reverb_room_size);
fluid_synth_set_reverb_group_damp(data->synth, -1, reverb_damping);
fluid_synth_set_reverb_group_width(data->synth, -1, reverb_width);
fluid_synth_set_reverb_group_level(data->synth, -1, reverb_level);
# else
fluid_synth_set_reverb(data->synth, reverb_room_size, reverb_damping, reverb_width, reverb_level);
# endif
} else
# ifndef USE_OLD_FLUIDSYNTH_API
fluid_synth_reverb_on(data->synth, -1, 0);
# else
fluid_synth_set_reverb_on(data->synth, 0);
# endif
int interpolation = device_get_config_int("interpolation");
int fs_interpolation = FLUID_INTERP_4THORDER;