move struct _fluid_mod_t to private header

This commit is contained in:
derselbst 2017-09-21 10:52:48 +02:00
parent 4911138eb0
commit 5da9451321
4 changed files with 68 additions and 33 deletions

View file

@ -32,27 +32,6 @@ extern "C" {
#define FLUID_NUM_MOD 64 /**< Maximum number of modulators in a voice */
/**
* Modulator structure. See SoundFont 2.04 PDF section 8.2.
*
* @deprecated To be removed from the public API.
*/
struct _fluid_mod_t
{
unsigned char dest; /**< Destination generator to control */
unsigned char src1; /**< Source controller 1 */
unsigned char flags1; /**< Source controller 1 flags */
unsigned char src2; /**< Source controller 2 */
unsigned char flags2; /**< Source controller 2 flags */
double amount; /**< Multiplier amount */
/* The 'next' field allows to link modulators into a list. It is
* not used in fluid_voice.c, there each voice allocates memory for a
* fixed number of modulators. Since there may be a huge number of
* different zones, this is more efficient.
*/
fluid_mod_t * next;
};
/**
* Flags defining the polarity, mapping function and type of a modulator source.
* Compare with SoundFont 2.04 PDF section 8.2.
@ -105,7 +84,10 @@ 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_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 void fluid_mod_clone(fluid_mod_t* mod, fluid_mod_t* src);
#ifdef __cplusplus
}

View file

@ -28,6 +28,7 @@
#include "fluidsynth.h"
#include "fluidsynth_priv.h"
#include "fluid_list.h"
#include "fluid_mod.h"

View file

@ -22,8 +22,11 @@
#include "fluid_chan.h"
#include "fluid_voice.h"
/*
* fluid_mod_clone
/**
* Clone the modulators destination, sources, flags and amount.
* @param mod the modulator to store the copy to
* @param src the source modulator to retrieve the information from
* @note The \c next member of \c mod will be left unchanged.
*/
void
fluid_mod_clone(fluid_mod_t* mod, fluid_mod_t* src)
@ -418,7 +421,43 @@ fluid_mod_test_identity (fluid_mod_t *mod1, fluid_mod_t *mod2)
&& mod1->flags2 == mod2->flags2;
}
/**
* Check if the modulator has the given source.
*
* @param cc Boolean value indicating if ctrl is a CC controller or not
* @param ctrl The source to check for (if \c cc == FALSE : a value of type #fluid_mod_src, else the value of the MIDI CC to check for)
*
* @return TRUE if the modulator has the given source, FALSE otherwise.
*/
int fluid_mod_has_source(fluid_mod_t * mod, int cc, int ctrl)
{
return
(
(
((mod->src1 == ctrl) && ((mod->flags1 & FLUID_MOD_CC) != 0) && (cc != 0))
|| ((mod->src1 == ctrl) && ((mod->flags1 & FLUID_MOD_CC) == 0) && (cc == 0))
)
||
(
((mod->src2 == ctrl) && ((mod->flags2 & FLUID_MOD_CC) != 0) && (cc != 0))
|| ((mod->src2 == ctrl) && ((mod->flags2 & FLUID_MOD_CC) == 0) && (cc == 0))
)
);
}
/**
* Check if the modulator has the given destination.
* @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)
{
return mod->dest == gen;
}
/* debug function: Prints the contents of a modulator */
#ifdef DEBUG
void fluid_dump_modulator(fluid_mod_t * mod){
int src1=mod->src1;
int dest=mod->dest;
@ -467,5 +506,5 @@ void fluid_dump_modulator(fluid_mod_t * mod){
}; /* switch dest */
printf(", amount %f flags %i src2 %i flags2 %i\n",amount, flags1, src2, flags2);
};
#endif

View file

@ -24,17 +24,30 @@
#include "fluidsynth_priv.h"
#include "fluid_conv.h"
void fluid_mod_clone(fluid_mod_t* mod, fluid_mod_t* src);
/**
* Modulator structure. See SoundFont 2.04 PDF section 8.2.
*/
struct _fluid_mod_t
{
unsigned char dest; /**< Destination generator to control */
unsigned char src1; /**< Source controller 1 */
unsigned char flags1; /**< Source controller 1 flags */
unsigned char src2; /**< Source controller 2 */
unsigned char flags2; /**< Source controller 2 flags */
double amount; /**< Multiplier amount */
/* The 'next' field allows to link modulators into a list. It is
* not used in fluid_voice.c, there each voice allocates memory for a
* fixed number of modulators. Since there may be a huge number of
* different zones, this is more efficient.
*/
fluid_mod_t * next;
};
fluid_real_t fluid_mod_get_value(fluid_mod_t* mod, fluid_channel_t* chan, fluid_voice_t* voice);
#ifdef DEBUG
void fluid_dump_modulator(fluid_mod_t * mod);
#define fluid_mod_has_source(mod,cc,ctrl) \
( ((((mod)->src1 == ctrl) && (((mod)->flags1 & FLUID_MOD_CC) != 0) && (cc != 0)) \
|| ((((mod)->src1 == ctrl) && (((mod)->flags1 & FLUID_MOD_CC) == 0) && (cc == 0)))) \
|| ((((mod)->src2 == ctrl) && (((mod)->flags2 & FLUID_MOD_CC) != 0) && (cc != 0)) \
|| ((((mod)->src2 == ctrl) && (((mod)->flags2 & FLUID_MOD_CC) == 0) && (cc == 0)))))
#define fluid_mod_has_dest(mod,gen) ((mod)->dest == gen)
#endif
#endif /* _FLUID_MOD_H */