From 9900d5f1511be120ea09267819f06257179c2b0b Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 16:56:51 +0100 Subject: [PATCH 01/24] rename fluid_mod_new|delete() to match naming conventions --- doc/fluidsynth-v11-devdoc.txt | 1 + include/fluidsynth/mod.h | 4 ++-- src/sfloader/fluid_defsfont.c | 8 ++++---- src/synth/fluid_mod.c | 4 ++-- src/synth/fluid_synth.c | 6 +++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 663b1303..01951a69 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -91,6 +91,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - the shell command handler was decoupled internally, as a consequence the param list of new_fluid_server() and new_fluid_cmd_handler() was adapted - reverb: roomsize is now limited to an upper threshold of 1.0 - use unique device names for the "audio.portaudio.device" setting +- rename fluid_mod_new() and fluid_mod_delete() to match naming conventions: new_fluid_mod() and delete_fluid_mod()

- add "synth.volenv" a setting for volume envelope processing - add "midi.autoconnect" a setting for automatically connecting fluidsynth to available MIDI input ports diff --git a/include/fluidsynth/mod.h b/include/fluidsynth/mod.h index 857a622e..8721722d 100644 --- a/include/fluidsynth/mod.h +++ b/include/fluidsynth/mod.h @@ -68,8 +68,8 @@ enum fluid_mod_src FLUID_MOD_PITCHWHEELSENS = 16 /**< Pitch wheel sensitivity */ }; -FLUIDSYNTH_API fluid_mod_t* fluid_mod_new(void); -FLUIDSYNTH_API void fluid_mod_delete(fluid_mod_t * mod); +FLUIDSYNTH_API fluid_mod_t* new_fluid_mod(void); +FLUIDSYNTH_API void delete_fluid_mod(fluid_mod_t * mod); FLUIDSYNTH_API void fluid_mod_set_source1(fluid_mod_t* mod, int src, int flags); FLUIDSYNTH_API void fluid_mod_set_source2(fluid_mod_t* mod, int src, int flags); diff --git a/src/sfloader/fluid_defsfont.c b/src/sfloader/fluid_defsfont.c index 6595a715..148a7817 100644 --- a/src/sfloader/fluid_defsfont.c +++ b/src/sfloader/fluid_defsfont.c @@ -1221,7 +1221,7 @@ delete_fluid_preset_zone(fluid_preset_zone_t* zone) { tmp = mod; mod = mod->next; - fluid_mod_delete (tmp); + delete_fluid_mod (tmp); } FLUID_FREE (zone->name); @@ -1272,7 +1272,7 @@ fluid_preset_zone_import_sfont(fluid_preset_zone_t* zone, SFZone *sfzone, fluid_ for (count = 0, r = sfzone->mod; r != NULL; count++) { SFMod* mod_src = (SFMod *)r->data; - fluid_mod_t * mod_dest = fluid_mod_new(); + fluid_mod_t * mod_dest = new_fluid_mod(); int type; if (mod_dest == NULL){ @@ -1613,7 +1613,7 @@ delete_fluid_inst_zone(fluid_inst_zone_t* zone) { tmp = mod; mod = mod->next; - fluid_mod_delete (tmp); + delete_fluid_mod (tmp); } FLUID_FREE (zone->name); @@ -1675,7 +1675,7 @@ fluid_inst_zone_import_sfont(fluid_inst_zone_t* zone, SFZone *sfzone, fluid_defs int type; fluid_mod_t* mod_dest; - mod_dest = fluid_mod_new(); + mod_dest = new_fluid_mod(); if (mod_dest == NULL){ return FLUID_FAILED; } diff --git a/src/synth/fluid_mod.c b/src/synth/fluid_mod.c index 1dd7ec63..fb8e497f 100644 --- a/src/synth/fluid_mod.c +++ b/src/synth/fluid_mod.c @@ -383,7 +383,7 @@ fluid_mod_get_value(fluid_mod_t* mod, fluid_channel_t* chan, fluid_voice_t* voic * @return New allocated modulator or NULL if out of memory */ fluid_mod_t* -fluid_mod_new() +new_fluid_mod() { fluid_mod_t* mod = FLUID_NEW (fluid_mod_t); if (mod == NULL) { @@ -398,7 +398,7 @@ fluid_mod_new() * @param mod Modulator to free */ void -fluid_mod_delete (fluid_mod_t *mod) +delete_fluid_mod (fluid_mod_t *mod) { FLUID_FREE(mod); } diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 104df082..0ab50972 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -931,7 +931,7 @@ delete_fluid_synth(fluid_synth_t* synth) while (default_mod != NULL) { mod = default_mod; default_mod = mod->next; - fluid_mod_delete(mod); + delete_fluid_mod(mod); } fluid_rec_mutex_destroy(synth->mutex); @@ -1130,7 +1130,7 @@ fluid_synth_add_default_mod(fluid_synth_t* synth, fluid_mod_t* mod, int mode) } /* Add a new modulator (no existing modulator to add / overwrite). */ - new_mod = fluid_mod_new(); + new_mod = new_fluid_mod(); if (new_mod == NULL) FLUID_API_RETURN(FLUID_FAILED); @@ -1175,7 +1175,7 @@ fluid_synth_remove_default_mod(fluid_synth_t* synth, const fluid_mod_t* mod) { last_mod->next = default_mod->next; } - fluid_mod_delete(default_mod); + delete_fluid_mod(default_mod); FLUID_API_RETURN(FLUID_OK); } last_mod = default_mod; From 52872305f27a027500d640e210c3fe80fc419dc6 Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 17:11:06 +0100 Subject: [PATCH 02/24] move FLUID_NUM_MOD to public voice header --- include/fluidsynth/mod.h | 1 - include/fluidsynth/voice.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fluidsynth/mod.h b/include/fluidsynth/mod.h index 8721722d..298b36e2 100644 --- a/include/fluidsynth/mod.h +++ b/include/fluidsynth/mod.h @@ -30,7 +30,6 @@ extern "C" { * @brief SoundFont modulator functions and constants. */ -#define FLUID_NUM_MOD 64 /**< Maximum number of modulators in a voice */ /** * Flags defining the polarity, mapping function and type of a modulator source. diff --git a/include/fluidsynth/voice.h b/include/fluidsynth/voice.h index f28e1dc3..a6086f4b 100644 --- a/include/fluidsynth/voice.h +++ b/include/fluidsynth/voice.h @@ -35,6 +35,7 @@ extern "C" { * such as the SoundFont loader's noteon method. */ +#define FLUID_NUM_MOD 64 /**< Maximum number of modulators in a voice */ FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t* voice, int gen); From 4776b7e407e1723c52800690303df6b92040c7bf Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 17:19:29 +0100 Subject: [PATCH 03/24] remove macro fluid_sfont_get_id() from public API --- doc/fluidsynth-v11-devdoc.txt | 1 + include/fluidsynth/sfont.h | 1 - src/sfloader/fluid_sfont.h | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 01951a69..23d3bcfd 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -85,6 +85,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove fluid_synth_set_gen2(), fluid_synth_set_gen() now behaves as fluid_synth_set_gen2() - remove struct fluid_mod_t from public API, use the getters and setters of mod.h instead - remove struct _fluid_gen_t, fluid_gen_set_default_values() and enum fluid_gen_flags from public API +- remove macro fluid_sfont_get_id() from public API

- all public \c fluid_settings_* functions that return an integer which is not meant to be interpreted as bool consistently return either FLUID_OK or FLUID_FAILED - all public delete_* functions return void and are safe when called with NULL diff --git a/include/fluidsynth/sfont.h b/include/fluidsynth/sfont.h index 4e617dbf..49b64b0f 100644 --- a/include/fluidsynth/sfont.h +++ b/include/fluidsynth/sfont.h @@ -191,7 +191,6 @@ struct _fluid_sfont_t { int (*iteration_next)(fluid_sfont_t* sfont, fluid_preset_t* preset); }; -#define fluid_sfont_get_id(_sf) ((_sf)->id) /** * Virtual SoundFont preset. diff --git a/src/sfloader/fluid_sfont.h b/src/sfloader/fluid_sfont.h index 434eac25..226d8d9a 100644 --- a/src/sfloader/fluid_sfont.h +++ b/src/sfloader/fluid_sfont.h @@ -32,6 +32,8 @@ #define delete_fluid_sfont(_sf) ( ((_sf) && (_sf)->free)? (*(_sf)->free)(_sf) : 0) + +#define fluid_sfont_get_id(_sf) ((_sf)->id) #define fluid_sfont_get_name(_sf) (*(_sf)->get_name)(_sf) #define fluid_sfont_get_preset(_sf,_bank,_prenum) (*(_sf)->get_preset)(_sf,_bank,_prenum) #define fluid_sfont_iteration_start(_sf) (*(_sf)->iteration_start)(_sf) From 4d65e07156ef3d59ce9a2600ca32ea6fe3f936ad Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 17:27:37 +0100 Subject: [PATCH 04/24] get rid of redundant fluid_sample_refcount macro and access field directly --- doc/fluidsynth-v11-devdoc.txt | 2 +- include/fluidsynth/sfont.h | 3 +-- src/sfloader/fluid_defsfont.c | 2 +- src/sfloader/fluid_ramsfont.c | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 23d3bcfd..94c779d7 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -85,7 +85,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove fluid_synth_set_gen2(), fluid_synth_set_gen() now behaves as fluid_synth_set_gen2() - remove struct fluid_mod_t from public API, use the getters and setters of mod.h instead - remove struct _fluid_gen_t, fluid_gen_set_default_values() and enum fluid_gen_flags from public API -- remove macro fluid_sfont_get_id() from public API +- remove macros fluid_sfont_get_id() and fluid_sample_refcount() from public API

- all public \c fluid_settings_* functions that return an integer which is not meant to be interpreted as bool consistently return either FLUID_OK or FLUID_FAILED - all public delete_* functions return void and are safe when called with NULL diff --git a/include/fluidsynth/sfont.h b/include/fluidsynth/sfont.h index 49b64b0f..86a90721 100644 --- a/include/fluidsynth/sfont.h +++ b/include/fluidsynth/sfont.h @@ -290,7 +290,7 @@ struct _fluid_sample_t int amplitude_that_reaches_noise_floor_is_valid; /**< Indicates if \a amplitude_that_reaches_noise_floor is valid (TRUE), set to FALSE initially to calculate. */ double amplitude_that_reaches_noise_floor; /**< The amplitude at which the sample's loop will be below the noise floor. For voice off optimization, calculated automatically. */ - unsigned int refcount; /**< Count of voices using this sample (use #fluid_sample_refcount to access this field) */ + unsigned int refcount; /**< Count of voices using this sample */ /** * Implement this function to receive notification when sample is no longer used. @@ -304,7 +304,6 @@ struct _fluid_sample_t }; -#define fluid_sample_refcount(_sample) ((_sample)->refcount) /**< Get the reference count of a sample. Should only be called from within synthesis context (noteon method for example) */ #define FLUID_SAMPLETYPE_MONO 1 /**< Flag for #fluid_sample_t \a sampletype field for mono samples */ diff --git a/src/sfloader/fluid_defsfont.c b/src/sfloader/fluid_defsfont.c index 148a7817..e76c1217 100644 --- a/src/sfloader/fluid_defsfont.c +++ b/src/sfloader/fluid_defsfont.c @@ -552,7 +552,7 @@ int delete_fluid_defsfont(fluid_defsfont_t* sfont) /* Check that no samples are currently used */ for (list = sfont->sample; list; list = fluid_list_next(list)) { sample = (fluid_sample_t*) fluid_list_get(list); - if (fluid_sample_refcount(sample) != 0) { + if (sample->refcount != 0) { return FLUID_FAILED; } } diff --git a/src/sfloader/fluid_ramsfont.c b/src/sfloader/fluid_ramsfont.c index d75eb545..a0da0360 100644 --- a/src/sfloader/fluid_ramsfont.c +++ b/src/sfloader/fluid_ramsfont.c @@ -256,7 +256,7 @@ delete_fluid_ramsfont (fluid_ramsfont_t* sfont) /* Check that no samples are currently used */ for (list = sfont->sample; list; list = fluid_list_next(list)) { fluid_sample_t* sam = (fluid_sample_t*) fluid_list_get(list); - if (fluid_sample_refcount(sam) != 0) { + if (sam->refcount != 0) { return -1; } } From 9f366f3320ce93a3378c7bd542358ea918428dad Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 17:38:33 +0100 Subject: [PATCH 05/24] move SAMPLETYPE macros to enum --- include/fluidsynth/sfont.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/include/fluidsynth/sfont.h b/include/fluidsynth/sfont.h index 86a90721..4502ae82 100644 --- a/include/fluidsynth/sfont.h +++ b/include/fluidsynth/sfont.h @@ -70,6 +70,18 @@ enum { FLUID_SAMPLE_DONE /**< Sample no longer needed notify */ }; +/** + * Indicates the type of a sample used by the _fluid_sample_t::sampletype field. + */ +enum fluid_sample_type +{ + FLUID_SAMPLETYPE_MONO = 0x1, /**< Used for mono samples */ + FLUID_SAMPLETYPE_RIGHT = 0x2, /**< Used for right samples of a stereo pair */ + FLUID_SAMPLETYPE_LEFT = 0x4, /**< Used for left samples of a stereo pair */ + FLUID_SAMPLETYPE_LINKED = 0x8, /**< Currently not used */ + FLUID_SAMPLETYPE_OGG_VORBIS = 0x10, /**< Used for Ogg Vorbis compressed samples @since 1.1.7 */ + FLUID_SAMPLETYPE_ROM = 0x8000 /**< Indicates ROM samples, causes sample to be ignored */ +}; /** * SoundFont loader structure. @@ -283,7 +295,7 @@ struct _fluid_sample_t unsigned int samplerate; /**< Sample rate */ int origpitch; /**< Original pitch (MIDI note number, 0-127) */ int pitchadj; /**< Fine pitch adjustment (+/- 99 cents) */ - int sampletype; /**< Values: #FLUID_SAMPLETYPE_MONO, FLUID_SAMPLETYPE_RIGHT, FLUID_SAMPLETYPE_LEFT, FLUID_SAMPLETYPE_ROM */ + int sampletype; /**< Specifies the type of this sample as indicated by the #fluid_sample_type enum */ int valid; /**< Should be TRUE if sample data is valid, FALSE otherwise (in which case it will not be synthesized) */ short* data; /**< Pointer to the sample's data */ @@ -304,17 +316,6 @@ struct _fluid_sample_t }; - - -#define FLUID_SAMPLETYPE_MONO 1 /**< Flag for #fluid_sample_t \a sampletype field for mono samples */ -#define FLUID_SAMPLETYPE_RIGHT 2 /**< Flag for #fluid_sample_t \a sampletype field for right samples of a stereo pair */ -#define FLUID_SAMPLETYPE_LEFT 4 /**< Flag for #fluid_sample_t \a sampletype field for left samples of a stereo pair */ -#define FLUID_SAMPLETYPE_LINKED 8 /**< Flag for #fluid_sample_t \a sampletype field, not used currently */ -#define FLUID_SAMPLETYPE_OGG_VORBIS 0x10 /**< Flag for #fluid_sample_t \a sampletype field for Ogg Vorbis compressed samples @since 1.1.7 */ -#define FLUID_SAMPLETYPE_ROM 0x8000 /**< Flag for #fluid_sample_t \a sampletype field, ROM sample, causes sample to be ignored */ - - - #ifdef __cplusplus } #endif From 62df9178aec57a7004ada6f89dfc6cf1be66fa34 Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 17:49:10 +0100 Subject: [PATCH 06/24] remove deprecated fluid_synth_get_channel_info() it provided functionality in between of fluid_synth_get_program() and fluid_synth_get_channel_preset(), which however was not visible from the user perspective --- doc/fluidsynth-v11-devdoc.txt | 2 +- include/fluidsynth/synth.h | 19 ------------ include/fluidsynth/types.h | 1 - src/synth/fluid_synth.c | 57 ----------------------------------- 4 files changed, 1 insertion(+), 78 deletions(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 94c779d7..1e227853 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -74,7 +74,7 @@ FluidSynths SOVERSION was bumped. The API was reworked, deprecated functions wer Changes in FluidSynth 2.0.0 concerning developers: -- remove deprecated fluid_synth_get_program() and fluid_synth_get_channel_preset(), use fluid_synth_get_channel_info() instead +- remove deprecated fluid_synth_get_channel_info() in favour of fluid_synth_get_program() and fluid_synth_get_channel_preset() - remove deprecated fluid_settings_getstr() - remove deprecated fluid_synth_set_midi_router() - remove deprecated fluid_get_hinstance() and fluid_set_hinstance() (dsound driver now uses the desktop window) diff --git a/include/fluidsynth/synth.h b/include/fluidsynth/synth.h index a459e761..179d8a09 100644 --- a/include/fluidsynth/synth.h +++ b/include/fluidsynth/synth.h @@ -45,22 +45,6 @@ extern "C" { * fluid_synth_noteon(), fluid_synth_noteoff(), ... */ -#define FLUID_SYNTH_CHANNEL_INFO_NAME_SIZE 32 /**< Length of channel info name field (including zero terminator) */ - -/** - * Channel information structure for fluid_synth_get_channel_info(). - * @since 2.0.0 - */ -struct _fluid_synth_channel_info_t -{ - int assigned : 1; /**< TRUE if a preset is assigned, FALSE otherwise */ - /* Reserved flag bits (at the least 31) */ - int sfont_id; /**< ID of parent SoundFont */ - int bank; /**< MIDI bank number (0-16383) */ - int program; /**< MIDI program number (0-127) */ - char name[FLUID_SYNTH_CHANNEL_INFO_NAME_SIZE]; /**< Channel preset name */ - char reserved[32]; /**< Reserved data for future expansion */ -}; FLUIDSYNTH_API fluid_synth_t* new_fluid_synth(fluid_settings_t* settings); FLUIDSYNTH_API void delete_fluid_synth(fluid_synth_t* synth); @@ -95,9 +79,6 @@ FLUIDSYNTH_API int fluid_synth_get_program(fluid_synth_t* synth, int chan, unsigned int* sfont_id, unsigned int* bank_num, unsigned int* preset_num); FLUIDSYNTH_API int fluid_synth_unset_program (fluid_synth_t *synth, int chan); -FLUIDSYNTH_API -FLUID_DEPRECATED -int fluid_synth_get_channel_info (fluid_synth_t *synth, int chan, fluid_synth_channel_info_t *info); FLUIDSYNTH_API int fluid_synth_program_reset(fluid_synth_t* synth); FLUIDSYNTH_API int fluid_synth_system_reset(fluid_synth_t* synth); diff --git a/include/fluidsynth/types.h b/include/fluidsynth/types.h index bf826a41..eeb05b5f 100644 --- a/include/fluidsynth/types.h +++ b/include/fluidsynth/types.h @@ -35,7 +35,6 @@ extern "C" { typedef struct _fluid_hashtable_t fluid_settings_t; /**< Configuration settings instance */ typedef struct _fluid_synth_t fluid_synth_t; /**< Synthesizer instance */ -typedef struct _fluid_synth_channel_info_t fluid_synth_channel_info_t; /**< SoundFont channel info */ typedef struct _fluid_voice_t fluid_voice_t; /**< Synthesis voice instance */ typedef struct _fluid_sfloader_t fluid_sfloader_t; /**< SoundFont loader plugin */ typedef struct _fluid_sfont_t fluid_sfont_t; /**< SoundFont */ diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 0ab50972..3566ef52 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -3810,63 +3810,6 @@ fluid_synth_get_channel_preset(fluid_synth_t* synth, int chan) return result; } -/** - * Get information on the currently selected preset on a MIDI channel. - * @param synth FluidSynth instance - * @param chan MIDI channel number (0 to MIDI channel count - 1) - * @param info Caller supplied structure to fill with preset information - * @return #FLUID_OK on success, #FLUID_FAILED otherwise - * @deprecated Provides redundant functionality that can be achieved with - * fluid_synth_get_channel_preset() or fluid_synth_get_program(). - * @since 1.1.1 - */ -int -fluid_synth_get_channel_info (fluid_synth_t *synth, int chan, - fluid_synth_channel_info_t *info) -{ - fluid_channel_t *channel; - fluid_preset_t *preset; - const char *name; - - if (info) - { - info->assigned = FALSE; - info->name[0] = '\0'; - } - - fluid_return_val_if_fail (info != NULL, FLUID_FAILED); - FLUID_API_ENTRY_CHAN(FLUID_FAILED); - - channel = synth->channel[chan]; - preset = channel->preset; - - if (preset) - { - info->assigned = TRUE; - name = fluid_preset_get_name (preset); - - if (name) - { - strncpy (info->name, name, FLUID_SYNTH_CHANNEL_INFO_NAME_SIZE); - info->name[FLUID_SYNTH_CHANNEL_INFO_NAME_SIZE - 1] = '\0'; - } - else info->name[0] = '\0'; - - info->sfont_id = preset->sfont->id; - info->bank = fluid_preset_get_banknum (preset); - info->program = fluid_preset_get_num (preset); - } - else - { - info->assigned = FALSE; - fluid_channel_get_sfont_bank_prog (channel, &info->sfont_id, &info->bank, &info->program); - info->name[0] = '\0'; - } - - fluid_synth_api_exit(synth); - return FLUID_OK; -} - /** * Get list of currently playing voices. * @param synth FluidSynth instance From 7140e971ec4b607b831548f69840d2b4cc17f773 Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 17:52:58 +0100 Subject: [PATCH 07/24] remove deprecated fluid_synth_create_key_tuning() --- doc/fluidsynth-v11-devdoc.txt | 1 + include/fluidsynth/synth.h | 4 ---- src/synth/fluid_synth.c | 24 ------------------------ 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 1e227853..406510d1 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -78,6 +78,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove deprecated fluid_settings_getstr() - remove deprecated fluid_synth_set_midi_router() - remove deprecated fluid_get_hinstance() and fluid_set_hinstance() (dsound driver now uses the desktop window) +- remove deprecated fluid_synth_create_key_tuning(), use fluid_synth_activate_key_tuning(synth, bank, prog, name, pitch, FALSE) instead - remove deprecated FLUID_HINT_INTEGER - remove misspelled FLUID_SEQ_PITCHWHHELSENS macro - remove obsolete "audio.[out|in]put-channels" settings diff --git a/include/fluidsynth/synth.h b/include/fluidsynth/synth.h index 179d8a09..bdfdd634 100644 --- a/include/fluidsynth/synth.h +++ b/include/fluidsynth/synth.h @@ -225,10 +225,6 @@ FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t* synth, int chan, int par /* Tuning */ -FLUIDSYNTH_API -FLUID_DEPRECATED -int fluid_synth_create_key_tuning(fluid_synth_t* synth, int bank, int prog, - const char* name, const double* pitch); FLUIDSYNTH_API int fluid_synth_activate_key_tuning(fluid_synth_t* synth, int bank, int prog, const char* name, const double* pitch, int apply); diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 3566ef52..a27db271 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -4500,30 +4500,6 @@ fluid_synth_update_voice_tuning_LOCAL (fluid_synth_t *synth, fluid_channel_t *ch } } -/** - * Set the tuning of the entire MIDI note scale. - * @param synth FluidSynth instance - * @param bank Tuning bank number (0-127), not related to MIDI instrument bank - * @param prog Tuning preset number (0-127), not related to MIDI instrument program - * @param name Label name for this tuning - * @param pitch Array of pitch values (length of 128, each value is number of - * cents, for example normally note 0 is 0.0, 1 is 100.0, 60 is 6000.0, etc). - * Pass NULL to create a equal tempered (normal) scale. - * @return FLUID_OK on success, FLUID_FAILED otherwise - * - * @note Tuning is not applied in realtime to existing notes of the replaced - * tuning (if any), use fluid_synth_activate_key_tuning() instead to specify - * this behavior. - * - * @deprecated Use fluid_synth_activate_key_tuning(synth, bank, prog, name, pitch, FALSE) instead. - */ -int -fluid_synth_create_key_tuning(fluid_synth_t* synth, int bank, int prog, - const char* name, const double* pitch) -{ - return fluid_synth_activate_key_tuning (synth, bank, prog, name, pitch, FALSE); -} - /** * Set the tuning of the entire MIDI note scale. * @param synth FluidSynth instance From 0bb872658319457e97dbff68c838009a5ba895af Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 17:56:03 +0100 Subject: [PATCH 08/24] remove deprecated fluid_synth_create_octave_tuning() --- doc/fluidsynth-v11-devdoc.txt | 1 + include/fluidsynth/synth.h | 4 ---- src/synth/fluid_synth.c | 24 ------------------------ 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 406510d1..381c91dc 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -79,6 +79,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove deprecated fluid_synth_set_midi_router() - remove deprecated fluid_get_hinstance() and fluid_set_hinstance() (dsound driver now uses the desktop window) - remove deprecated fluid_synth_create_key_tuning(), use fluid_synth_activate_key_tuning(synth, bank, prog, name, pitch, FALSE) instead +- remove deprecated fluid_synth_create_octave_tuning(), use fluid_synth_activate_octave_tuning(synth, bank, prog, name, pitch, FALSE) instead - remove deprecated FLUID_HINT_INTEGER - remove misspelled FLUID_SEQ_PITCHWHHELSENS macro - remove obsolete "audio.[out|in]put-channels" settings diff --git a/include/fluidsynth/synth.h b/include/fluidsynth/synth.h index bdfdd634..64a9fc56 100644 --- a/include/fluidsynth/synth.h +++ b/include/fluidsynth/synth.h @@ -228,10 +228,6 @@ FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t* synth, int chan, int par FLUIDSYNTH_API int fluid_synth_activate_key_tuning(fluid_synth_t* synth, int bank, int prog, const char* name, const double* pitch, int apply); -FLUIDSYNTH_API -FLUID_DEPRECATED -int fluid_synth_create_octave_tuning(fluid_synth_t* synth, int bank, int prog, - const char* name, const double* pitch); FLUIDSYNTH_API int fluid_synth_activate_octave_tuning(fluid_synth_t* synth, int bank, int prog, const char* name, const double* pitch, int apply); diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index a27db271..86a72dd0 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -4540,30 +4540,6 @@ fluid_synth_activate_key_tuning(fluid_synth_t* synth, int bank, int prog, FLUID_API_RETURN(retval); } -/** - * Apply an octave tuning to every octave in the MIDI note scale. - * @param synth FluidSynth instance - * @param bank Tuning bank number (0-127), not related to MIDI instrument bank - * @param prog Tuning preset number (0-127), not related to MIDI instrument program - * @param name Label name for this tuning - * @param pitch Array of pitch values (length of 12 for each note of an octave - * starting at note C, values are number of offset cents to add to the normal - * tuning amount) - * @return FLUID_OK on success, FLUID_FAILED otherwise - * - * @note Tuning is not applied in realtime to existing notes of the replaced - * tuning (if any), use fluid_synth_activate_octave_tuning() instead to specify - * this behavior. - * - * @deprecated Use fluid_synth_activate_octave_tuning(synth, bank, prog, name, pitch, FALSE) instead. - */ -int -fluid_synth_create_octave_tuning(fluid_synth_t* synth, int bank, int prog, - const char* name, const double* pitch) -{ - return fluid_synth_activate_octave_tuning (synth, bank, prog, name, pitch, FALSE); -} - /** * Activate an octave tuning on every octave in the MIDI note scale. * @param synth FluidSynth instance From 70a1c82a5e0b321a7c7d9d7688a969ee968f077d Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 18:00:50 +0100 Subject: [PATCH 09/24] remove deprecated fluid_synth_select_tuning() --- doc/fluidsynth-v11-devdoc.txt | 1 + include/fluidsynth/synth.h | 3 --- src/synth/fluid_synth.c | 24 ------------------------ 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 381c91dc..7ceb0a79 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -80,6 +80,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove deprecated fluid_get_hinstance() and fluid_set_hinstance() (dsound driver now uses the desktop window) - remove deprecated fluid_synth_create_key_tuning(), use fluid_synth_activate_key_tuning(synth, bank, prog, name, pitch, FALSE) instead - remove deprecated fluid_synth_create_octave_tuning(), use fluid_synth_activate_octave_tuning(synth, bank, prog, name, pitch, FALSE) instead +- remove deprecated fluid_synth_select_tuning(), use fluid_synth_activate_tuning(synth, chan, bank, prog, FALSE) instead - remove deprecated FLUID_HINT_INTEGER - remove misspelled FLUID_SEQ_PITCHWHHELSENS macro - remove obsolete "audio.[out|in]put-channels" settings diff --git a/include/fluidsynth/synth.h b/include/fluidsynth/synth.h index 64a9fc56..c20b06f3 100644 --- a/include/fluidsynth/synth.h +++ b/include/fluidsynth/synth.h @@ -234,9 +234,6 @@ int fluid_synth_activate_octave_tuning(fluid_synth_t* synth, int bank, int prog, FLUIDSYNTH_API int fluid_synth_tune_notes(fluid_synth_t* synth, int bank, int prog, int len, const int *keys, const double* pitch, int apply); -FLUIDSYNTH_API -FLUID_DEPRECATED -int fluid_synth_select_tuning(fluid_synth_t* synth, int chan, int bank, int prog); FLUIDSYNTH_API int fluid_synth_activate_tuning(fluid_synth_t* synth, int chan, int bank, int prog, int apply); diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 86a72dd0..d48c1e10 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -4634,30 +4634,6 @@ fluid_synth_tune_notes(fluid_synth_t* synth, int bank, int prog, FLUID_API_RETURN(retval); } -/** - * Select a tuning scale on a MIDI channel. - * @param synth FluidSynth instance - * @param chan MIDI channel number (0 to MIDI channel count - 1) - * @param bank Tuning bank number (0-127), not related to MIDI instrument bank - * @param prog Tuning preset number (0-127), not related to MIDI instrument program - * @return FLUID_OK on success, FLUID_FAILED otherwise - * - * @note This function does NOT activate tuning in realtime, use - * fluid_synth_activate_tuning() instead to specify whether tuning change - * should cause existing notes to update. - * - * @note Prior to version 1.1.0 it was an error to select a tuning that didn't - * already exist. Starting with 1.1.0, a default equal tempered scale will be - * created, if no tuning exists for the given bank and prog. - * - * @deprecated Use fluid_synth_activate_tuning(synth, chan, bank, prog, FALSE) instead. - */ -int -fluid_synth_select_tuning(fluid_synth_t* synth, int chan, int bank, int prog) -{ - return fluid_synth_activate_tuning (synth, chan, bank, prog, FALSE); -} - /** * Activate a tuning scale on a MIDI channel. * @param synth FluidSynth instance From c5cdcb8eda573b2700bb2921f0532531b0c1d17f Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 18:01:19 +0100 Subject: [PATCH 10/24] remove deprecated fluid_synth_reset_tuning() --- doc/fluidsynth-v11-devdoc.txt | 1 + include/fluidsynth/synth.h | 3 --- src/synth/fluid_synth.c | 18 ------------------ 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 7ceb0a79..9c80b1b4 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -81,6 +81,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove deprecated fluid_synth_create_key_tuning(), use fluid_synth_activate_key_tuning(synth, bank, prog, name, pitch, FALSE) instead - remove deprecated fluid_synth_create_octave_tuning(), use fluid_synth_activate_octave_tuning(synth, bank, prog, name, pitch, FALSE) instead - remove deprecated fluid_synth_select_tuning(), use fluid_synth_activate_tuning(synth, chan, bank, prog, FALSE) instead +- remove deprecated fluid_synth_reset_tuning(), use fluid_synth_deactivate_tuning(synth, chan, FALSE) instead - remove deprecated FLUID_HINT_INTEGER - remove misspelled FLUID_SEQ_PITCHWHHELSENS macro - remove obsolete "audio.[out|in]put-channels" settings diff --git a/include/fluidsynth/synth.h b/include/fluidsynth/synth.h index c20b06f3..0801ea03 100644 --- a/include/fluidsynth/synth.h +++ b/include/fluidsynth/synth.h @@ -238,9 +238,6 @@ FLUIDSYNTH_API int fluid_synth_activate_tuning(fluid_synth_t* synth, int chan, int bank, int prog, int apply); FLUIDSYNTH_API -FLUID_DEPRECATED -int fluid_synth_reset_tuning(fluid_synth_t* synth, int chan); -FLUIDSYNTH_API int fluid_synth_deactivate_tuning(fluid_synth_t* synth, int chan, int apply); FLUIDSYNTH_API void fluid_synth_tuning_iteration_start(fluid_synth_t* synth); FLUIDSYNTH_API diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index d48c1e10..ec5cbb32 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -4709,24 +4709,6 @@ fluid_synth_set_tuning_LOCAL (fluid_synth_t *synth, int chan, return FLUID_OK; } -/** - * Clear tuning scale on a MIDI channel (set it to the default equal tempered scale). - * @param synth FluidSynth instance - * @param chan MIDI channel number (0 to MIDI channel count - 1) - * @return FLUID_OK on success, FLUID_FAILED otherwise - * - * @note This function does NOT activate tuning change in realtime, use - * fluid_synth_deactivate_tuning() instead to specify whether tuning change - * should cause existing notes to update. - * - * @deprecated Use fluid_synth_deactivate_tuning(synth, chan, FALSE) instead. - */ -int -fluid_synth_reset_tuning(fluid_synth_t* synth, int chan) -{ - return fluid_synth_deactivate_tuning (synth, chan, FALSE); -} - /** * Clear tuning scale on a MIDI channel (use default equal tempered scale). * @param synth FluidSynth instance From 73806d653c1c779e53156ce77f1bd6b8053801fe Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 18:04:21 +0100 Subject: [PATCH 11/24] remove orphaned fluid_synth_set_midi_router() decl. --- include/fluidsynth/synth.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/fluidsynth/synth.h b/include/fluidsynth/synth.h index 0801ea03..79b723ae 100644 --- a/include/fluidsynth/synth.h +++ b/include/fluidsynth/synth.h @@ -310,9 +310,6 @@ FLUIDSYNTH_API void fluid_synth_start_voice(fluid_synth_t* synth, fluid_voice_t* FLUIDSYNTH_API void fluid_synth_get_voicelist(fluid_synth_t* synth, fluid_voice_t* buf[], int bufsize, int ID); FLUIDSYNTH_API int fluid_synth_handle_midi_event(void* data, fluid_midi_event_t* event); -FLUIDSYNTH_API -FLUID_DEPRECATED -void fluid_synth_set_midi_router(fluid_synth_t* synth, fluid_midi_router_t* router); /* LADSPA */ From 5bc1f57ec55f333ecb4e1ef4bab5691909715056 Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 27 Nov 2017 18:30:20 +0100 Subject: [PATCH 12/24] mention ladspa functions in API docs --- doc/fluidsynth-v11-devdoc.txt | 1 + include/fluidsynth/ladspa.h | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 9c80b1b4..67db74e4 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -106,6 +106,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - add individual chorus setters: fluid_synth_set_chorus_nr(), fluid_synth_set_chorus_level(), fluid_synth_set_chorus_speed(), fluid_synth_set_chorus_depth(), fluid_synth_set_chorus_type() - introduce a separate data type for sequencer client IDs: #fluid_seq_id_t - add file callback struct to _fluid_sfloader_t and expose new_fluid_defsfloader() to enable soundfont loading from memory ( see fluid_sfload_mem.c ) +- expose functions to manipulate the ladspa effects unit (see ladspa.h) \section NewIn1_1_9 Whats new in 1.1.9? diff --git a/include/fluidsynth/ladspa.h b/include/fluidsynth/ladspa.h index 539a84d1..f12bb33e 100644 --- a/include/fluidsynth/ladspa.h +++ b/include/fluidsynth/ladspa.h @@ -25,6 +25,17 @@ extern "C" { #endif +/** + * @file ladspa.h + * @brief Functions for manipulating the ladspa effects unit + * + * This header defines useful functions for programatically manipulating the ladspa + * effects unit of the synth that can be retrieved via fluid_synth_get_ladspa_fx(). + * + * Using any of those functions requires fluidsynth to be compiled with ladspa support. + * Else all of those functions are useless dummies. + */ + FLUIDSYNTH_API int fluid_ladspa_is_active(fluid_ladspa_fx_t *fx); FLUIDSYNTH_API int fluid_ladspa_activate(fluid_ladspa_fx_t *fx); FLUIDSYNTH_API int fluid_ladspa_deactivate(fluid_ladspa_fx_t *fx); From 01040409ba96014f054b0c182213654a0a07ac67 Mon Sep 17 00:00:00 2001 From: derselbst Date: Thu, 30 Nov 2017 12:55:20 +0100 Subject: [PATCH 13/24] exclude private headers from public API doc generation --- doc/Doxyfile | 2 +- doc/Doxyfile.cmake | 2 +- doc/fluidsynth-v11-devdoc.txt | 2 +- src/midi/fluid_midi.h | 2 +- src/rvoice/fluid_rvoice.h | 8 ++++---- src/rvoice/fluid_rvoice_event.h | 2 +- src/synth/fluid_gen.h | 4 ++-- src/synth/fluid_mod.h | 2 +- src/synth/fluid_synth.h | 2 +- src/utils/fluid_ringbuffer.h | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/doc/Doxyfile b/doc/Doxyfile index 50ab1d9e..b8f5c5a6 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -88,7 +88,7 @@ FILE_PATTERNS = *.c *.h RECURSIVE = YES EXCLUDE = EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = fluid_*.h EXCLUDE_SYMBOLS = EXAMPLE_PATH = ../doc EXAMPLE_PATTERNS = *.c diff --git a/doc/Doxyfile.cmake b/doc/Doxyfile.cmake index 78a6df74..c5237ec6 100644 --- a/doc/Doxyfile.cmake +++ b/doc/Doxyfile.cmake @@ -88,7 +88,7 @@ FILE_PATTERNS = *.c *.h RECURSIVE = YES EXCLUDE = EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = fluid_*.h EXCLUDE_SYMBOLS = EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/doc EXAMPLE_PATTERNS = *.c diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 67db74e4..be76bb71 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -87,7 +87,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove obsolete "audio.[out|in]put-channels" settings - remove unimplemented "synth.dump" setting - remove fluid_synth_set_gen2(), fluid_synth_set_gen() now behaves as fluid_synth_set_gen2() -- remove struct fluid_mod_t from public API, use the getters and setters of mod.h instead +- remove struct _fluid_mod_t from public API, use the getters and setters of mod.h instead - remove struct _fluid_gen_t, fluid_gen_set_default_values() and enum fluid_gen_flags from public API - remove macros fluid_sfont_get_id() and fluid_sample_refcount() from public API

diff --git a/src/midi/fluid_midi.h b/src/midi/fluid_midi.h index dd4ed6ed..171be623 100644 --- a/src/midi/fluid_midi.h +++ b/src/midi/fluid_midi.h @@ -263,7 +263,7 @@ int fluid_track_send_events(fluid_track_t* track, #define fluid_track_eot(track) ((track)->cur == NULL) -/** +/* * fluid_playlist_item * Used as the `data' elements of the fluid_player.playlist. * Represents either a filename or a pre-loaded memory buffer. diff --git a/src/rvoice/fluid_rvoice.h b/src/rvoice/fluid_rvoice.h index 44cd97dc..2b6cba0d 100644 --- a/src/rvoice/fluid_rvoice.h +++ b/src/rvoice/fluid_rvoice.h @@ -48,7 +48,7 @@ enum fluid_loop { FLUID_LOOP_UNTIL_RELEASE = 3 }; -/** +/* * rvoice ticks-based parameters * These parameters must be updated even if the voice is currently quiet. */ @@ -77,7 +77,7 @@ struct _fluid_rvoice_envlfo_t fluid_real_t viblfo_to_pitch; }; -/** +/* * rvoice parameters needed for dsp interpolation */ struct _fluid_rvoice_dsp_t @@ -129,7 +129,7 @@ struct _fluid_rvoice_dsp_t ever add surround positioning, or stereo reverb/chorus */ #define FLUID_RVOICE_MAX_BUFS (4) -/** +/* * rvoice mixer-related parameters */ struct _fluid_rvoice_buffers_t @@ -142,7 +142,7 @@ struct _fluid_rvoice_buffers_t }; -/** +/* * Hard real-time parameters needed to synthesize a voice */ struct _fluid_rvoice_t diff --git a/src/rvoice/fluid_rvoice_event.h b/src/rvoice/fluid_rvoice_event.h index 19bd7c5b..eb450ecf 100644 --- a/src/rvoice/fluid_rvoice_event.h +++ b/src/rvoice/fluid_rvoice_event.h @@ -42,7 +42,7 @@ struct _fluid_rvoice_event_t { void fluid_rvoice_event_dispatch(fluid_rvoice_event_t* event); -/** +/* * Bridge between the renderer thread and the midi state thread. * If is_threadsafe is true, that means fluid_rvoice_eventhandler_fetch_all * can be called in parallell with fluid_rvoice_eventhandler_push/flush diff --git a/src/synth/fluid_gen.h b/src/synth/fluid_gen.h index 4c01e1be..aa930672 100644 --- a/src/synth/fluid_gen.h +++ b/src/synth/fluid_gen.h @@ -33,7 +33,7 @@ typedef struct _fluid_gen_info_t { float def; /* The default value (cfr. fluid_gen_set_default_values()) */ } fluid_gen_info_t; -/** +/* * SoundFont generator structure. */ typedef struct _fluid_gen_t @@ -44,7 +44,7 @@ typedef struct _fluid_gen_t double nrpn; /**< Change by NRPN messages */ } fluid_gen_t; -/** +/* * Enum value for 'flags' field of #fluid_gen_t (not really flags). */ enum fluid_gen_flags diff --git a/src/synth/fluid_mod.h b/src/synth/fluid_mod.h index d34576da..7018a9e3 100644 --- a/src/synth/fluid_mod.h +++ b/src/synth/fluid_mod.h @@ -24,7 +24,7 @@ #include "fluidsynth_priv.h" #include "fluid_conv.h" -/** +/* * Modulator structure. See SoundFont 2.04 PDF section 8.2. */ struct _fluid_mod_t diff --git a/src/synth/fluid_synth.h b/src/synth/fluid_synth.h index 6f8d0c63..0d02ac5d 100644 --- a/src/synth/fluid_synth.h +++ b/src/synth/fluid_synth.h @@ -78,7 +78,7 @@ enum fluid_synth_status #define SYNTH_REVERB_CHANNEL 0 #define SYNTH_CHORUS_CHANNEL 1 -/** +/* * Structure used for sfont_info field in #fluid_synth_t for each loaded * SoundFont with the SoundFont instance and additional fields. */ diff --git a/src/utils/fluid_ringbuffer.h b/src/utils/fluid_ringbuffer.h index eff598e4..5335ca3a 100644 --- a/src/utils/fluid_ringbuffer.h +++ b/src/utils/fluid_ringbuffer.h @@ -23,7 +23,7 @@ #include "fluid_sys.h" -/** +/* * Lockless event queue instance. */ struct _fluid_ringbuffer_t From cde8517c5aa71c2cd2a02358c45237e398a1f7e1 Mon Sep 17 00:00:00 2001 From: derselbst Date: Thu, 30 Nov 2017 13:01:16 +0100 Subject: [PATCH 14/24] make sure doxygen generates ladspa-related docs --- doc/Doxyfile | 2 +- doc/Doxyfile.cmake | 2 +- src/bindings/fluid_ladspa.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/Doxyfile b/doc/Doxyfile index b8f5c5a6..3cb8f044 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -200,7 +200,7 @@ EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = -PREDEFINED = +PREDEFINED = __DOXYGEN__ EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- diff --git a/doc/Doxyfile.cmake b/doc/Doxyfile.cmake index c5237ec6..fe1a0035 100644 --- a/doc/Doxyfile.cmake +++ b/doc/Doxyfile.cmake @@ -200,7 +200,7 @@ EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = -PREDEFINED = +PREDEFINED = __DOXYGEN__ EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- diff --git a/src/bindings/fluid_ladspa.c b/src/bindings/fluid_ladspa.c index d31ec968..c7faa2c7 100644 --- a/src/bindings/fluid_ladspa.c +++ b/src/bindings/fluid_ladspa.c @@ -27,7 +27,7 @@ #include "fluid_ladspa.h" -#ifdef LADSPA +#if defined(LADSPA) || defined(__DOXYGEN__) #include #include From 68d812ae3043175a80a8a33b5ebce322d659e413 Mon Sep 17 00:00:00 2001 From: derselbst Date: Thu, 30 Nov 2017 13:18:38 +0100 Subject: [PATCH 15/24] remove *_LAST enum values from public API doc addresses #186 --- include/fluidsynth/event.h | 4 +++- include/fluidsynth/gen.h | 4 +++- include/fluidsynth/log.h | 4 +++- include/fluidsynth/midi.h | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/fluidsynth/event.h b/include/fluidsynth/event.h index dde0bb23..374bdb53 100644 --- a/include/fluidsynth/event.h +++ b/include/fluidsynth/event.h @@ -59,7 +59,9 @@ enum fluid_seq_event_type { FLUID_SEQ_KEYPRESSURE, /**< Polyphonic aftertouch event @since 2.0.0 */ FLUID_SEQ_SYSTEMRESET, /**< System reset event @since 1.1.0 */ FLUID_SEQ_UNREGISTERING, /**< Called when a sequencer client is being unregistered. @since 1.1.0 */ - FLUID_SEQ_LASTEVENT /**< Defines the count of event enums @deprecated As of 1.1.7 this enum value is deprecated and will be removed in a future release, because it prevents adding new enum values without breaking ABI compatibility. */ +#ifndef __DOXYGEN__ + FLUID_SEQ_LASTEVENT /**< @internal Defines the count of events enums @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */ +#endif }; /* Event alloc/free */ diff --git a/include/fluidsynth/gen.h b/include/fluidsynth/gen.h index fa25414d..d4700073 100644 --- a/include/fluidsynth/gen.h +++ b/include/fluidsynth/gen.h @@ -99,7 +99,9 @@ enum fluid_gen_type { * is used, however, as the destination for the default pitch wheel * modulator. */ GEN_PITCH, /**< Pitch @note Not a real SoundFont generator */ - GEN_LAST /**< Value defines the count of generators (#fluid_gen_type) @deprecated As of 1.1.7 this enum value is deprecated and will be removed in a future release, because it prevents adding new enum values without breaking ABI compatibility. */ +#ifndef __DOXYGEN__ + GEN_LAST /**< @internal Value defines the count of generators (#fluid_gen_type) @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */ +#endif }; diff --git a/include/fluidsynth/log.h b/include/fluidsynth/log.h index cd9f4041..61bbef21 100644 --- a/include/fluidsynth/log.h +++ b/include/fluidsynth/log.h @@ -58,7 +58,9 @@ enum fluid_log_level { FLUID_WARN, /**< Warning */ FLUID_INFO, /**< Verbose informational messages */ FLUID_DBG, /**< Debugging messages */ - LAST_LOG_LEVEL /**< @deprecated As of 1.1.7 this enum value is deprecated and will be removed in a future release, because it prevents adding new enum values without breaking ABI compatibility. */ +#ifndef __DOXYGEN__ + LAST_LOG_LEVEL /**< @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */ +#endif }; /** diff --git a/include/fluidsynth/midi.h b/include/fluidsynth/midi.h index 03a34776..9be82128 100644 --- a/include/fluidsynth/midi.h +++ b/include/fluidsynth/midi.h @@ -64,7 +64,9 @@ typedef enum FLUID_MIDI_ROUTER_RULE_PITCH_BEND, /**< MIDI pitch bend rule */ FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE, /**< MIDI channel pressure rule */ FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE, /**< MIDI key pressure rule */ - FLUID_MIDI_ROUTER_RULE_COUNT /**< Total count of rule types */ +#ifndef __DOXYGEN__ + FLUID_MIDI_ROUTER_RULE_COUNT /**< @internal Total count of rule types @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time!*/ +#endif } fluid_midi_router_rule_type; /** From c7675a8269c51f34ff628e72ef627a9c9275b4a3 Mon Sep 17 00:00:00 2001 From: derselbst Date: Thu, 30 Nov 2017 13:25:40 +0100 Subject: [PATCH 16/24] bump version to 2.0 --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68a27f5b..1b811256 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,9 @@ set ( CMAKE_EXPORT_COMPILE_COMMANDS 1 ) set ( PACKAGE "fluidsynth" ) # FluidSynth package version -set ( FLUIDSYNTH_VERSION_MAJOR 1 ) -set ( FLUIDSYNTH_VERSION_MINOR 1 ) -set ( FLUIDSYNTH_VERSION_MICRO 8 ) +set ( FLUIDSYNTH_VERSION_MAJOR 2 ) +set ( FLUIDSYNTH_VERSION_MINOR 0 ) +set ( FLUIDSYNTH_VERSION_MICRO 0 ) set ( VERSION "${FLUIDSYNTH_VERSION_MAJOR}.${FLUIDSYNTH_VERSION_MINOR}.${FLUIDSYNTH_VERSION_MICRO}" ) set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" ) @@ -43,9 +43,9 @@ set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" ) # if any interfaces have been added: AGE++ # if any interfaces have been removed/changed (compatibility broken): AGE=0 # This is not exactly the same algorithm as the libtool one, but the results are the same. -set ( LIB_VERSION_CURRENT 1 ) -set ( LIB_VERSION_AGE 6 ) -set ( LIB_VERSION_REVISION 1 ) +set ( LIB_VERSION_CURRENT 2 ) +set ( LIB_VERSION_AGE 0 ) +set ( LIB_VERSION_REVISION 0 ) set ( LIB_VERSION_INFO "${LIB_VERSION_CURRENT}.${LIB_VERSION_AGE}.${LIB_VERSION_REVISION}" ) From 35f679d16d7e37743b43c2aae20a34de2342d098 Mon Sep 17 00:00:00 2001 From: derselbst Date: Thu, 30 Nov 2017 13:34:33 +0100 Subject: [PATCH 17/24] mention removed enum vals in API doc --- doc/fluidsynth-v11-devdoc.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index be76bb71..469c6fb4 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -90,6 +90,11 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove struct _fluid_mod_t from public API, use the getters and setters of mod.h instead - remove struct _fluid_gen_t, fluid_gen_set_default_values() and enum fluid_gen_flags from public API - remove macros fluid_sfont_get_id() and fluid_sample_refcount() from public API +- remove the following deprecated enum values: + - GEN_LAST + - LAST_LOG_LEVEL + - FLUID_SEQ_LASTEVENT + - FLUID_MIDI_ROUTER_RULE_COUNT

- all public \c fluid_settings_* functions that return an integer which is not meant to be interpreted as bool consistently return either FLUID_OK or FLUID_FAILED - all public delete_* functions return void and are safe when called with NULL @@ -100,7 +105,7 @@ Changes in FluidSynth 2.0.0 concerning developers:

- add "synth.volenv" a setting for volume envelope processing - add "midi.autoconnect" a setting for automatically connecting fluidsynth to available MIDI input ports -- add support for polyonic key pressure events, see fluid_event_key_pressure() +- add support for polyphonic key pressure events, see fluid_event_key_pressure() - add fluid_synth_add_default_mod() and fluid_synth_remove_default_mod() for manipulating default modulators - add individual reverb setters: fluid_synth_set_reverb_roomsize(), fluid_synth_set_reverb_damp(), fluid_synth_set_reverb_width(), fluid_synth_set_reverb_level() - add individual chorus setters: fluid_synth_set_chorus_nr(), fluid_synth_set_chorus_level(), fluid_synth_set_chorus_speed(), fluid_synth_set_chorus_depth(), fluid_synth_set_chorus_type() From 0f737708c724d3f632cd5dab32eabf293fb45283 Mon Sep 17 00:00:00 2001 From: derselbst Date: Sat, 2 Dec 2017 18:25:58 +0100 Subject: [PATCH 18/24] optimize fluid_voice_t in size --- src/synth/fluid_voice.c | 2 ++ src/synth/fluid_voice.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/synth/fluid_voice.c b/src/synth/fluid_voice.c index 214d006c..f9423fc7 100644 --- a/src/synth/fluid_voice.c +++ b/src/synth/fluid_voice.c @@ -420,7 +420,9 @@ void fluid_voice_start(fluid_voice_t* voice) fluid_voice_calculate_runtime_synthesis_parameters(voice); +#ifdef WITH_PROFILING voice->ref = fluid_profile_ref(); +#endif voice->status = FLUID_VOICE_ON; diff --git a/src/synth/fluid_voice.h b/src/synth/fluid_voice.h index 4103f08d..4975e855 100644 --- a/src/synth/fluid_voice.h +++ b/src/synth/fluid_voice.h @@ -105,8 +105,10 @@ struct _fluid_voice_t char can_access_overflow_rvoice; /* False if overflow_rvoice is being rendered in separate thread */ char has_noteoff; /* Flag set when noteoff has been sent */ +#ifdef WITH_PROFILING /* for debugging */ double ref; +#endif }; From 6e59d3bca978232108caa1b4af91d6c74cb3e53f Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 3 Dec 2017 16:24:10 +0100 Subject: [PATCH 19/24] use fluid_voice_gen_value() rather than _GEN macro --- src/synth/fluid_synth.c | 2 +- src/synth/fluid_voice.c | 84 ++++++++++++++++++++--------------------- src/synth/fluid_voice.h | 5 --- 3 files changed, 43 insertions(+), 48 deletions(-) diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index c8bd20f9..2fe50dca 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -3296,7 +3296,7 @@ static void fluid_synth_kill_by_exclusive_class_LOCAL(fluid_synth_t* synth, fluid_voice_t* new_voice) { - int excl_class = _GEN(new_voice,GEN_EXCLUSIVECLASS); + int excl_class = fluid_voice_gen_value(new_voice,GEN_EXCLUSIVECLASS); fluid_voice_t* existing_voice; int i; diff --git a/src/synth/fluid_voice.c b/src/synth/fluid_voice.c index f9423fc7..e231d63c 100644 --- a/src/synth/fluid_voice.c +++ b/src/synth/fluid_voice.c @@ -440,7 +440,7 @@ fluid_voice_calculate_gen_pitch(fluid_voice_t* voice) * modulator paradigm. Now the nominal pitch of the key is set. * Note about SCALETUNE: SF2.01 8.1.3 says, that this generator is a * non-realtime parameter. So we don't allow modulation (as opposed - * to _GEN(voice, GEN_SCALETUNE) When the scale tuning is varied, + * to fluid_voice_gen_value(voice, GEN_SCALETUNE) When the scale tuning is varied, * one key remains fixed. Here C3 (MIDI number 60) is used. */ if (fluid_channel_has_tuning(voice->channel)) { @@ -603,7 +603,7 @@ calculate_hold_decay_buffers(fluid_voice_t* voice, int gen_base, * will cause (60-72)*100=-1200 timecents of time variation. * The time is cut in half. */ - timecents = (_GEN(voice, gen_base) + _GEN(voice, gen_key2base) * (60.0 - fluid_voice_get_actual_key(voice))); + timecents = (fluid_voice_gen_value(voice, gen_base) + fluid_voice_gen_value(voice, gen_key2base) * (60.0 - fluid_voice_get_actual_key(voice))); /* Range checking */ if (is_decay){ @@ -651,7 +651,7 @@ calculate_hold_decay_buffers(fluid_voice_t* voice, int gen_base, * * Note: The generator holds three values: The base value .val, an * offset caused by modulators .mod, and an offset caused by the - * NRPN system. _GEN(voice, generator_enumerator) returns the sum + * NRPN system. fluid_voice_gen_value(voice, generator_enumerator) returns the sum * of all three. */ /** @@ -676,7 +676,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_PAN: /* range checking is done in the fluid_pan function */ - voice->pan = _GEN(voice, GEN_PAN); + voice->pan = fluid_voice_gen_value(voice, GEN_PAN); voice->amp_left = fluid_pan(voice->pan, 1) * voice->synth_gain / 32768.0f; voice->amp_right = fluid_pan(voice->pan, 0) * voice->synth_gain / 32768.0f; UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, voice->amp_left); @@ -701,15 +701,15 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_COARSETUNE: case GEN_FINETUNE: /* The testing for allowed range is done in 'fluid_ct2hz' */ - voice->pitch = (_GEN(voice, GEN_PITCH) - + 100.0f * _GEN(voice, GEN_COARSETUNE) - + _GEN(voice, GEN_FINETUNE)); + voice->pitch = (fluid_voice_gen_value(voice, GEN_PITCH) + + 100.0f * fluid_voice_gen_value(voice, GEN_COARSETUNE) + + fluid_voice_gen_value(voice, GEN_FINETUNE)); UPDATE_RVOICE_R1(fluid_rvoice_set_pitch, voice->pitch); break; case GEN_REVERBSEND: /* The generator unit is 'tenths of a percent'. */ - voice->reverb_send = _GEN(voice, GEN_REVERBSEND) / 1000.0f; + voice->reverb_send = fluid_voice_gen_value(voice, GEN_REVERBSEND) / 1000.0f; fluid_clip(voice->reverb_send, 0.0, 1.0); voice->amp_reverb = voice->reverb_send * voice->synth_gain / 32768.0f; UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, voice->amp_reverb); @@ -717,7 +717,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_CHORUSSEND: /* The generator unit is 'tenths of a percent'. */ - voice->chorus_send = _GEN(voice, GEN_CHORUSSEND) / 1000.0f; + voice->chorus_send = fluid_voice_gen_value(voice, GEN_CHORUSSEND) / 1000.0f; fluid_clip(voice->chorus_send, 0.0, 1.0); voice->amp_chorus = voice->chorus_send * voice->synth_gain / 32768.0f; UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, voice->amp_chorus); @@ -756,14 +756,14 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) * modulation. The allowed range is tested in the 'fluid_ct2hz' * function [PH,20021214] */ - x = _GEN(voice, GEN_FILTERFC); + x = fluid_voice_gen_value(voice, GEN_FILTERFC); UPDATE_RVOICE_FILTER1(fluid_iir_filter_set_fres, x); break; case GEN_FILTERQ: /* The generator contains 'centibels' (1/10 dB) => divide by 10 to * obtain dB */ - q_dB = _GEN(voice, GEN_FILTERQ) / 10.0f; + q_dB = fluid_voice_gen_value(voice, GEN_FILTERQ) / 10.0f; /* Range: SF2.01 section 8.1.3 # 8 (convert from cB to dB => /10) */ fluid_clip(q_dB, 0.0f, 96.0f); @@ -789,25 +789,25 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) break; case GEN_MODLFOTOPITCH: - x = _GEN(voice, GEN_MODLFOTOPITCH); + x = fluid_voice_gen_value(voice, GEN_MODLFOTOPITCH); fluid_clip(x, -12000.0, 12000.0); UPDATE_RVOICE_R1(fluid_rvoice_set_modlfo_to_pitch, x); break; case GEN_MODLFOTOVOL: - x = _GEN(voice, GEN_MODLFOTOVOL); + x = fluid_voice_gen_value(voice, GEN_MODLFOTOVOL); fluid_clip(x, -960.0, 960.0); UPDATE_RVOICE_R1(fluid_rvoice_set_modlfo_to_vol, x); break; case GEN_MODLFOTOFILTERFC: - x = _GEN(voice, GEN_MODLFOTOFILTERFC); + x = fluid_voice_gen_value(voice, GEN_MODLFOTOFILTERFC); fluid_clip(x, -12000, 12000); UPDATE_RVOICE_R1(fluid_rvoice_set_modlfo_to_fc, x); break; case GEN_MODLFODELAY: - x = _GEN(voice, GEN_MODLFODELAY); + x = fluid_voice_gen_value(voice, GEN_MODLFODELAY); fluid_clip(x, -12000.0f, 5000.0f); z = (unsigned int) (voice->output_rate * fluid_tc2sec_delay(x)); UPDATE_RVOICE_ENVLFO_I1(fluid_lfo_set_delay, modlfo, z); @@ -817,7 +817,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) /* - the frequency is converted into a delta value, per buffer of FLUID_BUFSIZE samples * - the delay into a sample delay */ - x = _GEN(voice, GEN_MODLFOFREQ); + x = fluid_voice_gen_value(voice, GEN_MODLFOFREQ); fluid_clip(x, -16000.0f, 4500.0f); x = (4.0f * FLUID_BUFSIZE * fluid_act2hz(x) / voice->output_rate); UPDATE_RVOICE_ENVLFO_R1(fluid_lfo_set_incr, modlfo, x); @@ -829,21 +829,21 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) * - the frequency is converted into a delta value, per buffer of FLUID_BUFSIZE samples * - the delay into a sample delay */ - x = _GEN(voice, GEN_VIBLFOFREQ); + x = fluid_voice_gen_value(voice, GEN_VIBLFOFREQ); fluid_clip(x, -16000.0f, 4500.0f); x = 4.0f * FLUID_BUFSIZE * fluid_act2hz(x) / voice->output_rate; UPDATE_RVOICE_ENVLFO_R1(fluid_lfo_set_incr, viblfo, x); break; case GEN_VIBLFODELAY: - x = _GEN(voice,GEN_VIBLFODELAY); + x = fluid_voice_gen_value(voice,GEN_VIBLFODELAY); fluid_clip(x, -12000.0f, 5000.0f); z = (unsigned int) (voice->output_rate * fluid_tc2sec_delay(x)); UPDATE_RVOICE_ENVLFO_I1(fluid_lfo_set_delay, viblfo, z); break; case GEN_VIBLFOTOPITCH: - x = _GEN(voice, GEN_VIBLFOTOPITCH); + x = fluid_voice_gen_value(voice, GEN_VIBLFOTOPITCH); fluid_clip(x, -12000.0, 12000.0); UPDATE_RVOICE_R1(fluid_rvoice_set_viblfo_to_pitch, x); break; @@ -862,7 +862,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) * never be released on a noteoff event */ #if 0 - x = _GEN(voice, GEN_KEYNUM); + x = fluid_voice_gen_value(voice, GEN_KEYNUM); if (x >= 0){ voice->key = x; } @@ -878,12 +878,12 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) * There is a flag, which should indicate, whether a generator is * enabled or not. But here we rely on the default value of -1. */ - /* 2017-09-02: do not change the voice's velocity here, user + /* 2017-09-02: do not change the voice's velocity here, use * fluid_voice_get_actual_velocity() to get the value of this generator * if active. */ #if 0 - x = _GEN(voice, GEN_VELOCITY); + x = fluid_voice_gen_value(voice, GEN_VELOCITY); if (x > 0) { voice->vel = x; } @@ -891,13 +891,13 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) break; case GEN_MODENVTOPITCH: - x = _GEN(voice, GEN_MODENVTOPITCH); + x = fluid_voice_gen_value(voice, GEN_MODENVTOPITCH); fluid_clip(x, -12000.0, 12000.0); UPDATE_RVOICE_R1(fluid_rvoice_set_modenv_to_pitch, x); break; case GEN_MODENVTOFILTERFC: - x = _GEN(voice,GEN_MODENVTOFILTERFC); + x = fluid_voice_gen_value(voice,GEN_MODENVTOFILTERFC); /* Range: SF2.01 section 8.1.3 # 1 * Motivation for range checking: @@ -923,8 +923,8 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_STARTADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 4 */ if (voice->sample != NULL) { z = (voice->sample->start - + (int) _GEN(voice, GEN_STARTADDROFS) - + 32768 * (int) _GEN(voice, GEN_STARTADDRCOARSEOFS)); + + (int) fluid_voice_gen_value(voice, GEN_STARTADDROFS) + + 32768 * (int) fluid_voice_gen_value(voice, GEN_STARTADDRCOARSEOFS)); UPDATE_RVOICE_I1(fluid_rvoice_set_start, z); } break; @@ -932,8 +932,8 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_ENDADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 12 */ if (voice->sample != NULL) { z = (voice->sample->end - + (int) _GEN(voice, GEN_ENDADDROFS) - + 32768 * (int) _GEN(voice, GEN_ENDADDRCOARSEOFS)); + + (int) fluid_voice_gen_value(voice, GEN_ENDADDROFS) + + 32768 * (int) fluid_voice_gen_value(voice, GEN_ENDADDRCOARSEOFS)); UPDATE_RVOICE_I1(fluid_rvoice_set_end, z); } break; @@ -941,8 +941,8 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_STARTLOOPADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 45 */ if (voice->sample != NULL) { z = (voice->sample->loopstart - + (int) _GEN(voice, GEN_STARTLOOPADDROFS) - + 32768 * (int) _GEN(voice, GEN_STARTLOOPADDRCOARSEOFS)); + + (int) fluid_voice_gen_value(voice, GEN_STARTLOOPADDROFS) + + 32768 * (int) fluid_voice_gen_value(voice, GEN_STARTLOOPADDRCOARSEOFS)); UPDATE_RVOICE_I1(fluid_rvoice_set_loopstart, z); } break; @@ -951,8 +951,8 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_ENDLOOPADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 50 */ if (voice->sample != NULL) { z = (voice->sample->loopend - + (int) _GEN(voice, GEN_ENDLOOPADDROFS) - + 32768 * (int) _GEN(voice, GEN_ENDLOOPADDRCOARSEOFS)); + + (int) fluid_voice_gen_value(voice, GEN_ENDLOOPADDROFS) + + 32768 * (int) fluid_voice_gen_value(voice, GEN_ENDLOOPADDRCOARSEOFS)); UPDATE_RVOICE_I1(fluid_rvoice_set_loopend, z); } break; @@ -969,7 +969,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) * - attack, decay and release are converted to their increment per sample */ case GEN_VOLENVDELAY: /* SF2.01 section 8.1.3 # 33 */ - x = _GEN(voice, GEN_VOLENVDELAY); + x = fluid_voice_gen_value(voice, GEN_VOLENVDELAY); fluid_clip(x, -12000.0f, 5000.0f); count = NUM_BUFFERS_DELAY(x); fluid_voice_update_volenv(voice, FLUID_VOICE_ENVDELAY, @@ -977,7 +977,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) break; case GEN_VOLENVATTACK: /* SF2.01 section 8.1.3 # 34 */ - x = _GEN(voice, GEN_VOLENVATTACK); + x = fluid_voice_gen_value(voice, GEN_VOLENVATTACK); fluid_clip(x, -12000.0f, 8000.0f); count = 1 + NUM_BUFFERS_ATTACK(x); fluid_voice_update_volenv(voice, FLUID_VOICE_ENVATTACK, @@ -994,7 +994,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_VOLENVDECAY: /* SF2.01 section 8.1.3 # 36 */ case GEN_VOLENVSUSTAIN: /* SF2.01 section 8.1.3 # 37 */ case GEN_KEYTOVOLENVDECAY: /* SF2.01 section 8.1.3 # 40 */ - y = 1.0f - 0.001f * _GEN(voice, GEN_VOLENVSUSTAIN); + y = 1.0f - 0.001f * fluid_voice_gen_value(voice, GEN_VOLENVSUSTAIN); fluid_clip(y, 0.0f, 1.0f); count = calculate_hold_decay_buffers(voice, GEN_VOLENVDECAY, GEN_KEYTOVOLENVDECAY, 1); /* 1 for decay */ fluid_voice_update_volenv(voice, FLUID_VOICE_ENVDECAY, @@ -1002,7 +1002,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) break; case GEN_VOLENVRELEASE: /* SF2.01 section 8.1.3 # 38 */ - x = _GEN(voice, GEN_VOLENVRELEASE); + x = fluid_voice_gen_value(voice, GEN_VOLENVRELEASE); fluid_clip(x, FLUID_MIN_VOLENVRELEASE, 8000.0f); count = 1 + NUM_BUFFERS_RELEASE(x); fluid_voice_update_volenv(voice, FLUID_VOICE_ENVRELEASE, @@ -1011,14 +1011,14 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) /* Modulation envelope */ case GEN_MODENVDELAY: /* SF2.01 section 8.1.3 # 25 */ - x = _GEN(voice, GEN_MODENVDELAY); + x = fluid_voice_gen_value(voice, GEN_MODENVDELAY); fluid_clip(x, -12000.0f, 5000.0f); fluid_voice_update_modenv(voice, FLUID_VOICE_ENVDELAY, NUM_BUFFERS_DELAY(x), 0.0f, 0.0f, -1.0f, 1.0f); break; case GEN_MODENVATTACK: /* SF2.01 section 8.1.3 # 26 */ - x = _GEN(voice, GEN_MODENVATTACK); + x = fluid_voice_gen_value(voice, GEN_MODENVATTACK); fluid_clip(x, -12000.0f, 8000.0f); count = 1 + NUM_BUFFERS_ATTACK(x); fluid_voice_update_modenv(voice, FLUID_VOICE_ENVATTACK, @@ -1036,14 +1036,14 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_MODENVSUSTAIN: /* SF 2.01 section 8.1.3 # 29 */ case GEN_KEYTOMODENVDECAY: /* SF 2.01 section 8.1.3 # 32 */ count = calculate_hold_decay_buffers(voice, GEN_MODENVDECAY, GEN_KEYTOMODENVDECAY, 1); /* 1 for decay */ - y = 1.0f - 0.001f * _GEN(voice, GEN_MODENVSUSTAIN); + y = 1.0f - 0.001f * fluid_voice_gen_value(voice, GEN_MODENVSUSTAIN); fluid_clip(y, 0.0f, 1.0f); fluid_voice_update_modenv(voice, FLUID_VOICE_ENVDECAY, count, 1.0f, count ? -1.0f / count : 0.0f, y, 2.0f); break; case GEN_MODENVRELEASE: /* SF 2.01 section 8.1.3 # 30 */ - x = _GEN(voice, GEN_MODENVRELEASE); + x = fluid_voice_gen_value(voice, GEN_MODENVRELEASE); fluid_clip(x, -12000.0f, 8000.0f); count = 1 + NUM_BUFFERS_RELEASE(x); fluid_voice_update_modenv(voice, FLUID_VOICE_ENVRELEASE, @@ -1454,7 +1454,7 @@ int fluid_voice_get_channel(const fluid_voice_t* voice) */ int fluid_voice_get_actual_key(const fluid_voice_t* voice) { - fluid_real_t x = _GEN(voice, GEN_KEYNUM); + fluid_real_t x = fluid_voice_gen_value(voice, GEN_KEYNUM); if (x >= 0) { return (int)x; @@ -1487,7 +1487,7 @@ int fluid_voice_get_key(const fluid_voice_t* voice) */ int fluid_voice_get_actual_velocity(const fluid_voice_t* voice) { - fluid_real_t x = _GEN(voice, GEN_VELOCITY); + fluid_real_t x = fluid_voice_gen_value(voice, GEN_VELOCITY); if (x > 0) { return (int)x; diff --git a/src/synth/fluid_voice.h b/src/synth/fluid_voice.h index 4975e855..79b00ae1 100644 --- a/src/synth/fluid_voice.h +++ b/src/synth/fluid_voice.h @@ -186,10 +186,5 @@ fluid_real_t fluid_voice_gen_value(fluid_voice_t* voice, int num); #define fluid_voice_get_loudness(voice) (fluid_adsr_env_get_max_val(&voice->volenv)) -#define _GEN(_voice, _n) \ - ((fluid_real_t)(_voice)->gen[_n].val \ - + (fluid_real_t)(_voice)->gen[_n].mod \ - + (fluid_real_t)(_voice)->gen[_n].nrpn) - #endif /* _FLUID_VOICE_H */ From d086ca8046f719ab1f944dca718b8d7cfbcaacc6 Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 3 Dec 2017 17:55:31 +0100 Subject: [PATCH 20/24] refactor fluid_voice_update_param() --- src/synth/fluid_synth.c | 8 ++-- src/synth/fluid_voice.c | 100 ++++++++++++++++++---------------------- src/synth/fluid_voice.h | 3 +- 3 files changed, 50 insertions(+), 61 deletions(-) diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 2fe50dca..0abb94d7 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -3296,8 +3296,7 @@ static void fluid_synth_kill_by_exclusive_class_LOCAL(fluid_synth_t* synth, fluid_voice_t* new_voice) { - int excl_class = fluid_voice_gen_value(new_voice,GEN_EXCLUSIVECLASS); - fluid_voice_t* existing_voice; + int excl_class = fluid_voice_gen_value(new_voice, GEN_EXCLUSIVECLASS); int i; /* Excl. class 0: No exclusive class */ @@ -3305,14 +3304,15 @@ fluid_synth_kill_by_exclusive_class_LOCAL(fluid_synth_t* synth, /* Kill all notes on the same channel with the same exclusive class */ for (i = 0; i < synth->polyphony; i++) { - existing_voice = synth->voice[i]; + fluid_voice_t* existing_voice = synth->voice[i]; + int existing_excl_class = fluid_voice_gen_value(existing_voice, GEN_EXCLUSIVECLASS); /* If voice is playing, on the same channel, has same exclusive * class and is not part of the same noteon event (voice group), then kill it */ if (fluid_voice_is_playing(existing_voice) && fluid_voice_get_channel(existing_voice) == fluid_voice_get_channel(new_voice) - && (int)_GEN (existing_voice, GEN_EXCLUSIVECLASS) == excl_class + && existing_excl_class == excl_class && fluid_voice_get_id (existing_voice) != fluid_voice_get_id(new_voice)) fluid_voice_kill_excl(existing_voice); } diff --git a/src/synth/fluid_voice.c b/src/synth/fluid_voice.c index e231d63c..982d6e7a 100644 --- a/src/synth/fluid_voice.c +++ b/src/synth/fluid_voice.c @@ -368,7 +368,7 @@ fluid_voice_gen_get(fluid_voice_t* voice, int gen) return voice->gen[gen].val; } -fluid_real_t fluid_voice_gen_value(fluid_voice_t* voice, int num) +fluid_real_t fluid_voice_gen_value(const fluid_voice_t* voice, int num) { /* This is an extension to the SoundFont standard. More * documentation is available at the fluid_synth_set_gen2() @@ -665,20 +665,20 @@ calculate_hold_decay_buffers(fluid_voice_t* voice, int gen_base, void fluid_voice_update_param(fluid_voice_t* voice, int gen) { - double q_dB; - fluid_real_t x; - 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.4f; + unsigned int count, z; + fluid_real_t q_dB; + fluid_real_t x = fluid_voice_gen_value(voice, gen); + switch (gen) { case GEN_PAN: /* range checking is done in the fluid_pan function */ - voice->pan = fluid_voice_gen_value(voice, GEN_PAN); - voice->amp_left = fluid_pan(voice->pan, 1) * voice->synth_gain / 32768.0f; - voice->amp_right = fluid_pan(voice->pan, 0) * voice->synth_gain / 32768.0f; + voice->pan = x; + voice->amp_left = fluid_pan(x, 1) * voice->synth_gain / 32768.0f; + voice->amp_right = fluid_pan(x, 0) * voice->synth_gain / 32768.0f; UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, voice->amp_left); UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 1, voice->amp_right); break; @@ -709,7 +709,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_REVERBSEND: /* The generator unit is 'tenths of a percent'. */ - voice->reverb_send = fluid_voice_gen_value(voice, GEN_REVERBSEND) / 1000.0f; + voice->reverb_send = x / 1000.0f; fluid_clip(voice->reverb_send, 0.0, 1.0); voice->amp_reverb = voice->reverb_send * voice->synth_gain / 32768.0f; UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, voice->amp_reverb); @@ -717,7 +717,7 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_CHORUSSEND: /* The generator unit is 'tenths of a percent'. */ - voice->chorus_send = fluid_voice_gen_value(voice, GEN_CHORUSSEND) / 1000.0f; + voice->chorus_send = x / 1000.0f; fluid_clip(voice->chorus_send, 0.0, 1.0); voice->amp_chorus = voice->chorus_send * voice->synth_gain / 32768.0f; UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, voice->amp_chorus); @@ -756,14 +756,13 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) * modulation. The allowed range is tested in the 'fluid_ct2hz' * function [PH,20021214] */ - x = fluid_voice_gen_value(voice, GEN_FILTERFC); UPDATE_RVOICE_FILTER1(fluid_iir_filter_set_fres, x); break; case GEN_FILTERQ: /* The generator contains 'centibels' (1/10 dB) => divide by 10 to * obtain dB */ - q_dB = fluid_voice_gen_value(voice, GEN_FILTERQ) / 10.0f; + q_dB = x / 10.0f; /* Range: SF2.01 section 8.1.3 # 8 (convert from cB to dB => /10) */ fluid_clip(q_dB, 0.0f, 96.0f); @@ -789,25 +788,21 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) break; case GEN_MODLFOTOPITCH: - x = fluid_voice_gen_value(voice, GEN_MODLFOTOPITCH); fluid_clip(x, -12000.0, 12000.0); UPDATE_RVOICE_R1(fluid_rvoice_set_modlfo_to_pitch, x); break; case GEN_MODLFOTOVOL: - x = fluid_voice_gen_value(voice, GEN_MODLFOTOVOL); fluid_clip(x, -960.0, 960.0); UPDATE_RVOICE_R1(fluid_rvoice_set_modlfo_to_vol, x); break; case GEN_MODLFOTOFILTERFC: - x = fluid_voice_gen_value(voice, GEN_MODLFOTOFILTERFC); fluid_clip(x, -12000, 12000); UPDATE_RVOICE_R1(fluid_rvoice_set_modlfo_to_fc, x); break; case GEN_MODLFODELAY: - x = fluid_voice_gen_value(voice, GEN_MODLFODELAY); fluid_clip(x, -12000.0f, 5000.0f); z = (unsigned int) (voice->output_rate * fluid_tc2sec_delay(x)); UPDATE_RVOICE_ENVLFO_I1(fluid_lfo_set_delay, modlfo, z); @@ -817,7 +812,6 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) /* - the frequency is converted into a delta value, per buffer of FLUID_BUFSIZE samples * - the delay into a sample delay */ - x = fluid_voice_gen_value(voice, GEN_MODLFOFREQ); fluid_clip(x, -16000.0f, 4500.0f); x = (4.0f * FLUID_BUFSIZE * fluid_act2hz(x) / voice->output_rate); UPDATE_RVOICE_ENVLFO_R1(fluid_lfo_set_incr, modlfo, x); @@ -829,21 +823,18 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) * - the frequency is converted into a delta value, per buffer of FLUID_BUFSIZE samples * - the delay into a sample delay */ - x = fluid_voice_gen_value(voice, GEN_VIBLFOFREQ); fluid_clip(x, -16000.0f, 4500.0f); x = 4.0f * FLUID_BUFSIZE * fluid_act2hz(x) / voice->output_rate; UPDATE_RVOICE_ENVLFO_R1(fluid_lfo_set_incr, viblfo, x); break; case GEN_VIBLFODELAY: - x = fluid_voice_gen_value(voice,GEN_VIBLFODELAY); fluid_clip(x, -12000.0f, 5000.0f); z = (unsigned int) (voice->output_rate * fluid_tc2sec_delay(x)); UPDATE_RVOICE_ENVLFO_I1(fluid_lfo_set_delay, viblfo, z); break; case GEN_VIBLFOTOPITCH: - x = fluid_voice_gen_value(voice, GEN_VIBLFOTOPITCH); fluid_clip(x, -12000.0, 12000.0); UPDATE_RVOICE_R1(fluid_rvoice_set_viblfo_to_pitch, x); break; @@ -891,14 +882,11 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) break; case GEN_MODENVTOPITCH: - x = fluid_voice_gen_value(voice, GEN_MODENVTOPITCH); fluid_clip(x, -12000.0, 12000.0); UPDATE_RVOICE_R1(fluid_rvoice_set_modenv_to_pitch, x); break; case GEN_MODENVTOFILTERFC: - x = fluid_voice_gen_value(voice,GEN_MODENVTOFILTERFC); - /* Range: SF2.01 section 8.1.3 # 1 * Motivation for range checking: * Filter is reported to make funny noises now and then @@ -921,39 +909,47 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) */ case GEN_STARTADDROFS: /* SF2.01 section 8.1.3 # 0 */ case GEN_STARTADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 4 */ - if (voice->sample != NULL) { - z = (voice->sample->start - + (int) fluid_voice_gen_value(voice, GEN_STARTADDROFS) - + 32768 * (int) fluid_voice_gen_value(voice, GEN_STARTADDRCOARSEOFS)); - UPDATE_RVOICE_I1(fluid_rvoice_set_start, z); + if (voice->sample != NULL) + { + fluid_real_t start_fine = fluid_voice_gen_value(voice, GEN_STARTADDROFS); + fluid_real_t start_coar = fluid_voice_gen_value(voice, GEN_STARTADDRCOARSEOFS); + + z = voice->sample->start + (int)start_fine + 32768 * (int)start_coar; + UPDATE_RVOICE_I1(fluid_rvoice_set_start, z); } break; case GEN_ENDADDROFS: /* SF2.01 section 8.1.3 # 1 */ case GEN_ENDADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 12 */ - if (voice->sample != NULL) { - z = (voice->sample->end - + (int) fluid_voice_gen_value(voice, GEN_ENDADDROFS) - + 32768 * (int) fluid_voice_gen_value(voice, GEN_ENDADDRCOARSEOFS)); - UPDATE_RVOICE_I1(fluid_rvoice_set_end, z); + if (voice->sample != NULL) + { + fluid_real_t end_fine = fluid_voice_gen_value(voice, GEN_ENDADDROFS); + fluid_real_t end_coar = fluid_voice_gen_value(voice, GEN_ENDADDRCOARSEOFS); + + z = voice->sample->end + (int)end_fine + 32768 * (int)end_coar; + UPDATE_RVOICE_I1(fluid_rvoice_set_end, z); } break; case GEN_STARTLOOPADDROFS: /* SF2.01 section 8.1.3 # 2 */ case GEN_STARTLOOPADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 45 */ - if (voice->sample != NULL) { - z = (voice->sample->loopstart - + (int) fluid_voice_gen_value(voice, GEN_STARTLOOPADDROFS) - + 32768 * (int) fluid_voice_gen_value(voice, GEN_STARTLOOPADDRCOARSEOFS)); - UPDATE_RVOICE_I1(fluid_rvoice_set_loopstart, z); + if (voice->sample != NULL) + { + fluid_real_t lstart_fine = fluid_voice_gen_value(voice, GEN_STARTLOOPADDROFS); + fluid_real_t lstart_coar = fluid_voice_gen_value(voice, GEN_STARTLOOPADDRCOARSEOFS); + + z = voice->sample->loopstart + (int)lstart_fine + 32768 * (int)lstart_coar; + UPDATE_RVOICE_I1(fluid_rvoice_set_loopstart, z); } break; case GEN_ENDLOOPADDROFS: /* SF2.01 section 8.1.3 # 3 */ case GEN_ENDLOOPADDRCOARSEOFS: /* SF2.01 section 8.1.3 # 50 */ - if (voice->sample != NULL) { - z = (voice->sample->loopend - + (int) fluid_voice_gen_value(voice, GEN_ENDLOOPADDROFS) - + 32768 * (int) fluid_voice_gen_value(voice, GEN_ENDLOOPADDRCOARSEOFS)); - UPDATE_RVOICE_I1(fluid_rvoice_set_loopend, z); + if (voice->sample != NULL) + { + fluid_real_t lend_fine = fluid_voice_gen_value(voice, GEN_ENDLOOPADDROFS); + fluid_real_t lend_coar = fluid_voice_gen_value(voice, GEN_ENDLOOPADDRCOARSEOFS); + + z = voice->sample->loopend + (int)lend_fine + 32768 * (int)lend_coar; + UPDATE_RVOICE_I1(fluid_rvoice_set_loopend, z); } break; @@ -969,7 +965,6 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) * - attack, decay and release are converted to their increment per sample */ case GEN_VOLENVDELAY: /* SF2.01 section 8.1.3 # 33 */ - x = fluid_voice_gen_value(voice, GEN_VOLENVDELAY); fluid_clip(x, -12000.0f, 5000.0f); count = NUM_BUFFERS_DELAY(x); fluid_voice_update_volenv(voice, FLUID_VOICE_ENVDELAY, @@ -977,7 +972,6 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) break; case GEN_VOLENVATTACK: /* SF2.01 section 8.1.3 # 34 */ - x = fluid_voice_gen_value(voice, GEN_VOLENVATTACK); fluid_clip(x, -12000.0f, 8000.0f); count = 1 + NUM_BUFFERS_ATTACK(x); fluid_voice_update_volenv(voice, FLUID_VOICE_ENVATTACK, @@ -994,15 +988,14 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_VOLENVDECAY: /* SF2.01 section 8.1.3 # 36 */ case GEN_VOLENVSUSTAIN: /* SF2.01 section 8.1.3 # 37 */ case GEN_KEYTOVOLENVDECAY: /* SF2.01 section 8.1.3 # 40 */ - y = 1.0f - 0.001f * fluid_voice_gen_value(voice, GEN_VOLENVSUSTAIN); - fluid_clip(y, 0.0f, 1.0f); + x = 1.0f - 0.001f * fluid_voice_gen_value(voice, GEN_VOLENVSUSTAIN); + fluid_clip(x , 0.0f, 1.0f); count = calculate_hold_decay_buffers(voice, GEN_VOLENVDECAY, GEN_KEYTOVOLENVDECAY, 1); /* 1 for decay */ fluid_voice_update_volenv(voice, FLUID_VOICE_ENVDECAY, - count, 1.0f, count ? -1.0f / count : 0.0f, y, 2.0f); + count, 1.0f, count ? -1.0f / count : 0.0f, x, 2.0f); break; case GEN_VOLENVRELEASE: /* SF2.01 section 8.1.3 # 38 */ - x = fluid_voice_gen_value(voice, GEN_VOLENVRELEASE); fluid_clip(x, FLUID_MIN_VOLENVRELEASE, 8000.0f); count = 1 + NUM_BUFFERS_RELEASE(x); fluid_voice_update_volenv(voice, FLUID_VOICE_ENVRELEASE, @@ -1011,14 +1004,12 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) /* Modulation envelope */ case GEN_MODENVDELAY: /* SF2.01 section 8.1.3 # 25 */ - x = fluid_voice_gen_value(voice, GEN_MODENVDELAY); fluid_clip(x, -12000.0f, 5000.0f); fluid_voice_update_modenv(voice, FLUID_VOICE_ENVDELAY, NUM_BUFFERS_DELAY(x), 0.0f, 0.0f, -1.0f, 1.0f); break; case GEN_MODENVATTACK: /* SF2.01 section 8.1.3 # 26 */ - x = fluid_voice_gen_value(voice, GEN_MODENVATTACK); fluid_clip(x, -12000.0f, 8000.0f); count = 1 + NUM_BUFFERS_ATTACK(x); fluid_voice_update_modenv(voice, FLUID_VOICE_ENVATTACK, @@ -1036,14 +1027,13 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_MODENVSUSTAIN: /* SF 2.01 section 8.1.3 # 29 */ case GEN_KEYTOMODENVDECAY: /* SF 2.01 section 8.1.3 # 32 */ count = calculate_hold_decay_buffers(voice, GEN_MODENVDECAY, GEN_KEYTOMODENVDECAY, 1); /* 1 for decay */ - y = 1.0f - 0.001f * fluid_voice_gen_value(voice, GEN_MODENVSUSTAIN); - fluid_clip(y, 0.0f, 1.0f); + x = 1.0f - 0.001f * fluid_voice_gen_value(voice, GEN_MODENVSUSTAIN); + fluid_clip(x, 0.0f, 1.0f); fluid_voice_update_modenv(voice, FLUID_VOICE_ENVDECAY, - count, 1.0f, count ? -1.0f / count : 0.0f, y, 2.0f); + count, 1.0f, count ? -1.0f / count : 0.0f, x, 2.0f); break; case GEN_MODENVRELEASE: /* SF 2.01 section 8.1.3 # 30 */ - x = fluid_voice_gen_value(voice, GEN_MODENVRELEASE); fluid_clip(x, -12000.0f, 8000.0f); count = 1 + NUM_BUFFERS_RELEASE(x); fluid_voice_update_modenv(voice, FLUID_VOICE_ENVRELEASE, diff --git a/src/synth/fluid_voice.h b/src/synth/fluid_voice.h index 79b00ae1..406eac9a 100644 --- a/src/synth/fluid_voice.h +++ b/src/synth/fluid_voice.h @@ -181,8 +181,7 @@ fluid_voice_unlock_rvoice(fluid_voice_t* voice) #define _SAMPLEMODE(voice) ((int)(voice)->gen[GEN_SAMPLEMODE].val) -/* FIXME - This doesn't seem to be used anywhere - JG */ -fluid_real_t fluid_voice_gen_value(fluid_voice_t* voice, int num); +fluid_real_t fluid_voice_gen_value(const fluid_voice_t* voice, int num); #define fluid_voice_get_loudness(voice) (fluid_adsr_env_get_max_val(&voice->volenv)) From 76d4028aebb444d05b4e30dc9addeb89ac787572 Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 3 Dec 2017 18:28:22 +0100 Subject: [PATCH 21/24] calculate voice amplitudes on-the-fly no need for saving them in fluid_voice_t --- src/synth/fluid_voice.c | 45 ++++++++++++++++++++++++++--------------- src/synth/fluid_voice.h | 4 ---- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/synth/fluid_voice.c b/src/synth/fluid_voice.c index 982d6e7a..497e0a98 100644 --- a/src/synth/fluid_voice.c +++ b/src/synth/fluid_voice.c @@ -430,6 +430,17 @@ void fluid_voice_start(fluid_voice_t* voice) voice->channel->synth->active_voice_count++; } +/** + * Calculate the amplitude of a voice. + * + * @param gain The gain value in the range [0.0 ; 1.0] + * @return An amplitude used by rvoice_mixer's buffers + */ +static fluid_real_t fluid_voice_calculate_gain_amplitude(const fluid_voice_t* voice, fluid_real_t gain) +{ + return gain * voice->synth_gain / 32768.0f; +} + void fluid_voice_calculate_gen_pitch(fluid_voice_t* voice) { @@ -677,10 +688,12 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) case GEN_PAN: /* range checking is done in the fluid_pan function */ voice->pan = x; - voice->amp_left = fluid_pan(x, 1) * voice->synth_gain / 32768.0f; - voice->amp_right = fluid_pan(x, 0) * voice->synth_gain / 32768.0f; - UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, voice->amp_left); - UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 1, voice->amp_right); + + /* left amp */ + UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, fluid_voice_calculate_gain_amplitude(voice, fluid_pan(x, 1))); + + /* right amp */ + UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 1, fluid_voice_calculate_gain_amplitude(voice, fluid_pan(x, 0))); break; case GEN_ATTENUATION: @@ -711,16 +724,14 @@ fluid_voice_update_param(fluid_voice_t* voice, int gen) /* The generator unit is 'tenths of a percent'. */ voice->reverb_send = x / 1000.0f; fluid_clip(voice->reverb_send, 0.0, 1.0); - voice->amp_reverb = voice->reverb_send * voice->synth_gain / 32768.0f; - UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, voice->amp_reverb); + UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, fluid_voice_calculate_gain_amplitude(voice, voice->reverb_send)); break; case GEN_CHORUSSEND: /* The generator unit is 'tenths of a percent'. */ voice->chorus_send = x / 1000.0f; fluid_clip(voice->chorus_send, 0.0, 1.0); - voice->amp_chorus = voice->chorus_send * voice->synth_gain / 32768.0f; - UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, voice->amp_chorus); + UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, fluid_voice_calculate_gain_amplitude(voice, voice->chorus_send)); break; case GEN_OVERRIDEROOTKEY: @@ -1581,22 +1592,24 @@ int fluid_voice_set_param(fluid_voice_t* voice, int gen, fluid_real_t nrpn_value int fluid_voice_set_gain(fluid_voice_t* voice, fluid_real_t gain) { + fluid_real_t left, right, reverb, chorus; + /* avoid division by zero*/ if (gain < 0.0000001){ gain = 0.0000001; } voice->synth_gain = gain; - voice->amp_left = fluid_pan(voice->pan, 1) * gain / 32768.0f; - voice->amp_right = fluid_pan(voice->pan, 0) * gain / 32768.0f; - voice->amp_reverb = voice->reverb_send * gain / 32768.0f; - voice->amp_chorus = voice->chorus_send * gain / 32768.0f; + left = fluid_voice_calculate_gain_amplitude(voice, fluid_pan(voice->pan, 1)); + right = fluid_voice_calculate_gain_amplitude(voice, fluid_pan(voice->pan, 0)); + reverb = fluid_voice_calculate_gain_amplitude(voice, voice->reverb_send); + chorus = fluid_voice_calculate_gain_amplitude(voice, voice->chorus_send); UPDATE_RVOICE_R1(fluid_rvoice_set_synth_gain, gain); - UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, voice->amp_left); - UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 1, voice->amp_right); - UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, voice->amp_reverb); - UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, voice->amp_chorus); + UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 0, left); + UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 1, right); + UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 2, reverb); + UPDATE_RVOICE_BUFFERS2(fluid_rvoice_buffers_set_amp, 3, chorus); return FLUID_OK; } diff --git a/src/synth/fluid_voice.h b/src/synth/fluid_voice.h index 406eac9a..284a7c32 100644 --- a/src/synth/fluid_voice.h +++ b/src/synth/fluid_voice.h @@ -87,16 +87,12 @@ struct _fluid_voice_t /* pan */ fluid_real_t pan; - fluid_real_t amp_left; - fluid_real_t amp_right; /* reverb */ fluid_real_t reverb_send; - fluid_real_t amp_reverb; /* chorus */ fluid_real_t chorus_send; - fluid_real_t amp_chorus; /* rvoice control */ fluid_rvoice_t* rvoice; From 82450e0ee15d3d7755ea4f9ee99b0a1cd3e72da6 Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 3 Dec 2017 18:39:24 +0100 Subject: [PATCH 22/24] remove FLUID_NUM_MOD macro from public API --- doc/fluidsynth-v11-devdoc.txt | 1 + include/fluidsynth/voice.h | 2 -- src/synth/fluid_voice.h | 1 + src/utils/fluidsynth_priv.h | 1 + 4 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 469c6fb4..3a601233 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -90,6 +90,7 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove struct _fluid_mod_t from public API, use the getters and setters of mod.h instead - remove struct _fluid_gen_t, fluid_gen_set_default_values() and enum fluid_gen_flags from public API - remove macros fluid_sfont_get_id() and fluid_sample_refcount() from public API +- remove FLUID_NUM_MOD macro from public API - remove the following deprecated enum values: - GEN_LAST - LAST_LOG_LEVEL diff --git a/include/fluidsynth/voice.h b/include/fluidsynth/voice.h index a6086f4b..2952721e 100644 --- a/include/fluidsynth/voice.h +++ b/include/fluidsynth/voice.h @@ -35,8 +35,6 @@ extern "C" { * such as the SoundFont loader's noteon method. */ -#define FLUID_NUM_MOD 64 /**< Maximum number of modulators in a voice */ - FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t* voice, int gen); /** diff --git a/src/synth/fluid_voice.h b/src/synth/fluid_voice.h index 284a7c32..95ed2721 100644 --- a/src/synth/fluid_voice.h +++ b/src/synth/fluid_voice.h @@ -33,6 +33,7 @@ #define NO_CHANNEL 0xff + typedef struct _fluid_overflow_prio_t fluid_overflow_prio_t; struct _fluid_overflow_prio_t diff --git a/src/utils/fluidsynth_priv.h b/src/utils/fluidsynth_priv.h index 130f1dd7..e6dfe091 100644 --- a/src/utils/fluidsynth_priv.h +++ b/src/utils/fluidsynth_priv.h @@ -215,6 +215,7 @@ typedef struct _fluid_sample_timer_t fluid_sample_timer_t; #define FLUID_MAX_EVENT_QUEUES 16 /**< Maximum number of unique threads queuing events */ #define FLUID_DEFAULT_AUDIO_RT_PRIO 60 /**< Default setting for audio.realtime-prio */ #define FLUID_DEFAULT_MIDI_RT_PRIO 50 /**< Default setting for midi.realtime-prio */ +#define FLUID_NUM_MOD 64 /**< Maximum number of modulators in a voice */ /*************************************************************** * From 38fc7fb027ea4120e03e238371bbb7877fb3ae27 Mon Sep 17 00:00:00 2001 From: derselbst Date: Mon, 4 Dec 2017 20:42:01 +0100 Subject: [PATCH 23/24] reorder public fluid_voice declarations --- include/fluidsynth/voice.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/fluidsynth/voice.h b/include/fluidsynth/voice.h index 2952721e..ed3f869a 100644 --- a/include/fluidsynth/voice.h +++ b/include/fluidsynth/voice.h @@ -35,7 +35,6 @@ extern "C" { * such as the SoundFont loader's noteon method. */ -FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t* voice, int gen); /** * Enum used with fluid_voice_add_mod() to specify how to handle duplicate modulators. @@ -47,21 +46,22 @@ enum fluid_voice_add_mod { }; FLUIDSYNTH_API void fluid_voice_add_mod(fluid_voice_t* voice, fluid_mod_t* mod, int mode); -FLUIDSYNTH_API void fluid_voice_gen_set(fluid_voice_t* voice, int gen, float val); FLUIDSYNTH_API float fluid_voice_gen_get(fluid_voice_t* voice, int gen); +FLUIDSYNTH_API void fluid_voice_gen_set(fluid_voice_t* voice, int gen, float val); FLUIDSYNTH_API void fluid_voice_gen_incr(fluid_voice_t* voice, int gen, float val); FLUIDSYNTH_API unsigned int fluid_voice_get_id(const fluid_voice_t* voice); +FLUIDSYNTH_API int fluid_voice_get_channel(const fluid_voice_t* voice); +FLUIDSYNTH_API int fluid_voice_get_key(const fluid_voice_t* voice); +FLUIDSYNTH_API int fluid_voice_get_actual_key(const fluid_voice_t* voice); +FLUIDSYNTH_API int fluid_voice_get_velocity(const fluid_voice_t* voice); +FLUIDSYNTH_API int fluid_voice_get_actual_velocity(const fluid_voice_t* voice); FLUIDSYNTH_API int fluid_voice_is_playing(const fluid_voice_t* voice); FLUIDSYNTH_API int fluid_voice_is_on(const fluid_voice_t* voice); FLUIDSYNTH_API int fluid_voice_is_sustained(const fluid_voice_t* voice); FLUIDSYNTH_API int fluid_voice_is_sostenuto(const fluid_voice_t* voice); -FLUIDSYNTH_API int fluid_voice_get_channel(const fluid_voice_t* voice); -FLUIDSYNTH_API int fluid_voice_get_actual_key(const fluid_voice_t* voice); -FLUIDSYNTH_API int fluid_voice_get_key(const fluid_voice_t* voice); -FLUIDSYNTH_API int fluid_voice_get_actual_velocity(const fluid_voice_t* voice); -FLUIDSYNTH_API int fluid_voice_get_velocity(const fluid_voice_t* voice); -FLUIDSYNTH_API int fluid_voice_optimize_sample(fluid_sample_t* s); +FLUIDSYNTH_API int fluid_voice_optimize_sample(fluid_sample_t* s); +FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t* voice, int gen); #ifdef __cplusplus From a4e43d354376b64943d0193234273f697b51c1e3 Mon Sep 17 00:00:00 2001 From: derselbst Date: Wed, 6 Dec 2017 12:18:06 +0100 Subject: [PATCH 24/24] re-introduce fluid_synth_set_gen2() to reduce API breakage --- doc/fluidsynth-v11-devdoc.txt | 1 - include/fluidsynth/synth.h | 2 ++ src/synth/fluid_synth.c | 16 ++++++++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/doc/fluidsynth-v11-devdoc.txt b/doc/fluidsynth-v11-devdoc.txt index 3a601233..930dfeb9 100644 --- a/doc/fluidsynth-v11-devdoc.txt +++ b/doc/fluidsynth-v11-devdoc.txt @@ -86,7 +86,6 @@ Changes in FluidSynth 2.0.0 concerning developers: - remove misspelled FLUID_SEQ_PITCHWHHELSENS macro - remove obsolete "audio.[out|in]put-channels" settings - remove unimplemented "synth.dump" setting -- remove fluid_synth_set_gen2(), fluid_synth_set_gen() now behaves as fluid_synth_set_gen2() - remove struct _fluid_mod_t from public API, use the getters and setters of mod.h instead - remove struct _fluid_gen_t, fluid_gen_set_default_values() and enum fluid_gen_flags from public API - remove macros fluid_sfont_get_id() and fluid_sample_refcount() from public API diff --git a/include/fluidsynth/synth.h b/include/fluidsynth/synth.h index 79b723ae..98fd54cb 100644 --- a/include/fluidsynth/synth.h +++ b/include/fluidsynth/synth.h @@ -218,6 +218,8 @@ enum fluid_interp { /* Generator interface */ FLUIDSYNTH_API int fluid_synth_set_gen (fluid_synth_t* synth, int chan, + int param, float value); +FLUIDSYNTH_API int fluid_synth_set_gen2 (fluid_synth_t* synth, int chan, int param, float value, int absolute, int normalized); FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t* synth, int chan, int param); diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 0abb94d7..049a76fa 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -4831,6 +4831,14 @@ fluid_synth_get_settings(fluid_synth_t* synth) return synth->settings; } +/** + * Same as calling \c fluid_synth_set_gen2(synth, chan, param, value, FALSE, FALSE) + * @return FLUID_OK on success, FLUID_FAILED otherwise + */ +int fluid_synth_set_gen(fluid_synth_t* synth, int chan, int param, float value) +{ + return fluid_synth_set_gen2(synth, chan, param, value, FALSE, FALSE); +} /** * Set a SoundFont generator (effect) value on a MIDI channel in real-time. @@ -4843,19 +4851,15 @@ fluid_synth_get_settings(fluid_synth_t* synth) * TRUE to take the value as a 0.0-1.0 range and apply it to the valid * generator effect range (scaled and shifted as necessary). * @return FLUID_OK on success, FLUID_FAILED otherwise - * @since 2.0.0 * * This function allows for setting all effect parameters in real time on a - * MIDI channel. Setting absolute to non-zero will cause the value to override + * MIDI channel. Setting absolute to non-zero will cause the value to override * any generator values set in the instruments played on the MIDI channel. * See SoundFont 2.01 spec, paragraph 8.1.3, page 48 for details on SoundFont * generator parameters and valid ranges. - * - * @note The old behaviour of fluid_synth_set_gen() assumed \c absolute and \c normalized to - * be FALSE. */ int -fluid_synth_set_gen(fluid_synth_t* synth, int chan, int param, +fluid_synth_set_gen2(fluid_synth_t* synth, int chan, int param, float value, int absolute, int normalized) { float v;