mkxp-sunshine/src/fluid-fun.h
Jonas Kulla 757a1d5e39 Load fluidsynth entrypoints dynamically (and make them optional)
This removes the static dependency on fluidsynth being present
at buildtime (even headers aren't needed anymore).

Even though midi is a default format for the RPG XP/VX series,
it has fallen more and more out of use, with VX Ace completely
abandoning it from the RTP and making ogg vorbis the de facto
standard. Midi support is kept for legacy reasons, but isn't
encouraged. On top of all this, fluidsynth together with glib
is a heavy dependency that often times won't even be used.
Making it optional at build time is an attempt to unify and
keep build config fragmentation low.

In RGSS3, fluidsynth / midi is not initialized at all by
default, but rather on demand when either a midi track is
played back or Audio.setup_midi is called.
2014-09-09 00:08:32 +02:00

60 lines
2.7 KiB
C

#ifndef FLUIDFUN_H
#define FLUIDFUN_H
typedef struct _fluid_hashtable_t fluid_settings_t;
typedef struct _fluid_synth_t fluid_synth_t;
typedef fluid_settings_t* (*NEWFLUIDSETTINGSPROC)(void);
typedef int (*FLUIDSETTINGSSETNUMPROC)(fluid_settings_t* settings, const char *name, double val);
typedef int (*FLUIDSETTINGSSETSTRPROC)(fluid_settings_t* settings, const char *name, const char *str);
typedef void (*DELETEFLUIDSETTINGSPROC)(fluid_settings_t* settings);
typedef fluid_synth_t* (*NEWFLUIDSYNTHPROC)(fluid_settings_t* settings);
typedef int (*DELETEFLUIDSYNTHPROC)(fluid_synth_t* synth);
typedef int (*FLUIDSYNTHSFLOADPROC)(fluid_synth_t* synth, const char* filename, int reset_presets);
typedef int (*FLUIDSYNTHSYSTEMRESETPROC)(fluid_synth_t* synth);
typedef int (*FLUIDSYNTHWRITES16PROC)(fluid_synth_t* synth, int len, void* lout, int loff, int lincr, void* rout, int roff, int rincr);
typedef int (*FLUIDSYNTHNOTEONPROC)(fluid_synth_t* synth, int chan, int key, int vel);
typedef int (*FLUIDSYNTHNOTEOFFPROC)(fluid_synth_t* synth, int chan, int key);
typedef int (*FLUIDSYNTHCHANNELPRESSUREPROC)(fluid_synth_t* synth, int chan, int val);
typedef int (*FLUIDSYNTHPITCHBENDPROC)(fluid_synth_t* synth, int chan, int val);
typedef int (*FLUIDSYNTHCCPROC)(fluid_synth_t* synth, int chan, int ctrl, int val);
typedef int (*FLUIDSYNTHPROGRAMCHANGEPROC)(fluid_synth_t* synth, int chan, int program);
#define FLUID_FUNCS \
FLUID_FUN(settings_setnum, FLUIDSETTINGSSETNUMPROC) \
FLUID_FUN(settings_setstr, FLUIDSETTINGSSETSTRPROC) \
FLUID_FUN(synth_sfload, FLUIDSYNTHSFLOADPROC) \
FLUID_FUN(synth_system_reset, FLUIDSYNTHSYSTEMRESETPROC) \
FLUID_FUN(synth_write_s16, FLUIDSYNTHWRITES16PROC) \
FLUID_FUN(synth_noteon, FLUIDSYNTHNOTEONPROC) \
FLUID_FUN(synth_noteoff, FLUIDSYNTHNOTEOFFPROC) \
FLUID_FUN(synth_channel_pressure, FLUIDSYNTHCHANNELPRESSUREPROC) \
FLUID_FUN(synth_pitch_bend, FLUIDSYNTHPITCHBENDPROC) \
FLUID_FUN(synth_cc, FLUIDSYNTHCCPROC) \
FLUID_FUN(synth_program_change, FLUIDSYNTHPROGRAMCHANGEPROC)
/* Functions that don't fit into the default prefix naming scheme */
#define FLUID_FUNCS2 \
FLUID_FUN2(new_settings, NEWFLUIDSETTINGSPROC, new_fluid_settings) \
FLUID_FUN2(new_synth, NEWFLUIDSYNTHPROC, new_fluid_synth) \
FLUID_FUN2(delete_settings, DELETEFLUIDSETTINGSPROC, delete_fluid_settings) \
FLUID_FUN2(delete_synth, DELETEFLUIDSYNTHPROC, delete_fluid_synth)
struct FluidFunctions
{
#define FLUID_FUN(name, type) type name;
#define FLUID_FUN2(name, type, rn) type name;
FLUID_FUNCS
FLUID_FUNCS2
#undef FLUID_FUN
#undef FLUID_FUN2
};
#define HAVE_FLUID fluid.new_synth
extern FluidFunctions fluid;
void initFluidFunctions();
void finiFluidFunctions();
#endif // FLUIDFUN_H