Is there a function that can return the list of all the instruments (preset names) in a soundfont file in FluidSynth or at least the number of presets in each soundbank?
This is not exactly "non-iterative", but it's the only way I could find to get a list of all the presets in a soundfont file.
fluid_preset_t* preset = new fluid_preset_t();
// Reset the iteration
sf->iteration_start(sf);
// Go through all the presets within the soundfont
int more = 1;
while (more) {
more = sf->iteration_next(sf, preset); // Will return 0 if no more soundfonts left
if (more) {
// Get preset name
char* presetname = preset->get_name(preset);
int banknum = preset->get_banknum(preset);
int num = preset->get_num(preset);
// Do something with the presetname, bank number and program number
// Such as add it to some list so that you can refer to it later
}
}
... where sf is a soundfont object.
Found this while going through the API documentation at http://fluidsynth.sourceforge.net/api/index.html. Note the menu at the top with links to the data structures, files, etc.