mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-01-19 07:50:49 +00:00
set soundfont iteration methods on fluid_sfont_t creation
This commit is contained in:
parent
c1a2a7af19
commit
a33e3c698d
5 changed files with 38 additions and 48 deletions
|
@ -172,6 +172,26 @@ typedef const char* (*fluid_sfont_get_name_t)(fluid_sfont_t* sfont);
|
|||
*/
|
||||
typedef fluid_preset_t* (*fluid_sfont_get_preset_t)(fluid_sfont_t* sfont, int bank, int prenum);
|
||||
|
||||
/**
|
||||
* Start virtual SoundFont preset iteration method.
|
||||
* @param sfont Virtual SoundFont
|
||||
*
|
||||
* Starts/re-starts virtual preset iteration in a SoundFont.
|
||||
*/
|
||||
typedef void (*fluid_sfont_iteration_start_t)(fluid_sfont_t* sfont);
|
||||
|
||||
/**
|
||||
* Virtual SoundFont preset iteration function.
|
||||
* @param sfont Virtual SoundFont
|
||||
* @param preset Caller supplied uninitialized buffer to fill in with current preset information
|
||||
* @return NULL when no more presets are available, otherwise the a pointer to the current preset
|
||||
*
|
||||
* Should store preset information to the caller supplied \a preset structure
|
||||
* and advance the internal iteration state to the next preset for subsequent
|
||||
* calls.
|
||||
*/
|
||||
typedef fluid_preset_t* (*fluid_sfont_iteration_next_t)(fluid_sfont_t* sfont);
|
||||
|
||||
/**
|
||||
* Method to free a virtual SoundFont bank. Any custom user provided cleanup function must ultimately call
|
||||
* delete_fluid_sfont() to ensure proper cleanup of the #fluid_sfont_t struct. If no private data
|
||||
|
@ -185,8 +205,11 @@ typedef int (*fluid_sfont_free_t)(fluid_sfont_t* sfont);
|
|||
|
||||
|
||||
FLUIDSYNTH_API fluid_sfont_t* new_fluid_sfont(fluid_sfont_get_name_t get_name,
|
||||
fluid_sfont_get_preset_t get_preset,
|
||||
fluid_sfont_free_t free);
|
||||
fluid_sfont_get_preset_t get_preset,
|
||||
fluid_sfont_iteration_start_t iter_start,
|
||||
fluid_sfont_iteration_next_t iter_next,
|
||||
fluid_sfont_free_t free);
|
||||
|
||||
FLUIDSYNTH_API int delete_fluid_sfont(fluid_sfont_t* sfont);
|
||||
|
||||
FLUIDSYNTH_API int fluid_sfont_set_data(fluid_sfont_t* sfont, void* data);
|
||||
|
|
|
@ -87,6 +87,8 @@ fluid_sfont_t* fluid_defsfloader_load(fluid_sfloader_t* loader, const char* file
|
|||
|
||||
sfont = new_fluid_sfont(fluid_defsfont_sfont_get_name,
|
||||
fluid_defsfont_sfont_get_preset,
|
||||
fluid_defsfont_sfont_iteration_start,
|
||||
fluid_defsfont_sfont_iteration_next,
|
||||
fluid_defsfont_sfont_delete);
|
||||
if (sfont == NULL)
|
||||
{
|
||||
|
@ -94,8 +96,6 @@ fluid_sfont_t* fluid_defsfloader_load(fluid_sfloader_t* loader, const char* file
|
|||
return NULL;
|
||||
}
|
||||
|
||||
fluid_sfont_set_iteration_start(sfont, fluid_defsfont_sfont_iteration_start);
|
||||
fluid_sfont_set_iteration_next(sfont, fluid_defsfont_sfont_iteration_next);
|
||||
fluid_sfont_set_data(sfont, defsfont);
|
||||
|
||||
defsfont->sfont = sfont;
|
||||
|
|
|
@ -92,6 +92,8 @@ fluid_ramsfont_create_sfont()
|
|||
|
||||
sfont = new_fluid_sfont(fluid_ramsfont_sfont_get_name,
|
||||
fluid_ramsfont_sfont_get_preset,
|
||||
fluid_ramsfont_sfont_iteration_start,
|
||||
fluid_ramsfont_sfont_iteration_next,
|
||||
fluid_ramsfont_sfont_delete);
|
||||
if (sfont == NULL)
|
||||
{
|
||||
|
@ -99,11 +101,8 @@ fluid_ramsfont_create_sfont()
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ramsfont->sfont = sfont;
|
||||
|
||||
fluid_sfont_set_iteration_start(sfont, fluid_ramsfont_sfont_iteration_start);
|
||||
fluid_sfont_set_iteration_next(sfont, fluid_ramsfont_sfont_iteration_next);
|
||||
fluid_sfont_set_data(sfont, ramsfont);
|
||||
ramsfont->sfont = sfont;
|
||||
|
||||
return sfont;
|
||||
}
|
||||
|
|
|
@ -180,11 +180,15 @@ int fluid_sfloader_set_callbacks(fluid_sfloader_t* loader,
|
|||
* Creates a new virtual SoundFont instance structure.
|
||||
* @param get_name A function implementing #fluid_sfont_get_name_t.
|
||||
* @param get_preset A function implementing #fluid_sfont_get_preset_t.
|
||||
* @param iter_start A function implementing #fluid_sfont_iteration_start_t, or NULL if preset iteration not needed.
|
||||
* @param iter_next A function implementing #fluid_sfont_iteration_next_t, or NULL if preset iteration not needed.
|
||||
* @param free A function implementing #fluid_sfont_free_t.
|
||||
* @return The soundfont instance on success or NULL otherwise.
|
||||
*/
|
||||
fluid_sfont_t* new_fluid_sfont(fluid_sfont_get_name_t get_name,
|
||||
fluid_sfont_get_preset_t get_preset,
|
||||
fluid_sfont_iteration_start_t iter_start,
|
||||
fluid_sfont_iteration_next_t iter_next,
|
||||
fluid_sfont_free_t free)
|
||||
{
|
||||
fluid_sfont_t* sfont;
|
||||
|
@ -203,6 +207,8 @@ fluid_sfont_t* new_fluid_sfont(fluid_sfont_get_name_t get_name,
|
|||
|
||||
sfont->get_name = get_name;
|
||||
sfont->get_preset = get_preset;
|
||||
sfont->iteration_start = iter_start;
|
||||
sfont->iteration_next = iter_next;
|
||||
sfont->free = free;
|
||||
|
||||
return sfont;
|
||||
|
@ -236,22 +242,6 @@ void* fluid_sfont_get_data(fluid_sfont_t* sfont)
|
|||
return sfont->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal KISS! No need to expose this to public API currently.
|
||||
*/
|
||||
void fluid_sfont_set_iteration_start(fluid_sfont_t* sfont, fluid_sfont_iteration_start_t iter_start)
|
||||
{
|
||||
sfont->iteration_start = iter_start;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal KISS! No need to expose this to public API currently.
|
||||
*/
|
||||
void fluid_sfont_set_iteration_next(fluid_sfont_t* sfont, fluid_sfont_iteration_next_t iter_next)
|
||||
{
|
||||
sfont->iteration_next = iter_next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the unique ID of a SoundFont instance.
|
||||
*
|
||||
|
@ -277,6 +267,7 @@ const char* fluid_sfont_get_name(fluid_sfont_t* sfont)
|
|||
/**
|
||||
* Retrieve the preset assigned the a SoundFont instance
|
||||
* for the given bank and preset number.
|
||||
* @param sfont The SoundFont instance.
|
||||
* @param bank bank number of the preset
|
||||
* @param prenum program number of the preset
|
||||
* @return The preset instance or NULL if none found.
|
||||
|
|
|
@ -83,29 +83,6 @@ struct _fluid_sfloader_t {
|
|||
fluid_sfloader_load_t load;
|
||||
};
|
||||
|
||||
/**
|
||||
* Start virtual SoundFont preset iteration method.
|
||||
* @param sfont Virtual SoundFont
|
||||
*
|
||||
* Starts/re-starts virtual preset iteration in a SoundFont.
|
||||
*/
|
||||
typedef void (*fluid_sfont_iteration_start_t)(fluid_sfont_t* sfont);
|
||||
|
||||
/**
|
||||
* Virtual SoundFont preset iteration function.
|
||||
* @param sfont Virtual SoundFont
|
||||
* @param preset Caller supplied uninitialized buffer to fill in with current preset information
|
||||
* @return NULL when no more presets are available, otherwise the a pointer to the current preset
|
||||
*
|
||||
* Should store preset information to the caller supplied \a preset structure
|
||||
* and advance the internal iteration state to the next preset for subsequent
|
||||
* calls.
|
||||
*/
|
||||
typedef fluid_preset_t* (*fluid_sfont_iteration_next_t)(fluid_sfont_t* sfont);
|
||||
|
||||
void fluid_sfont_set_iteration_start(fluid_sfont_t* sfont, fluid_sfont_iteration_start_t iter_start);
|
||||
void fluid_sfont_set_iteration_next(fluid_sfont_t* sfont, fluid_sfont_iteration_next_t iter_next);
|
||||
|
||||
/**
|
||||
* Virtual SoundFont instance structure.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue