mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-30 16:01:51 +00:00
Merge pull request #263 from FluidSynth/rm-def-mod
support removing default modulators
This commit is contained in:
commit
987aa33486
4 changed files with 61 additions and 20 deletions
|
@ -76,18 +76,18 @@ FLUIDSYNTH_API void fluid_mod_set_source2(fluid_mod_t* mod, int src, int flags);
|
|||
FLUIDSYNTH_API void fluid_mod_set_dest(fluid_mod_t* mod, int dst);
|
||||
FLUIDSYNTH_API void fluid_mod_set_amount(fluid_mod_t* mod, double amount);
|
||||
|
||||
FLUIDSYNTH_API int fluid_mod_get_source1(fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API int fluid_mod_get_flags1(fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API int fluid_mod_get_source2(fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API int fluid_mod_get_flags2(fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API int fluid_mod_get_dest(fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API double fluid_mod_get_amount(fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API int fluid_mod_get_source1(const fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API int fluid_mod_get_flags1(const fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API int fluid_mod_get_source2(const fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API int fluid_mod_get_flags2(const fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API int fluid_mod_get_dest(const fluid_mod_t* mod);
|
||||
FLUIDSYNTH_API double fluid_mod_get_amount(const fluid_mod_t* mod);
|
||||
|
||||
FLUIDSYNTH_API int fluid_mod_test_identity(fluid_mod_t * mod1, fluid_mod_t * mod2);
|
||||
FLUIDSYNTH_API int fluid_mod_has_source(fluid_mod_t * mod, int cc, int ctrl);
|
||||
FLUIDSYNTH_API int fluid_mod_has_dest(fluid_mod_t * mod, int gen);
|
||||
FLUIDSYNTH_API int fluid_mod_test_identity(const fluid_mod_t * mod1, const fluid_mod_t * mod2);
|
||||
FLUIDSYNTH_API int fluid_mod_has_source(const fluid_mod_t * mod, int cc, int ctrl);
|
||||
FLUIDSYNTH_API int fluid_mod_has_dest(const fluid_mod_t * mod, int gen);
|
||||
|
||||
FLUIDSYNTH_API void fluid_mod_clone(fluid_mod_t* mod, fluid_mod_t* src);
|
||||
FLUIDSYNTH_API void fluid_mod_clone(fluid_mod_t* mod, const fluid_mod_t* src);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -295,6 +295,7 @@ enum fluid_synth_add_mod {
|
|||
};
|
||||
|
||||
FLUIDSYNTH_API int fluid_synth_add_default_mod(fluid_synth_t* synth, fluid_mod_t* mod, int mode);
|
||||
FLUIDSYNTH_API int fluid_synth_remove_default_mod(fluid_synth_t* synth, const fluid_mod_t* mod);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
* @note The \c next member of \c mod will be left unchanged.
|
||||
*/
|
||||
void
|
||||
fluid_mod_clone(fluid_mod_t* mod, fluid_mod_t* src)
|
||||
fluid_mod_clone(fluid_mod_t* mod, const fluid_mod_t* src)
|
||||
{
|
||||
mod->dest = src->dest;
|
||||
mod->src1 = src->src1;
|
||||
|
@ -97,7 +97,7 @@ fluid_mod_set_amount(fluid_mod_t* mod, double amount)
|
|||
* @return The primary source value (#fluid_mod_src or a MIDI CC controller value).
|
||||
*/
|
||||
int
|
||||
fluid_mod_get_source1(fluid_mod_t* mod)
|
||||
fluid_mod_get_source1(const fluid_mod_t* mod)
|
||||
{
|
||||
return mod->src1;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ fluid_mod_get_source1(fluid_mod_t* mod)
|
|||
* @return The primary source flags (#fluid_mod_flags).
|
||||
*/
|
||||
int
|
||||
fluid_mod_get_flags1(fluid_mod_t* mod)
|
||||
fluid_mod_get_flags1(const fluid_mod_t* mod)
|
||||
{
|
||||
return mod->flags1;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ fluid_mod_get_flags1(fluid_mod_t* mod)
|
|||
* @return The secondary source value (#fluid_mod_src or a MIDI CC controller value).
|
||||
*/
|
||||
int
|
||||
fluid_mod_get_source2(fluid_mod_t* mod)
|
||||
fluid_mod_get_source2(const fluid_mod_t* mod)
|
||||
{
|
||||
return mod->src2;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ fluid_mod_get_source2(fluid_mod_t* mod)
|
|||
* @return The secondary source flags (#fluid_mod_flags).
|
||||
*/
|
||||
int
|
||||
fluid_mod_get_flags2(fluid_mod_t* mod)
|
||||
fluid_mod_get_flags2(const fluid_mod_t* mod)
|
||||
{
|
||||
return mod->flags2;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ fluid_mod_get_flags2(fluid_mod_t* mod)
|
|||
* @return Destination generator (#fluid_gen_type)
|
||||
*/
|
||||
int
|
||||
fluid_mod_get_dest(fluid_mod_t* mod)
|
||||
fluid_mod_get_dest(const fluid_mod_t* mod)
|
||||
{
|
||||
return mod->dest;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ fluid_mod_get_dest(fluid_mod_t* mod)
|
|||
* @return Scale amount
|
||||
*/
|
||||
double
|
||||
fluid_mod_get_amount(fluid_mod_t* mod)
|
||||
fluid_mod_get_amount(const fluid_mod_t* mod)
|
||||
{
|
||||
return (double) mod->amount;
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ fluid_mod_delete (fluid_mod_t *mod)
|
|||
* SF2.01 section 9.5.1 page 69, 'bullet' 3 defines 'identical'.
|
||||
*/
|
||||
int
|
||||
fluid_mod_test_identity (fluid_mod_t *mod1, fluid_mod_t *mod2)
|
||||
fluid_mod_test_identity (const fluid_mod_t *mod1, const fluid_mod_t *mod2)
|
||||
{
|
||||
return mod1->dest == mod2->dest
|
||||
&& mod1->src1 == mod2->src1
|
||||
|
@ -429,7 +429,7 @@ fluid_mod_test_identity (fluid_mod_t *mod1, fluid_mod_t *mod2)
|
|||
*
|
||||
* @return TRUE if the modulator has the given source, FALSE otherwise.
|
||||
*/
|
||||
int fluid_mod_has_source(fluid_mod_t * mod, int cc, int ctrl)
|
||||
int fluid_mod_has_source(const fluid_mod_t * mod, int cc, int ctrl)
|
||||
{
|
||||
return
|
||||
(
|
||||
|
@ -450,7 +450,7 @@ int fluid_mod_has_source(fluid_mod_t * mod, int cc, int ctrl)
|
|||
* @param gen The destination generator of type #fluid_gen_type to check for
|
||||
* @return TRUE if the modulator has the given destination, FALSE otherwise.
|
||||
*/
|
||||
int fluid_mod_has_dest(fluid_mod_t * mod, int gen)
|
||||
int fluid_mod_has_dest(const fluid_mod_t * mod, int gen)
|
||||
{
|
||||
return mod->dest == gen;
|
||||
}
|
||||
|
|
|
@ -1145,6 +1145,46 @@ fluid_synth_add_default_mod(fluid_synth_t* synth, fluid_mod_t* mod, int mode)
|
|||
FLUID_API_RETURN(FLUID_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified modulator \c mod from the synth's default modulator list.
|
||||
* fluid_mod_test_identity() will be used to test modulator matching.
|
||||
* @param synth synth instance
|
||||
* @param mod The modulator to remove
|
||||
* @return FLUID_OK if a matching modulator was found and successfully removed, FLUID_FAILED otherwise
|
||||
*/
|
||||
int
|
||||
fluid_synth_remove_default_mod(fluid_synth_t* synth, const fluid_mod_t* mod)
|
||||
{
|
||||
fluid_mod_t* default_mod;
|
||||
fluid_mod_t* last_mod;
|
||||
|
||||
fluid_return_val_if_fail (synth != NULL, FLUID_FAILED);
|
||||
fluid_return_val_if_fail (mod != NULL, FLUID_FAILED);
|
||||
fluid_synth_api_enter(synth);
|
||||
|
||||
last_mod = default_mod = synth->default_mod;
|
||||
|
||||
while (default_mod != NULL) {
|
||||
if (fluid_mod_test_identity(default_mod, mod))
|
||||
{
|
||||
if(synth->default_mod == default_mod)
|
||||
{
|
||||
synth->default_mod = synth->default_mod->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
last_mod->next = default_mod->next;
|
||||
}
|
||||
fluid_mod_delete(default_mod);
|
||||
FLUID_API_RETURN(FLUID_OK);
|
||||
}
|
||||
last_mod = default_mod;
|
||||
default_mod = default_mod->next;
|
||||
}
|
||||
|
||||
FLUID_API_RETURN(FLUID_FAILED);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send a MIDI controller event on a MIDI channel.
|
||||
|
|
Loading…
Reference in a new issue