From 630523ba735bd998f2fabd4694ab09f8e4c9a7e3 Mon Sep 17 00:00:00 2001 From: derselbst Date: Sun, 27 Jan 2019 11:15:14 +0100 Subject: [PATCH] remove fluid_synth_set_gen2() ...and all other absolute NRPN generator leftovers, closes #415 --- src/synth/fluid_chan.c | 1 - src/synth/fluid_chan.h | 15 +------------- src/synth/fluid_gen.c | 8 -------- src/synth/fluid_gen.h | 1 - src/synth/fluid_synth.c | 45 ++++++++--------------------------------- src/synth/fluid_synth.h | 3 --- src/synth/fluid_voice.c | 16 +++------------ src/synth/fluid_voice.h | 2 +- 8 files changed, 13 insertions(+), 78 deletions(-) diff --git a/src/synth/fluid_chan.c b/src/synth/fluid_chan.c index 49ef99ec..365c0fd2 100644 --- a/src/synth/fluid_chan.c +++ b/src/synth/fluid_chan.c @@ -128,7 +128,6 @@ fluid_channel_init_ctrl(fluid_channel_t *chan, int is_all_ctrl_off) for(i = 0; i < GEN_LAST; i++) { chan->gen[i] = 0.0f; - chan->gen_abs[i] = 0; } if(is_all_ctrl_off) diff --git a/src/synth/fluid_chan.h b/src/synth/fluid_chan.h index 42d73df7..a9ca1bca 100644 --- a/src/synth/fluid_chan.h +++ b/src/synth/fluid_chan.h @@ -129,18 +129,6 @@ struct _fluid_channel_t * applied to future notes. They are copied to a voice's generators * in fluid_voice_init(), which calls fluid_gen_init(). */ fluid_real_t gen[GEN_LAST]; - - /* By default, the NRPN values are relative to the values of the - * generators set in the SoundFont. For example, if the NRPN - * specifies an attack of 100 msec then 100 msec will be added to the - * combined attack time of the sound font and the modulators. - * - * However, it is useful to be able to specify the generator value - * absolutely, completely ignoring the generators of the SoundFont - * and the values of modulators. The gen_abs field, is a boolean - * flag indicating whether the NRPN value is absolute or not. - */ - char gen_abs[GEN_LAST]; }; fluid_channel_t *new_fluid_channel(fluid_synth_t *synth, int num); @@ -200,9 +188,8 @@ void fluid_channel_get_sfont_bank_prog(fluid_channel_t *chan, int *sfont, #define fluid_channel_legato(_c) ((_c)->cc[LEGATO_SWITCH] >= 64) #define fluid_channel_sustained(_c) ((_c)->cc[SUSTAIN_SWITCH] >= 64) #define fluid_channel_sostenuto(_c) ((_c)->cc[SOSTENUTO_SWITCH] >= 64) -#define fluid_channel_set_gen(_c, _n, _v, _a) { (_c)->gen[_n] = _v; (_c)->gen_abs[_n] = _a; } +#define fluid_channel_set_gen(_c, _n, _v) { (_c)->gen[_n] = _v; } #define fluid_channel_get_gen(_c, _n) ((_c)->gen[_n]) -#define fluid_channel_get_gen_abs(_c, _n) ((_c)->gen_abs[_n]) #define fluid_channel_get_min_note_length_ticks(chan) \ ((chan)->synth->min_note_length_ticks) diff --git a/src/synth/fluid_gen.c b/src/synth/fluid_gen.c index 291375f2..cf3cc48b 100644 --- a/src/synth/fluid_gen.c +++ b/src/synth/fluid_gen.c @@ -107,14 +107,6 @@ fluid_gen_init(fluid_gen_t *gen, fluid_channel_t *channel) gen[i].mod = 0.0; gen[i].nrpn = (channel == NULL) ? 0.0 : fluid_channel_get_gen(channel, i); gen[i].val = fluid_gen_info[i].def; - - /* This is an extension to the SoundFont standard. More - * documentation is available at the fluid_synth_set_gen2() - * function. */ - if(channel != NULL && fluid_channel_get_gen_abs(channel, i)) - { - gen[i].flags = GEN_ABS_NRPN; - } } } diff --git a/src/synth/fluid_gen.h b/src/synth/fluid_gen.h index b4ea6f6b..76d168c2 100644 --- a/src/synth/fluid_gen.h +++ b/src/synth/fluid_gen.h @@ -52,7 +52,6 @@ enum fluid_gen_flags { GEN_UNUSED, /**< Generator value is not set */ GEN_SET, /**< Generator value is set */ - GEN_ABS_NRPN /**< Generator is an absolute value */ }; #define fluid_gen_set_mod(_gen, _val) { (_gen)->mod = (double) (_val); } diff --git a/src/synth/fluid_synth.c b/src/synth/fluid_synth.c index 32552b06..1c7a1f27 100644 --- a/src/synth/fluid_synth.c +++ b/src/synth/fluid_synth.c @@ -109,7 +109,7 @@ static void fluid_synth_update_voice_tuning_LOCAL(fluid_synth_t *synth, static int fluid_synth_set_tuning_LOCAL(fluid_synth_t *synth, int chan, fluid_tuning_t *tuning, int apply); static void fluid_synth_set_gen_LOCAL(fluid_synth_t *synth, int chan, - int param, float value, int absolute); + int param, float value); static void fluid_synth_stop_LOCAL(fluid_synth_t *synth, unsigned int id); @@ -1694,7 +1694,7 @@ fluid_synth_cc_LOCAL(fluid_synth_t *synth, int channum, int num) if(nrpn_select < GEN_LAST) { float val = fluid_gen_scale_nrpn(nrpn_select, data); - fluid_synth_set_gen_LOCAL(synth, channum, nrpn_select, val, FALSE); + fluid_synth_set_gen_LOCAL(synth, channum, nrpn_select, val); } chan->nrpn_select = 0; /* Reset to 0 */ @@ -1712,12 +1712,12 @@ fluid_synth_cc_LOCAL(fluid_synth_t *synth, int channum, int num) case RPN_CHANNEL_FINE_TUNE: /* Fine tune is 14 bit over +/-1 semitone (+/- 100 cents, 8192 = center) */ fluid_synth_set_gen_LOCAL(synth, channum, GEN_FINETUNE, - (data - 8192) / 8192.0 * 100.0, FALSE); + (data - 8192) / 8192.0 * 100.0); break; case RPN_CHANNEL_COARSE_TUNE: /* Coarse tune is 7 bit and in semitones (64 is center) */ fluid_synth_set_gen_LOCAL(synth, channum, GEN_COARSETUNE, - value - 64, FALSE); + value - 64); break; case RPN_TUNING_PROGRAM_CHANGE: @@ -6117,51 +6117,22 @@ fluid_synth_get_settings(fluid_synth_t *synth) */ 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. - * @param synth FluidSynth instance - * @param chan MIDI channel number (0 to MIDI channel count - 1) - * @param param SoundFont generator ID (#fluid_gen_type) - * @param value Offset or absolute generator value to assign to the MIDI channel - * @param absolute FALSE to assign a relative value, TRUE to assign an absolute value - * @param normalized FALSE if value is specified in the native units of the generator, - * 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 - * - * 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 - * 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. - */ -int -fluid_synth_set_gen2(fluid_synth_t *synth, int chan, int param, - float value, int absolute, int normalized) -{ - float v; fluid_return_val_if_fail(param >= 0 && param < GEN_LAST, FLUID_FAILED); FLUID_API_ENTRY_CHAN(FLUID_FAILED); - v = normalized ? fluid_gen_scale(param, value) : value; - - fluid_synth_set_gen_LOCAL(synth, chan, param, v, absolute); + fluid_synth_set_gen_LOCAL(synth, chan, param, value); FLUID_API_RETURN(FLUID_OK); } /* Synthesis thread local set gen function */ static void -fluid_synth_set_gen_LOCAL(fluid_synth_t *synth, int chan, int param, float value, - int absolute) +fluid_synth_set_gen_LOCAL(fluid_synth_t *synth, int chan, int param, float value) { fluid_voice_t *voice; int i; - fluid_channel_set_gen(synth->channel[chan], param, value, absolute); + fluid_channel_set_gen(synth->channel[chan], param, value); for(i = 0; i < synth->polyphony; i++) { @@ -6169,7 +6140,7 @@ fluid_synth_set_gen_LOCAL(fluid_synth_t *synth, int chan, int param, float value if(fluid_voice_get_channel(voice) == chan) { - fluid_voice_set_param(voice, param, value, absolute); + fluid_voice_set_param(voice, param, value); } } } diff --git a/src/synth/fluid_synth.h b/src/synth/fluid_synth.h index 156424af..46c92ccf 100644 --- a/src/synth/fluid_synth.h +++ b/src/synth/fluid_synth.h @@ -209,9 +209,6 @@ void delete_fluid_sample_timer(fluid_synth_t *synth, fluid_sample_timer_t *timer void fluid_synth_process_event_queue(fluid_synth_t *synth); -int fluid_synth_set_gen2(fluid_synth_t *synth, int chan, - int param, float value, - int absolute, int normalized); /* * misc */ diff --git a/src/synth/fluid_voice.c b/src/synth/fluid_voice.c index 72f4f16d..276adf9d 100644 --- a/src/synth/fluid_voice.c +++ b/src/synth/fluid_voice.c @@ -428,17 +428,7 @@ fluid_voice_gen_get(fluid_voice_t *voice, int gen) 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() - * function. */ - if(voice->gen[num].flags == GEN_ABS_NRPN) - { - return (fluid_real_t) voice->gen[num].nrpn; - } - else - { - return (fluid_real_t)(voice->gen[num].val + voice->gen[num].mod + voice->gen[num].nrpn); - } + return (fluid_real_t)(voice->gen[num].val + voice->gen[num].mod + voice->gen[num].nrpn); } /* @@ -1789,10 +1779,10 @@ fluid_voice_get_lower_boundary_for_attenuation(fluid_voice_t *voice) -int fluid_voice_set_param(fluid_voice_t *voice, int gen, fluid_real_t nrpn_value, int abs) +int fluid_voice_set_param(fluid_voice_t *voice, int gen, fluid_real_t nrpn_value) { voice->gen[gen].nrpn = nrpn_value; - voice->gen[gen].flags = (abs) ? GEN_ABS_NRPN : GEN_SET; + voice->gen[gen].flags = GEN_SET; fluid_voice_update_param(voice, gen); return FLUID_OK; } diff --git a/src/synth/fluid_voice.h b/src/synth/fluid_voice.h index fb0b2823..08d23483 100644 --- a/src/synth/fluid_voice.h +++ b/src/synth/fluid_voice.h @@ -131,7 +131,7 @@ int fluid_voice_modulate(fluid_voice_t *voice, int cc, int ctrl); int fluid_voice_modulate_all(fluid_voice_t *voice); /** Set the NRPN value of a generator. */ -int fluid_voice_set_param(fluid_voice_t *voice, int gen, fluid_real_t value, int abs); +int fluid_voice_set_param(fluid_voice_t *voice, int gen, fluid_real_t value); /** Set the gain. */