Update Fluidsynth to v2.0.7

This commit is contained in:
Robin Gareus 2019-09-30 23:10:33 +02:00
parent 549b2447f8
commit 07905f0776
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
9 changed files with 40 additions and 64 deletions

View file

@ -1,7 +1,7 @@
This is a stripped down version of fluidsynth (library only) This is a stripped down version of fluidsynth (library only)
from git://github.com/FluidSynth/fluidsynth.git from git://github.com/FluidSynth/fluidsynth.git
rev. v2.0.6-92-gc6030874 rev. v2.0.7-98-g9ab3e3ab
fluidsynth is licensed in terms of the LGPL-2+, see individual source fluidsynth is licensed in terms of the LGPL-2+, see individual source
files for (C) holders. files for (C) holders.

View file

@ -62,6 +62,7 @@ extern "C" {
FLUIDSYNTH_API int fluid_is_soundfont(const char *filename); FLUIDSYNTH_API int fluid_is_soundfont(const char *filename);
FLUIDSYNTH_API int fluid_is_midifile(const char *filename); FLUIDSYNTH_API int fluid_is_midifile(const char *filename);
FLUIDSYNTH_API void fluid_free(void* ptr);
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -1151,7 +1151,7 @@ new_fluid_preset_zone(char *name)
/* /*
* delete list of modulators. * delete list of modulators.
*/ */
static void delete_fluid_list_mod(fluid_mod_t *mod) void delete_fluid_list_mod(fluid_mod_t *mod)
{ {
fluid_mod_t *tmp; fluid_mod_t *tmp;

View file

@ -178,6 +178,7 @@ struct _fluid_preset_zone_t
}; };
fluid_preset_zone_t *new_fluid_preset_zone(char *name); fluid_preset_zone_t *new_fluid_preset_zone(char *name);
void delete_fluid_list_mod(fluid_mod_t *mod);
void delete_fluid_preset_zone(fluid_preset_zone_t *zone); void delete_fluid_preset_zone(fluid_preset_zone_t *zone);
fluid_preset_zone_t *fluid_preset_zone_next(fluid_preset_zone_t *zone); fluid_preset_zone_t *fluid_preset_zone_next(fluid_preset_zone_t *zone);
int fluid_preset_zone_import_sfont(fluid_preset_zone_t *zone, SFZone *sfzone, fluid_defsfont_t *defssfont); int fluid_preset_zone_import_sfont(fluid_preset_zone_t *zone, SFZone *sfzone, fluid_defsfont_t *defssfont);

View file

@ -1047,7 +1047,7 @@ fluid_settings_copystr(fluid_settings_t *settings, const char *name,
* @since 1.1.0 * @since 1.1.0
* *
* Like fluid_settings_copystr() but allocates a new copy of the string. Caller * Like fluid_settings_copystr() but allocates a new copy of the string. Caller
* owns the string and should free it with free() when done using it. * owns the string and should free it with fluid_free() when done using it.
*/ */
int int
fluid_settings_dupstr(fluid_settings_t *settings, const char *name, char **str) fluid_settings_dupstr(fluid_settings_t *settings, const char *name, char **str)
@ -1116,7 +1116,7 @@ fluid_settings_dupstr(fluid_settings_t *settings, const char *name, char **str)
* @param settings a settings object * @param settings a settings object
* @param name a setting's name * @param name a setting's name
* @param s a string to be tested * @param s a string to be tested
* @return TRUE if the value exists and is equal to 's', FALSE otherwise * @return TRUE if the value exists and is equal to \c s, FALSE otherwise
*/ */
int int
fluid_settings_str_equal(fluid_settings_t *settings, const char *name, const char *s) fluid_settings_str_equal(fluid_settings_t *settings, const char *name, const char *s)
@ -1644,7 +1644,7 @@ int fluid_settings_getint_default(fluid_settings_t *settings, const char *name,
* @param data any user provided pointer * @param data any user provided pointer
* @param func callback function to be called on each iteration * @param func callback function to be called on each iteration
* *
* @note Starting with FluidSynth 1.1.0 the \a func callback is called for each * @note Starting with FluidSynth 1.1.0 the \p func callback is called for each
* option in alphabetical order. Sort order was undefined in previous versions. * option in alphabetical order. Sort order was undefined in previous versions.
*/ */
void void
@ -1727,7 +1727,7 @@ fluid_settings_option_count(fluid_settings_t *settings, const char *name)
* @param name Settings name * @param name Settings name
* @param separator String to use between options (NULL to use ", ") * @param separator String to use between options (NULL to use ", ")
* @return Newly allocated string or NULL on error (out of memory, not a valid * @return Newly allocated string or NULL on error (out of memory, not a valid
* setting \a name or not a string setting). Free the string when finished with it. * setting \p name or not a string setting). Free the string when finished with it by using fluid_free().
* @since 1.1.0 * @since 1.1.0
*/ */
char * char *
@ -1869,7 +1869,7 @@ fluid_settings_foreach_iter(void *key, void *value, void *data)
* @param data any user provided pointer * @param data any user provided pointer
* @param func callback function to be called on each iteration * @param func callback function to be called on each iteration
* *
* @note Starting with FluidSynth 1.1.0 the \a func callback is called for each * @note Starting with FluidSynth 1.1.0 the \p func callback is called for each
* setting in alphabetical order. Sort order was undefined in previous versions. * setting in alphabetical order. Sort order was undefined in previous versions.
*/ */
void void

View file

@ -131,11 +131,6 @@ static void fluid_synth_handle_reverb_chorus_int(void *data, const char *name, i
static void fluid_synth_reset_basic_channel_LOCAL(fluid_synth_t *synth, int chan, int nbr_chan); static void fluid_synth_reset_basic_channel_LOCAL(fluid_synth_t *synth, int chan, int nbr_chan);
static int fluid_synth_check_next_basic_channel(fluid_synth_t *synth, int basicchan, int mode, int val); static int fluid_synth_check_next_basic_channel(fluid_synth_t *synth, int basicchan, int mode, int val);
static void fluid_synth_set_basic_channel_LOCAL(fluid_synth_t *synth, int basicchan, int mode, int val); static void fluid_synth_set_basic_channel_LOCAL(fluid_synth_t *synth, int basicchan, int mode, int val);
static int fluid_synth_set_reverb_full_LOCAL(fluid_synth_t *synth, int set, double roomsize,
double damping, double width, double level);
static int fluid_synth_set_chorus_full_LOCAL(fluid_synth_t *synth, int set, int nr, double level,
double speed, double depth_ms, int type);
/*************************************************************** /***************************************************************
* *
@ -915,7 +910,7 @@ new_fluid_synth(fluid_settings_t *settings)
fluid_settings_getnum(settings, "synth.reverb.width", &width); fluid_settings_getnum(settings, "synth.reverb.width", &width);
fluid_settings_getnum(settings, "synth.reverb.level", &level); fluid_settings_getnum(settings, "synth.reverb.level", &level);
fluid_synth_set_reverb_full_LOCAL(synth, fluid_synth_set_reverb_full(synth,
FLUID_REVMODEL_SET_ALL, FLUID_REVMODEL_SET_ALL,
room, room,
damp, damp,
@ -931,7 +926,7 @@ new_fluid_synth(fluid_settings_t *settings)
fluid_settings_getnum(settings, "synth.chorus.speed", &speed); fluid_settings_getnum(settings, "synth.chorus.speed", &speed);
fluid_settings_getnum(settings, "synth.chorus.depth", &depth); fluid_settings_getnum(settings, "synth.chorus.depth", &depth);
fluid_synth_set_chorus_full_LOCAL(synth, fluid_synth_set_chorus_full(synth,
FLUID_CHORUS_SET_ALL, FLUID_CHORUS_SET_ALL,
i, i,
level, level,
@ -987,8 +982,6 @@ delete_fluid_synth(fluid_synth_t *synth)
fluid_list_t *list; fluid_list_t *list;
fluid_sfont_t *sfont; fluid_sfont_t *sfont;
fluid_sfloader_t *loader; fluid_sfloader_t *loader;
fluid_mod_t *default_mod;
fluid_mod_t *mod;
fluid_return_if_fail(synth != NULL); fluid_return_if_fail(synth != NULL);
@ -1107,14 +1100,7 @@ delete_fluid_synth(fluid_synth_t *synth)
#endif #endif
/* delete all default modulators */ /* delete all default modulators */
default_mod = synth->default_mod; delete_fluid_list_mod(synth->default_mod);
while(default_mod != NULL)
{
mod = default_mod;
default_mod = mod->next;
delete_fluid_mod(mod);
}
FLUID_FREE(synth->overflow.important_channels); FLUID_FREE(synth->overflow.important_channels);
@ -1354,6 +1340,7 @@ fluid_synth_add_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod, int mo
fluid_return_val_if_fail(synth != NULL, FLUID_FAILED); fluid_return_val_if_fail(synth != NULL, FLUID_FAILED);
fluid_return_val_if_fail(mod != NULL, FLUID_FAILED); fluid_return_val_if_fail(mod != NULL, FLUID_FAILED);
fluid_return_val_if_fail((mode == FLUID_SYNTH_ADD) || (mode == FLUID_SYNTH_OVERWRITE) , FLUID_FAILED);
/* Checks if modulators sources are valid */ /* Checks if modulators sources are valid */
if(!fluid_mod_check_sources(mod, "api fluid_synth_add_default_mod mod")) if(!fluid_mod_check_sources(mod, "api fluid_synth_add_default_mod mod"))
@ -1373,14 +1360,10 @@ fluid_synth_add_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod, int mo
{ {
default_mod->amount += mod->amount; default_mod->amount += mod->amount;
} }
else if(mode == FLUID_SYNTH_OVERWRITE) else // mode == FLUID_SYNTH_OVERWRITE
{ {
default_mod->amount = mod->amount; default_mod->amount = mod->amount;
} }
else
{
FLUID_API_RETURN(FLUID_FAILED);
}
FLUID_API_RETURN(FLUID_OK); FLUID_API_RETURN(FLUID_OK);
} }
@ -1419,7 +1402,7 @@ fluid_synth_add_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod, int mo
* @param mod The modulator to remove * @param mod The modulator to remove
* @return #FLUID_OK if a matching modulator was found and successfully removed, #FLUID_FAILED otherwise * @return #FLUID_OK if a matching modulator was found and successfully removed, #FLUID_FAILED otherwise
* *
* @note Not realtime safe (due to internal memory allocation) and therefore should not be called * @note Not realtime safe (due to internal memory freeing) and therefore should not be called
* from synthesis context at the risk of stalling audio output. * from synthesis context at the risk of stalling audio output.
*/ */
int int
@ -1440,7 +1423,7 @@ fluid_synth_remove_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod)
{ {
if(synth->default_mod == default_mod) if(synth->default_mod == default_mod)
{ {
synth->default_mod = synth->default_mod->next; synth->default_mod = default_mod->next;
} }
else else
{ {
@ -5072,6 +5055,7 @@ fluid_synth_set_reverb_full(fluid_synth_t *synth, int set, double roomsize,
double damping, double width, double level) double damping, double width, double level)
{ {
int ret; int ret;
fluid_rvoice_param_t param[MAX_EVENT_PARAMS];
fluid_return_val_if_fail(synth != NULL, FLUID_FAILED); fluid_return_val_if_fail(synth != NULL, FLUID_FAILED);
/* if non of the flags is set, fail */ /* if non of the flags is set, fail */
@ -5080,16 +5064,6 @@ fluid_synth_set_reverb_full(fluid_synth_t *synth, int set, double roomsize,
/* Synth shadow values are set here so that they will be returned if querried */ /* Synth shadow values are set here so that they will be returned if querried */
fluid_synth_api_enter(synth); fluid_synth_api_enter(synth);
ret = fluid_synth_set_reverb_full_LOCAL(synth, set, roomsize, damping, width, level);
FLUID_API_RETURN(ret);
}
static int
fluid_synth_set_reverb_full_LOCAL(fluid_synth_t *synth, int set, double roomsize,
double damping, double width, double level)
{
int ret;
fluid_rvoice_param_t param[MAX_EVENT_PARAMS];
if(set & FLUID_REVMODEL_SET_ROOMSIZE) if(set & FLUID_REVMODEL_SET_ROOMSIZE)
{ {
@ -5121,7 +5095,7 @@ fluid_synth_set_reverb_full_LOCAL(fluid_synth_t *synth, int set, double roomsize
fluid_rvoice_mixer_set_reverb_params, fluid_rvoice_mixer_set_reverb_params,
synth->eventhandler->mixer, synth->eventhandler->mixer,
param); param);
return ret; FLUID_API_RETURN(ret);
} }
/** /**
@ -5287,6 +5261,7 @@ fluid_synth_set_chorus_full(fluid_synth_t *synth, int set, int nr, double level,
double speed, double depth_ms, int type) double speed, double depth_ms, int type)
{ {
int ret; int ret;
fluid_rvoice_param_t param[MAX_EVENT_PARAMS];
fluid_return_val_if_fail(synth != NULL, FLUID_FAILED); fluid_return_val_if_fail(synth != NULL, FLUID_FAILED);
/* if non of the flags is set, fail */ /* if non of the flags is set, fail */
@ -5295,18 +5270,6 @@ fluid_synth_set_chorus_full(fluid_synth_t *synth, int set, int nr, double level,
/* Synth shadow values are set here so that they will be returned if queried */ /* Synth shadow values are set here so that they will be returned if queried */
fluid_synth_api_enter(synth); fluid_synth_api_enter(synth);
ret = fluid_synth_set_chorus_full_LOCAL(synth, set, nr, level, speed, depth_ms, type);
FLUID_API_RETURN(ret);
}
static int
fluid_synth_set_chorus_full_LOCAL(fluid_synth_t *synth, int set, int nr, double level,
double speed, double depth_ms, int type)
{
int ret;
fluid_rvoice_param_t param[MAX_EVENT_PARAMS];
if(set & FLUID_CHORUS_SET_NR) if(set & FLUID_CHORUS_SET_NR)
{ {
synth->chorus_nr = nr; synth->chorus_nr = nr;
@ -5343,7 +5306,7 @@ fluid_synth_set_chorus_full_LOCAL(fluid_synth_t *synth, int set, int nr, double
synth->eventhandler->mixer, synth->eventhandler->mixer,
param); param);
return (ret); FLUID_API_RETURN(ret);
} }
/** /**

View file

@ -192,6 +192,17 @@ fluid_log(int level, const char *fmt, ...)
return FLUID_FAILED; return FLUID_FAILED;
} }
/**
* Convenience wrapper for free() that satisfies at least C90 requirements.
* Especially useful when using fluidsynth with programming languages that do not provide malloc() and free().
* @note Only use this function when the API documentation explicitly says so. Otherwise use adequate \c delete_fluid_* functions.
* @since 2.0.7
*/
void fluid_free(void* ptr)
{
free(ptr);
}
/** /**
* An improved strtok, still trashes the input string, but is portable and * An improved strtok, still trashes the input string, but is portable and
* thread safe. Also skips token chars at beginning of token string and never * thread safe. Also skips token chars at beginning of token string and never

View file

@ -186,7 +186,7 @@ typedef void (*fluid_rvoice_function_t)(void *obj, const fluid_rvoice_param_t pa
#define FLUID_NEW(_t) (_t*)malloc(sizeof(_t)) #define FLUID_NEW(_t) (_t*)malloc(sizeof(_t))
#define FLUID_ARRAY_ALIGNED(_t,_n,_a) (_t*)malloc((_n)*sizeof(_t) + ((unsigned int)_a - 1u)) #define FLUID_ARRAY_ALIGNED(_t,_n,_a) (_t*)malloc((_n)*sizeof(_t) + ((unsigned int)_a - 1u))
#define FLUID_ARRAY(_t,_n) FLUID_ARRAY_ALIGNED(_t,_n,1u) #define FLUID_ARRAY(_t,_n) FLUID_ARRAY_ALIGNED(_t,_n,1u)
#define FLUID_FREE(_p) free(_p) #define FLUID_FREE(_p) fluid_free(_p)
/* File access */ /* File access */
#define FLUID_FOPEN(_f,_m) fopen(_f,_m) #define FLUID_FOPEN(_f,_m) fopen(_f,_m)

View file

@ -163,7 +163,7 @@ index 4ee072e4b9..1b3fceb342 100644
typedef struct _fluid_rvoice_mixer_t fluid_rvoice_mixer_t; typedef struct _fluid_rvoice_mixer_t fluid_rvoice_mixer_t;
diff --git b/libs/fluidsynth/src/fluid_settings.c a/libs/fluidsynth/src/fluid_settings.c diff --git b/libs/fluidsynth/src/fluid_settings.c a/libs/fluidsynth/src/fluid_settings.c
index 5b2b08748f..1811169846 100644 index 78532ad2a3..a825603a44 100644
--- b/libs/fluidsynth/src/fluid_settings.c --- b/libs/fluidsynth/src/fluid_settings.c
+++ a/libs/fluidsynth/src/fluid_settings.c +++ a/libs/fluidsynth/src/fluid_settings.c
@@ -21,9 +21,6 @@ @@ -21,9 +21,6 @@
@ -191,7 +191,7 @@ index 5b2b08748f..1811169846 100644
static int static int
diff --git b/libs/fluidsynth/src/fluid_synth.c a/libs/fluidsynth/src/fluid_synth.c diff --git b/libs/fluidsynth/src/fluid_synth.c a/libs/fluidsynth/src/fluid_synth.c
index 426d3c4fc0..42064f93d6 100644 index 3f602b88d1..570a2535cd 100644
--- b/libs/fluidsynth/src/fluid_synth.c --- b/libs/fluidsynth/src/fluid_synth.c
+++ a/libs/fluidsynth/src/fluid_synth.c +++ a/libs/fluidsynth/src/fluid_synth.c
@@ -25,7 +25,6 @@ @@ -25,7 +25,6 @@
@ -202,7 +202,7 @@ index 426d3c4fc0..42064f93d6 100644
#ifdef TRAP_ON_FPE #ifdef TRAP_ON_FPE
#define _GNU_SOURCE #define _GNU_SOURCE
@@ -268,7 +267,7 @@ void fluid_version(int *major, int *minor, int *micro) @@ -263,7 +262,7 @@ void fluid_version(int *major, int *minor, int *micro)
* @return FluidSynth version string, which is internal and should not be * @return FluidSynth version string, which is internal and should not be
* modified or freed. * modified or freed.
*/ */
@ -211,7 +211,7 @@ index 426d3c4fc0..42064f93d6 100644
fluid_version_str(void) fluid_version_str(void)
{ {
return FLUIDSYNTH_VERSION; return FLUIDSYNTH_VERSION;
@@ -5509,7 +5508,7 @@ fluid_synth_set_interp_method(fluid_synth_t *synth, int chan, int interp_method) @@ -5472,7 +5471,7 @@ fluid_synth_set_interp_method(fluid_synth_t *synth, int chan, int interp_method)
} }
FLUID_API_RETURN(FLUID_OK); FLUID_API_RETURN(FLUID_OK);
@ -220,7 +220,7 @@ index 426d3c4fc0..42064f93d6 100644
/** /**
* Get the total count of MIDI channels. * Get the total count of MIDI channels.
@@ -6447,6 +6446,7 @@ int fluid_synth_set_channel_type(fluid_synth_t *synth, int chan, int type) @@ -6410,6 +6409,7 @@ int fluid_synth_set_channel_type(fluid_synth_t *synth, int chan, int type)
FLUID_API_RETURN(FLUID_OK); FLUID_API_RETURN(FLUID_OK);
} }
@ -228,7 +228,7 @@ index 426d3c4fc0..42064f93d6 100644
/** /**
* Return the LADSPA effects instance used by FluidSynth * Return the LADSPA effects instance used by FluidSynth
* *
@@ -6459,6 +6459,7 @@ fluid_ladspa_fx_t *fluid_synth_get_ladspa_fx(fluid_synth_t *synth) @@ -6422,6 +6422,7 @@ fluid_ladspa_fx_t *fluid_synth_get_ladspa_fx(fluid_synth_t *synth)
return synth->ladspa_fx; return synth->ladspa_fx;
} }
@ -260,10 +260,10 @@ index 0b9758bad5..fe222f7b6f 100644
enum fluid_iir_filter_flags custom_filter_flags; /**< filter type of the user-defined filter currently used for all voices */ enum fluid_iir_filter_flags custom_filter_flags; /**< filter type of the user-defined filter currently used for all voices */
}; };
diff --git b/libs/fluidsynth/src/fluid_sys.c a/libs/fluidsynth/src/fluid_sys.c diff --git b/libs/fluidsynth/src/fluid_sys.c a/libs/fluidsynth/src/fluid_sys.c
index 5d123883b3..938c05cf22 100644 index 8128fbba91..f6c56d3995 100644
--- b/libs/fluidsynth/src/fluid_sys.c --- b/libs/fluidsynth/src/fluid_sys.c
+++ a/libs/fluidsynth/src/fluid_sys.c +++ a/libs/fluidsynth/src/fluid_sys.c
@@ -205,9 +205,10 @@ fluid_log(int level, const char *fmt, ...) @@ -216,9 +216,10 @@ void fluid_free(void* ptr)
* @param delim String of delimiter chars. * @param delim String of delimiter chars.
* @return Pointer to the next token or NULL if no more tokens. * @return Pointer to the next token or NULL if no more tokens.
*/ */