mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 15:01:40 +00:00
fuse fluid_gen_set_default_values() and fluid_gen_init()
avoids iterating over generators twice
This commit is contained in:
parent
f8a55cd10d
commit
45e0f94b29
4 changed files with 12 additions and 37 deletions
|
@ -1099,7 +1099,7 @@ new_fluid_preset_zone(char *name)
|
|||
/* Flag all generators as unused (default, they will be set when they are found
|
||||
* in the sound font).
|
||||
* This also sets the generator values to default, but that is of no concern here.*/
|
||||
fluid_gen_set_default_values(&zone->gen[0]);
|
||||
fluid_gen_init(&zone->gen[0], NULL);
|
||||
zone->mod = NULL; /* list of modulators */
|
||||
return zone;
|
||||
}
|
||||
|
@ -1650,7 +1650,7 @@ new_fluid_inst_zone(char *name)
|
|||
zone->range.ignore = FALSE;
|
||||
/* Flag the generators as unused.
|
||||
* This also sets the generator values to default, but they will be overwritten anyway, if used.*/
|
||||
fluid_gen_set_default_values(&zone->gen[0]);
|
||||
fluid_gen_init(&zone->gen[0], NULL);
|
||||
zone->mod = NULL; /* list of modulators */
|
||||
return zone;
|
||||
}
|
||||
|
|
|
@ -92,14 +92,12 @@ static const fluid_gen_info_t fluid_gen_info[] =
|
|||
{ GEN_CUSTOM_FILTERQ, 1, 1, 0.0f, 960.0f, 0.0f }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set an array of generators to their default values.
|
||||
* @param gen Array of generators (should be #GEN_LAST in size).
|
||||
* @return Always returns #FLUID_OK
|
||||
/* fluid_gen_init
|
||||
*
|
||||
* Set an array of generators to their initial value
|
||||
*/
|
||||
int
|
||||
fluid_gen_set_default_values(fluid_gen_t *gen)
|
||||
void
|
||||
fluid_gen_init(fluid_gen_t *gen, fluid_channel_t *channel)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -107,39 +105,17 @@ fluid_gen_set_default_values(fluid_gen_t *gen)
|
|||
{
|
||||
gen[i].flags = GEN_UNUSED;
|
||||
gen[i].mod = 0.0;
|
||||
gen[i].nrpn = 0.0;
|
||||
gen[i].nrpn = (channel == NULL) ? 0.0 : fluid_channel_get_gen(channel, i);
|
||||
gen[i].val = fluid_gen_info[i].def;
|
||||
}
|
||||
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
|
||||
/* fluid_gen_init
|
||||
*
|
||||
* Set an array of generators to their initial value
|
||||
*/
|
||||
int
|
||||
fluid_gen_init(fluid_gen_t *gen, fluid_channel_t *channel)
|
||||
{
|
||||
int i;
|
||||
|
||||
fluid_gen_set_default_values(gen);
|
||||
|
||||
for(i = 0; i < GEN_LAST; i++)
|
||||
{
|
||||
gen[i].nrpn = fluid_channel_get_gen(channel, i);
|
||||
|
||||
/* This is an extension to the SoundFont standard. More
|
||||
* documentation is available at the fluid_synth_set_gen2()
|
||||
* function. */
|
||||
if(fluid_channel_get_gen_abs(channel, i))
|
||||
if(channel != NULL && fluid_channel_get_gen_abs(channel, i))
|
||||
{
|
||||
gen[i].flags = GEN_ABS_NRPN;
|
||||
}
|
||||
}
|
||||
|
||||
return FLUID_OK;
|
||||
}
|
||||
|
||||
fluid_real_t fluid_gen_scale(int gen, float value)
|
||||
|
|
|
@ -31,7 +31,7 @@ typedef struct _fluid_gen_info_t
|
|||
char nrpn_scale; /* The scale to convert from NRPN (cfr. fluid_gen_map_nrpn()) */
|
||||
float min; /* The minimum value */
|
||||
float max; /* The maximum value */
|
||||
float def; /* The default value (cfr. fluid_gen_set_default_values()) */
|
||||
float def; /* The default value (cfr. fluid_gen_init()) */
|
||||
} fluid_gen_info_t;
|
||||
|
||||
/*
|
||||
|
@ -60,8 +60,7 @@ enum fluid_gen_flags
|
|||
|
||||
fluid_real_t fluid_gen_scale(int gen, float value);
|
||||
fluid_real_t fluid_gen_scale_nrpn(int gen, int nrpn);
|
||||
int fluid_gen_init(fluid_gen_t *gen, fluid_channel_t *channel);
|
||||
int fluid_gen_set_default_values(fluid_gen_t *gen);
|
||||
void fluid_gen_init(fluid_gen_t *gen, fluid_channel_t *channel);
|
||||
|
||||
|
||||
#endif /* _FLUID_GEN_H */
|
||||
|
|
|
@ -606,7 +606,7 @@ fluid_voice_calculate_runtime_synthesis_parameters(fluid_voice_t *voice)
|
|||
* - Add the output value to the modulation value of the generator.
|
||||
*
|
||||
* Note: The generators have been initialized with
|
||||
* fluid_gen_set_default_values.
|
||||
* fluid_gen_init().
|
||||
*/
|
||||
|
||||
for(i = 0; i < voice->mod_count; i++)
|
||||
|
|
Loading…
Reference in a new issue