mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-26 13:50:50 +00:00
remove fluid_synth_set_gen2()
...and all other absolute NRPN generator leftovers, closes #415
This commit is contained in:
parent
70727b2f7a
commit
630523ba73
8 changed files with 13 additions and 78 deletions
|
@ -128,7 +128,6 @@ fluid_channel_init_ctrl(fluid_channel_t *chan, int is_all_ctrl_off)
|
||||||
for(i = 0; i < GEN_LAST; i++)
|
for(i = 0; i < GEN_LAST; i++)
|
||||||
{
|
{
|
||||||
chan->gen[i] = 0.0f;
|
chan->gen[i] = 0.0f;
|
||||||
chan->gen_abs[i] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_all_ctrl_off)
|
if(is_all_ctrl_off)
|
||||||
|
|
|
@ -129,18 +129,6 @@ struct _fluid_channel_t
|
||||||
* applied to future notes. They are copied to a voice's generators
|
* applied to future notes. They are copied to a voice's generators
|
||||||
* in fluid_voice_init(), which calls fluid_gen_init(). */
|
* in fluid_voice_init(), which calls fluid_gen_init(). */
|
||||||
fluid_real_t gen[GEN_LAST];
|
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);
|
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_legato(_c) ((_c)->cc[LEGATO_SWITCH] >= 64)
|
||||||
#define fluid_channel_sustained(_c) ((_c)->cc[SUSTAIN_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_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(_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) \
|
#define fluid_channel_get_min_note_length_ticks(chan) \
|
||||||
((chan)->synth->min_note_length_ticks)
|
((chan)->synth->min_note_length_ticks)
|
||||||
|
|
||||||
|
|
|
@ -107,14 +107,6 @@ fluid_gen_init(fluid_gen_t *gen, fluid_channel_t *channel)
|
||||||
gen[i].mod = 0.0;
|
gen[i].mod = 0.0;
|
||||||
gen[i].nrpn = (channel == NULL) ? 0.0 : fluid_channel_get_gen(channel, i);
|
gen[i].nrpn = (channel == NULL) ? 0.0 : fluid_channel_get_gen(channel, i);
|
||||||
gen[i].val = fluid_gen_info[i].def;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ enum fluid_gen_flags
|
||||||
{
|
{
|
||||||
GEN_UNUSED, /**< Generator value is not set */
|
GEN_UNUSED, /**< Generator value is not set */
|
||||||
GEN_SET, /**< Generator value is 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); }
|
#define fluid_gen_set_mod(_gen, _val) { (_gen)->mod = (double) (_val); }
|
||||||
|
|
|
@ -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,
|
static int fluid_synth_set_tuning_LOCAL(fluid_synth_t *synth, int chan,
|
||||||
fluid_tuning_t *tuning, int apply);
|
fluid_tuning_t *tuning, int apply);
|
||||||
static void fluid_synth_set_gen_LOCAL(fluid_synth_t *synth, int chan,
|
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);
|
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)
|
if(nrpn_select < GEN_LAST)
|
||||||
{
|
{
|
||||||
float val = fluid_gen_scale_nrpn(nrpn_select, data);
|
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 */
|
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) */
|
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,
|
fluid_synth_set_gen_LOCAL(synth, channum, GEN_FINETUNE,
|
||||||
(data - 8192) / 8192.0 * 100.0, FALSE);
|
(data - 8192) / 8192.0 * 100.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RPN_CHANNEL_COARSE_TUNE: /* Coarse tune is 7 bit and in semitones (64 is center) */
|
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,
|
fluid_synth_set_gen_LOCAL(synth, channum, GEN_COARSETUNE,
|
||||||
value - 64, FALSE);
|
value - 64);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RPN_TUNING_PROGRAM_CHANGE:
|
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)
|
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_return_val_if_fail(param >= 0 && param < GEN_LAST, FLUID_FAILED);
|
||||||
FLUID_API_ENTRY_CHAN(FLUID_FAILED);
|
FLUID_API_ENTRY_CHAN(FLUID_FAILED);
|
||||||
|
|
||||||
v = normalized ? fluid_gen_scale(param, value) : value;
|
fluid_synth_set_gen_LOCAL(synth, chan, param, value);
|
||||||
|
|
||||||
fluid_synth_set_gen_LOCAL(synth, chan, param, v, absolute);
|
|
||||||
|
|
||||||
FLUID_API_RETURN(FLUID_OK);
|
FLUID_API_RETURN(FLUID_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Synthesis thread local set gen function */
|
/* Synthesis thread local set gen function */
|
||||||
static void
|
static void
|
||||||
fluid_synth_set_gen_LOCAL(fluid_synth_t *synth, int chan, int param, float value,
|
fluid_synth_set_gen_LOCAL(fluid_synth_t *synth, int chan, int param, float value)
|
||||||
int absolute)
|
|
||||||
{
|
{
|
||||||
fluid_voice_t *voice;
|
fluid_voice_t *voice;
|
||||||
int i;
|
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++)
|
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)
|
if(fluid_voice_get_channel(voice) == chan)
|
||||||
{
|
{
|
||||||
fluid_voice_set_param(voice, param, value, absolute);
|
fluid_voice_set_param(voice, param, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
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
|
* misc
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -427,19 +427,9 @@ fluid_voice_gen_get(fluid_voice_t *voice, int gen)
|
||||||
}
|
}
|
||||||
|
|
||||||
fluid_real_t fluid_voice_gen_value(const 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()
|
|
||||||
* 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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fluid_voice_start
|
* fluid_voice_start
|
||||||
|
@ -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].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);
|
fluid_voice_update_param(voice, gen);
|
||||||
return FLUID_OK;
|
return FLUID_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
int fluid_voice_modulate_all(fluid_voice_t *voice);
|
||||||
|
|
||||||
/** Set the NRPN value of a generator. */
|
/** 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. */
|
/** Set the gain. */
|
||||||
|
|
Loading…
Reference in a new issue