From 9be61b5cd467c6e866ac8a59308920ef3fd710fc Mon Sep 17 00:00:00 2001 From: carlo-bramini Date: Sun, 22 Oct 2017 19:10:41 +0200 Subject: [PATCH 1/8] 'deprecated' is not supported on MSVC6. --- include/fluidsynth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fluidsynth.h b/include/fluidsynth.h index 1da4587f..5526409b 100644 --- a/include/fluidsynth.h +++ b/include/fluidsynth.h @@ -48,7 +48,7 @@ extern "C" { #if defined(__GNUC__) || defined(__clang__) # define FLUID_DEPRECATED __attribute__((deprecated)) -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && _MSC_VER > 1400 # define FLUID_DEPRECATED __declspec(deprecated) #else # define FLUID_DEPRECATED From e1c3b46ee2612e898983c7d275003b6238c3d914 Mon Sep 17 00:00:00 2001 From: carlo-bramini Date: Sun, 22 Oct 2017 19:13:16 +0200 Subject: [PATCH 2/8] Fix an handle leak --- src/bindings/fluid_cmd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bindings/fluid_cmd.c b/src/bindings/fluid_cmd.c index 5f8241db..ccec3bfe 100644 --- a/src/bindings/fluid_cmd.c +++ b/src/bindings/fluid_cmd.c @@ -387,6 +387,7 @@ fluid_source(fluid_cmd_handler_t* handler, const char *filename) { int file; fluid_shell_t shell; + int result; #ifdef WIN32 file = _open(filename, _O_RDONLY); @@ -397,7 +398,11 @@ fluid_source(fluid_cmd_handler_t* handler, const char *filename) return file; } fluid_shell_init(&shell, NULL, handler, file, fluid_get_stdout()); - return fluid_shell_run(&shell); + result = fluid_shell_run(&shell); + + close(file); + + return result; } /** From 9d49d29aafde6fee0fb644f2dcb9cdb6e14b7079 Mon Sep 17 00:00:00 2001 From: carlo-bramini Date: Sun, 22 Oct 2017 19:19:14 +0200 Subject: [PATCH 3/8] Declare list_of_generators_to_initialize[] as global static const. --- src/synth/fluid_voice.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/synth/fluid_voice.c b/src/synth/fluid_voice.c index a3a2cdb8..e282c355 100644 --- a/src/synth/fluid_voice.c +++ b/src/synth/fluid_voice.c @@ -488,22 +488,7 @@ fluid_voice_calculate_gen_pitch(fluid_voice_t* voice) } -/* - * fluid_voice_calculate_runtime_synthesis_parameters - * - * in this function we calculate the values of all the parameters. the - * parameters are converted to their most useful unit for the DSP - * algorithm, for example, number of samples instead of - * timecents. Some parameters keep their "perceptual" unit and - * conversion will be done in the DSP function. This is the case, for - * example, for the pitch since it is modulated by the controllers in - * cents. */ -static int -fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) -{ - int i; - - int list_of_generators_to_initialize[35] = { +static int const list_of_generators_to_initialize[] = { GEN_STARTADDROFS, /* SF2.01 page 48 #0 */ GEN_ENDADDROFS, /* #1 */ GEN_STARTLOOPADDROFS, /* #2 */ @@ -553,8 +538,23 @@ fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) /* GEN_COARSETUNE [1] #51 */ /* GEN_FINETUNE [1] #52 */ GEN_OVERRIDEROOTKEY, /* #58 */ - GEN_PITCH, /* --- */ - -1}; /* end-of-list marker */ + GEN_PITCH /* --- */ +}; + +/* + * fluid_voice_calculate_runtime_synthesis_parameters + * + * in this function we calculate the values of all the parameters. the + * parameters are converted to their most useful unit for the DSP + * algorithm, for example, number of samples instead of + * timecents. Some parameters keep their "perceptual" unit and + * conversion will be done in the DSP function. This is the case, for + * example, for the pitch since it is modulated by the controllers in + * cents. */ +static int +fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) +{ + int i; /* When the voice is made ready for the synthesis process, a lot of * voice-internal parameters have to be calculated. @@ -598,7 +598,7 @@ fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) */ /* Calculate the voice parameter(s) dependent on each generator. */ - for (i = 0; list_of_generators_to_initialize[i] != -1; i++) { + for (i = 0; i < FLUID_N_ELEMENTS(list_of_generators_to_initialize); i++) { fluid_voice_update_param(voice, list_of_generators_to_initialize[i]); } @@ -702,7 +702,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) fluid_real_t y; unsigned int count, z; // Alternate attenuation scale used by EMU10K1 cards when setting the attenuation at the preset or instrument level within the SoundFont bank. - static const float ALT_ATTENUATION_SCALE = 0.4; + static const float ALT_ATTENUATION_SCALE = 0.4f; switch (gen) { From 7db133acae92c8e98f322e11279af323758dd376 Mon Sep 17 00:00:00 2001 From: carlo-bramini Date: Sun, 22 Oct 2017 19:40:14 +0200 Subject: [PATCH 4/8] 'mod_count' of struct fluid_voice_t should be an unsigned type. --- src/synth/fluid_voice.c | 11 ++++++----- src/synth/fluid_voice.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/synth/fluid_voice.c b/src/synth/fluid_voice.c index e282c355..c53dfa05 100644 --- a/src/synth/fluid_voice.c +++ b/src/synth/fluid_voice.c @@ -554,7 +554,7 @@ static int const list_of_generators_to_initialize[] = { static int fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) { - int i; + unsigned int i; /* When the voice is made ready for the synthesis process, a lot of * voice-internal parameters have to be calculated. @@ -1113,7 +1113,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) */ int fluid_voice_modulate(fluid_voice_t* voice, int cc, int ctrl) { - int i, k; + unsigned int i, k; fluid_mod_t* mod; int gen; fluid_real_t modval; @@ -1158,7 +1158,8 @@ int fluid_voice_modulate(fluid_voice_t* voice, int cc, int ctrl) int fluid_voice_modulate_all(fluid_voice_t* voice) { fluid_mod_t* mod; - int i, k, gen; + unsigned int i, k; + int gen; fluid_real_t modval; /* Loop through all the modulators. @@ -1342,7 +1343,7 @@ fluid_voice_stop(fluid_voice_t* voice) void fluid_voice_add_mod(fluid_voice_t* voice, fluid_mod_t* mod, int mode) { - int i; + unsigned int i; /* * Some soundfonts come with a huge number of non-standard @@ -1557,7 +1558,7 @@ int fluid_voice_get_velocity(const fluid_voice_t* voice) static fluid_real_t fluid_voice_get_lower_boundary_for_attenuation(fluid_voice_t* voice) { - int i; + unsigned int i; fluid_mod_t* mod; fluid_real_t possible_att_reduction_cB=0; fluid_real_t lower_bound; diff --git a/src/synth/fluid_voice.h b/src/synth/fluid_voice.h index 5b0442bf..b43c0403 100644 --- a/src/synth/fluid_voice.h +++ b/src/synth/fluid_voice.h @@ -68,7 +68,7 @@ struct _fluid_voice_t fluid_channel_t* channel; fluid_gen_t gen[GEN_LAST]; fluid_mod_t mod[FLUID_NUM_MOD]; - int mod_count; + unsigned int mod_count; fluid_sample_t* sample; /* Pointer to sample (dupe in rvoice) */ /* basic parameters */ From 6068c207280d6dd79eee691b8051976fce0d134f Mon Sep 17 00:00:00 2001 From: carlo-bramini Date: Tue, 24 Oct 2017 20:23:21 +0200 Subject: [PATCH 5/8] Place again list_of_generators_to_initialize[] inside fluid_voice_calculate_runtime_synthesis_parameters() --- src/synth/fluid_voice.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/synth/fluid_voice.c b/src/synth/fluid_voice.c index c53dfa05..72b087d0 100644 --- a/src/synth/fluid_voice.c +++ b/src/synth/fluid_voice.c @@ -488,7 +488,22 @@ fluid_voice_calculate_gen_pitch(fluid_voice_t* voice) } -static int const list_of_generators_to_initialize[] = { +/* + * fluid_voice_calculate_runtime_synthesis_parameters + * + * in this function we calculate the values of all the parameters. the + * parameters are converted to their most useful unit for the DSP + * algorithm, for example, number of samples instead of + * timecents. Some parameters keep their "perceptual" unit and + * conversion will be done in the DSP function. This is the case, for + * example, for the pitch since it is modulated by the controllers in + * cents. */ +static int +fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) +{ + unsigned int i; + + static int const list_of_generators_to_initialize[] = { GEN_STARTADDROFS, /* SF2.01 page 48 #0 */ GEN_ENDADDROFS, /* #1 */ GEN_STARTLOOPADDROFS, /* #2 */ @@ -539,22 +554,7 @@ static int const list_of_generators_to_initialize[] = { /* GEN_FINETUNE [1] #52 */ GEN_OVERRIDEROOTKEY, /* #58 */ GEN_PITCH /* --- */ -}; - -/* - * fluid_voice_calculate_runtime_synthesis_parameters - * - * in this function we calculate the values of all the parameters. the - * parameters are converted to their most useful unit for the DSP - * algorithm, for example, number of samples instead of - * timecents. Some parameters keep their "perceptual" unit and - * conversion will be done in the DSP function. This is the case, for - * example, for the pitch since it is modulated by the controllers in - * cents. */ -static int -fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) -{ - unsigned int i; + }; /* When the voice is made ready for the synthesis process, a lot of * voice-internal parameters have to be calculated. From 96f0f5fe887924a5a36a1801f5fa878c225fab3e Mon Sep 17 00:00:00 2001 From: carlo-bramini Date: Tue, 24 Oct 2017 20:25:58 +0200 Subject: [PATCH 6/8] Use _close() on _WIN32 --- src/bindings/fluid_cmd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bindings/fluid_cmd.c b/src/bindings/fluid_cmd.c index ccec3bfe..4cbdaa04 100644 --- a/src/bindings/fluid_cmd.c +++ b/src/bindings/fluid_cmd.c @@ -400,7 +400,11 @@ fluid_source(fluid_cmd_handler_t* handler, const char *filename) fluid_shell_init(&shell, NULL, handler, file, fluid_get_stdout()); result = fluid_shell_run(&shell); +#ifdef WIN32 + _close(file); +#else close(file); +#endif return result; } From 36f0ecb12a276fd5a93a6c17e7700650aadcdde7 Mon Sep 17 00:00:00 2001 From: carlo-bramini Date: Tue, 24 Oct 2017 20:31:56 +0200 Subject: [PATCH 7/8] MSVC6 is the latest version not supporting deprecated declpec --- include/fluidsynth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fluidsynth.h b/include/fluidsynth.h index 5526409b..edb57d24 100644 --- a/include/fluidsynth.h +++ b/include/fluidsynth.h @@ -48,7 +48,7 @@ extern "C" { #if defined(__GNUC__) || defined(__clang__) # define FLUID_DEPRECATED __attribute__((deprecated)) -#elif defined(_MSC_VER) && _MSC_VER > 1400 +#elif defined(_MSC_VER) && _MSC_VER > 1200 # define FLUID_DEPRECATED __declspec(deprecated) #else # define FLUID_DEPRECATED From 2e175731792bca48cace84c79dafb21a6ea72f11 Mon Sep 17 00:00:00 2001 From: derselbst Date: Wed, 25 Oct 2017 17:41:56 +0200 Subject: [PATCH 8/8] Revert "'mod_count' of struct fluid_voice_t should be an unsigned type." This reverts commit 7db133acae92c8e98f322e11279af323758dd376. --- src/synth/fluid_voice.c | 16 ++++++++-------- src/synth/fluid_voice.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/synth/fluid_voice.c b/src/synth/fluid_voice.c index 72b087d0..8a996c44 100644 --- a/src/synth/fluid_voice.c +++ b/src/synth/fluid_voice.c @@ -501,7 +501,8 @@ fluid_voice_calculate_gen_pitch(fluid_voice_t* voice) static int fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) { - unsigned int i; + int i; + unsigned int n; static int const list_of_generators_to_initialize[] = { GEN_STARTADDROFS, /* SF2.01 page 48 #0 */ @@ -598,8 +599,8 @@ fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t* voice) */ /* Calculate the voice parameter(s) dependent on each generator. */ - for (i = 0; i < FLUID_N_ELEMENTS(list_of_generators_to_initialize); i++) { - fluid_voice_update_param(voice, list_of_generators_to_initialize[i]); + for (n = 0; n < FLUID_N_ELEMENTS(list_of_generators_to_initialize); n++) { + fluid_voice_update_param(voice, list_of_generators_to_initialize[n]); } /* Make an estimate on how loud this voice can get at any time (attenuation). */ @@ -1113,7 +1114,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) */ int fluid_voice_modulate(fluid_voice_t* voice, int cc, int ctrl) { - unsigned int i, k; + int i, k; fluid_mod_t* mod; int gen; fluid_real_t modval; @@ -1158,8 +1159,7 @@ int fluid_voice_modulate(fluid_voice_t* voice, int cc, int ctrl) int fluid_voice_modulate_all(fluid_voice_t* voice) { fluid_mod_t* mod; - unsigned int i, k; - int gen; + int i, k, gen; fluid_real_t modval; /* Loop through all the modulators. @@ -1343,7 +1343,7 @@ fluid_voice_stop(fluid_voice_t* voice) void fluid_voice_add_mod(fluid_voice_t* voice, fluid_mod_t* mod, int mode) { - unsigned int i; + int i; /* * Some soundfonts come with a huge number of non-standard @@ -1558,7 +1558,7 @@ int fluid_voice_get_velocity(const fluid_voice_t* voice) static fluid_real_t fluid_voice_get_lower_boundary_for_attenuation(fluid_voice_t* voice) { - unsigned int i; + int i; fluid_mod_t* mod; fluid_real_t possible_att_reduction_cB=0; fluid_real_t lower_bound; diff --git a/src/synth/fluid_voice.h b/src/synth/fluid_voice.h index b43c0403..5b0442bf 100644 --- a/src/synth/fluid_voice.h +++ b/src/synth/fluid_voice.h @@ -68,7 +68,7 @@ struct _fluid_voice_t fluid_channel_t* channel; fluid_gen_t gen[GEN_LAST]; fluid_mod_t mod[FLUID_NUM_MOD]; - unsigned int mod_count; + int mod_count; fluid_sample_t* sample; /* Pointer to sample (dupe in rvoice) */ /* basic parameters */