add public getters and iteration functions for fluid_sfont_t

This commit is contained in:
derselbst 2018-06-02 15:01:40 +02:00
parent 344133a704
commit 77e608e3ce
3 changed files with 69 additions and 7 deletions

View File

@ -192,6 +192,11 @@ FLUIDSYNTH_API int delete_fluid_sfont(fluid_sfont_t* sfont);
FLUIDSYNTH_API int fluid_sfont_set_data(fluid_sfont_t* sfont, void* data);
FLUIDSYNTH_API void* fluid_sfont_get_data(fluid_sfont_t* sfont);
FLUIDSYNTH_API int fluid_sfont_get_id(fluid_sfont_t* sfont);
FLUIDSYNTH_API const char* fluid_sfont_get_name(fluid_sfont_t* sfont);
FLUIDSYNTH_API fluid_preset_t* fluid_sfont_get_preset(fluid_sfont_t* sfont, int bank, int prenum);
FLUIDSYNTH_API void fluid_sfont_iteration_start(fluid_sfont_t* sfont);
FLUIDSYNTH_API fluid_preset_t* fluid_sfont_iteration_next(fluid_sfont_t* sfont);
/**
* Method to get a virtual SoundFont preset name.

View File

@ -252,6 +252,69 @@ void fluid_sfont_set_iteration_next(fluid_sfont_t* sfont, fluid_sfont_iteration_
sfont->iteration_next = iter_next;
}
/**
* Retrieve the unique ID of a SoundFont instance.
*
* @param sfont The SoundFont instance.
* @return The SoundFont ID.
*/
int fluid_sfont_get_id(fluid_sfont_t* sfont)
{
return sfont->id;
}
/**
* Retrieve the name of a SoundFont instance.
*
* @param sfont The SoundFont instance.
* @return The name of the SoundFont.
*/
const char* fluid_sfont_get_name(fluid_sfont_t* sfont)
{
return sfont->get_name(sfont);
}
/**
* Retrieve the preset assigned the a SoundFont instance
* for the given bank and preset number.
* @param bank bank number of the preset
* @param prenum program number of the preset
* @return The preset instance or NULL if none found.
*/
fluid_preset_t* fluid_sfont_get_preset(fluid_sfont_t* sfont, int bank, int prenum)
{
return sfont->get_preset(sfont, bank, prenum);
}
/**
* Starts / re-starts virtual preset iteration in a SoundFont.
* @param sfont Virtual SoundFont instance
*/
void fluid_sfont_iteration_start(fluid_sfont_t* sfont)
{
fluid_return_if_fail(sfont != NULL);
fluid_return_if_fail(sfont->iteration_start != NULL);
sfont->iteration_start(sfont);
}
/**
* Virtual SoundFont preset iteration function.
*
* Returns preset information to the caller and advances the
* internal iteration state to the next preset for subsequent calls.
* @param sfont The SoundFont instance.
* @return NULL when no more presets are available, otherwise the a pointer to the current preset
*/
fluid_preset_t* fluid_sfont_iteration_next(fluid_sfont_t* sfont)
{
fluid_return_val_if_fail(sfont != NULL, NULL);
fluid_return_val_if_fail(sfont->iteration_next != NULL, NULL);
return sfont->iteration_next(sfont);
}
/**
* Destroys a SoundFont instance created with new_fluid_sfont().
*

View File

@ -37,12 +37,6 @@ int fluid_sample_sanitize_loop(fluid_sample_t *sample, unsigned int max_end);
#define fluid_sfont_delete_internal(_sf) ( ((_sf) && (_sf)->free)? (*(_sf)->free)(_sf) : 0)
#define fluid_sfont_get_id(_sf) ((_sf)->id)
#define fluid_sfont_get_name(_sf) (*(_sf)->get_name)(_sf)
#define fluid_sfont_get_preset(_sf,_bank,_prenum) (*(_sf)->get_preset)(_sf,_bank,_prenum)
#define fluid_sfont_iteration_start(_sf) { if((_sf) && (_sf)->iteration_start) (*(_sf)->iteration_start)(_sf); }
#define fluid_sfont_iteration_next(_sf) (((_sf) && (_sf)->iteration_start) ? (*(_sf)->iteration_next)(_sf) : 0)
#define fluid_preset_delete_internal(_preset) \
{ if ((_preset) && (_preset)->free) { (*(_preset)->free)(_preset); }}
@ -101,7 +95,7 @@ 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 0 when no more presets are available, 1 otherwise
* @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