libfluidsynth  2.0.2
Typedefs | Enumerations | Functions
sfont.h File Reference

SoundFont plugins. More...

Typedefs

typedef fluid_sfont_t *(* fluid_sfloader_load_t) (fluid_sfloader_t *loader, const char *filename)
 Method to load an instrument file (does not actually need to be a real file name, could be another type of string identifier that the loader understands). More...
 
typedef void(* fluid_sfloader_free_t) (fluid_sfloader_t *loader)
 The free method should free the memory allocated for a fluid_sfloader_t instance in addition to any private data. More...
 
typedef void *(* fluid_sfloader_callback_open_t) (const char *filename)
 Opens the file or memory indicated by filename in binary read mode. More...
 
typedef int(* fluid_sfloader_callback_read_t) (void *buf, int count, void *handle)
 Reads count bytes to the specified buffer buf. More...
 
typedef int(* fluid_sfloader_callback_seek_t) (void *handle, long offset, int origin)
 Same purpose and behaviour as fseek. More...
 
typedef int(* fluid_sfloader_callback_close_t) (void *handle)
 Closes the handle returned by fluid_sfloader_callback_open_t and frees used ressources. More...
 
typedef long(* fluid_sfloader_callback_tell_t) (void *handle)
 
typedef const char *(* fluid_sfont_get_name_t) (fluid_sfont_t *sfont)
 Method to return the name of a virtual SoundFont. More...
 
typedef fluid_preset_t *(* fluid_sfont_get_preset_t) (fluid_sfont_t *sfont, int bank, int prenum)
 Get a virtual SoundFont preset by bank and program numbers. More...
 
typedef void(* fluid_sfont_iteration_start_t) (fluid_sfont_t *sfont)
 Start virtual SoundFont preset iteration method. More...
 
typedef fluid_preset_t *(* fluid_sfont_iteration_next_t) (fluid_sfont_t *sfont)
 Virtual SoundFont preset iteration function. More...
 
typedef int(* fluid_sfont_free_t) (fluid_sfont_t *sfont)
 Method to free a virtual SoundFont bank. More...
 
typedef const char *(* fluid_preset_get_name_t) (fluid_preset_t *preset)
 Method to get a virtual SoundFont preset name. More...
 
typedef int(* fluid_preset_get_banknum_t) (fluid_preset_t *preset)
 Method to get a virtual SoundFont preset MIDI bank number. More...
 
typedef int(* fluid_preset_get_num_t) (fluid_preset_t *preset)
 Method to get a virtual SoundFont preset MIDI program number. More...
 
typedef int(* fluid_preset_noteon_t) (fluid_preset_t *preset, fluid_synth_t *synth, int chan, int key, int vel)
 Method to handle a noteon event (synthesize the instrument). More...
 
typedef void(* fluid_preset_free_t) (fluid_preset_t *preset)
 Method to free a virtual SoundFont preset. More...
 

Enumerations

enum  { FLUID_PRESET_SELECTED, FLUID_PRESET_UNSELECTED, FLUID_SAMPLE_DONE }
 Some notification enums for presets and samples. More...
 
enum  fluid_sample_type {
  FLUID_SAMPLETYPE_MONO = 0x1, FLUID_SAMPLETYPE_RIGHT = 0x2, FLUID_SAMPLETYPE_LEFT = 0x4, FLUID_SAMPLETYPE_LINKED = 0x8,
  FLUID_SAMPLETYPE_OGG_VORBIS = 0x10, FLUID_SAMPLETYPE_ROM = 0x8000
}
 Indicates the type of a sample used by the _fluid_sample_t::sampletype field. More...
 

Functions

FLUIDSYNTH_API fluid_sfloader_tnew_fluid_sfloader (fluid_sfloader_load_t load, fluid_sfloader_free_t free)
 Creates a new SoundFont loader. More...
 
FLUIDSYNTH_API void delete_fluid_sfloader (fluid_sfloader_t *loader)
 Frees a SoundFont loader created with new_fluid_sfloader(). More...
 
FLUIDSYNTH_API fluid_sfloader_tnew_fluid_defsfloader (fluid_settings_t *settings)
 Creates a default soundfont2 loader that can be used with fluid_synth_add_sfloader(). More...
 
FLUIDSYNTH_API int fluid_sfloader_set_callbacks (fluid_sfloader_t *loader, fluid_sfloader_callback_open_t open, fluid_sfloader_callback_read_t read, fluid_sfloader_callback_seek_t seek, fluid_sfloader_callback_tell_t tell, fluid_sfloader_callback_close_t close)
 Set custom callbacks to be used upon soundfont loading. More...
 
FLUIDSYNTH_API int fluid_sfloader_set_data (fluid_sfloader_t *loader, void *data)
 Specify private data to be used by fluid_sfloader_load_t. More...
 
FLUIDSYNTH_API void * fluid_sfloader_get_data (fluid_sfloader_t *loader)
 Obtain private data previously set with fluid_sfloader_set_data(). More...
 
FLUIDSYNTH_API fluid_sfont_tnew_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)
 Creates a new virtual SoundFont instance structure. More...
 
FLUIDSYNTH_API int delete_fluid_sfont (fluid_sfont_t *sfont)
 Destroys a SoundFont instance created with new_fluid_sfont(). More...
 
FLUIDSYNTH_API int fluid_sfont_set_data (fluid_sfont_t *sfont, void *data)
 Set private data to use with a SoundFont instance. More...
 
FLUIDSYNTH_API void * fluid_sfont_get_data (fluid_sfont_t *sfont)
 Retrieve the private data of a SoundFont instance. More...
 
FLUIDSYNTH_API int fluid_sfont_get_id (fluid_sfont_t *sfont)
 Retrieve the unique ID of a SoundFont instance. More...
 
FLUIDSYNTH_API const char * fluid_sfont_get_name (fluid_sfont_t *sfont)
 Retrieve the name of a SoundFont instance. More...
 
FLUIDSYNTH_API fluid_preset_tfluid_sfont_get_preset (fluid_sfont_t *sfont, int bank, int prenum)
 Retrieve the preset assigned the a SoundFont instance for the given bank and preset number. More...
 
FLUIDSYNTH_API void fluid_sfont_iteration_start (fluid_sfont_t *sfont)
 Starts / re-starts virtual preset iteration in a SoundFont. More...
 
FLUIDSYNTH_API fluid_preset_tfluid_sfont_iteration_next (fluid_sfont_t *sfont)
 Virtual SoundFont preset iteration function. More...
 
FLUIDSYNTH_API fluid_preset_tnew_fluid_preset (fluid_sfont_t *parent_sfont, fluid_preset_get_name_t get_name, fluid_preset_get_banknum_t get_bank, fluid_preset_get_num_t get_num, fluid_preset_noteon_t noteon, fluid_preset_free_t free)
 Create a virtual SoundFont preset instance. More...
 
FLUIDSYNTH_API void delete_fluid_preset (fluid_preset_t *preset)
 Destroys a SoundFont preset instance created with new_fluid_preset(). More...
 
FLUIDSYNTH_API int fluid_preset_set_data (fluid_preset_t *preset, void *data)
 Set private data to use with a SoundFont preset instance. More...
 
FLUIDSYNTH_API void * fluid_preset_get_data (fluid_preset_t *preset)
 Retrieve the private data of a SoundFont preset instance. More...
 
FLUIDSYNTH_API const char * fluid_preset_get_name (fluid_preset_t *preset)
 Retrieves the presets name by executing the get_name function provided on its creation. More...
 
FLUIDSYNTH_API int fluid_preset_get_banknum (fluid_preset_t *preset)
 Retrieves the presets bank number by executing the get_bank function provided on its creation. More...
 
FLUIDSYNTH_API int fluid_preset_get_num (fluid_preset_t *preset)
 Retrieves the presets (instrument) number by executing the get_num function provided on its creation. More...
 
FLUIDSYNTH_API fluid_sfont_tfluid_preset_get_sfont (fluid_preset_t *preset)
 Retrieves the presets parent SoundFont instance. More...
 
FLUIDSYNTH_API fluid_sample_tnew_fluid_sample (void)
 Create a new sample instance. More...
 
FLUIDSYNTH_API void delete_fluid_sample (fluid_sample_t *sample)
 Destroy a sample instance previously created with new_fluid_sample(). More...
 
FLUIDSYNTH_API size_t fluid_sample_sizeof (void)
 Returns the size of the fluid_sample_t structure. More...
 
FLUIDSYNTH_API int fluid_sample_set_name (fluid_sample_t *sample, const char *name)
 Set the name of a SoundFont sample. More...
 
FLUIDSYNTH_API int fluid_sample_set_sound_data (fluid_sample_t *sample, short *data, char *data24, unsigned int nbframes, unsigned int sample_rate, short copy_data)
 Assign sample data to a SoundFont sample. More...
 
FLUIDSYNTH_API int fluid_sample_set_loop (fluid_sample_t *sample, unsigned int loop_start, unsigned int loop_end)
 Set the loop of a sample. More...
 
FLUIDSYNTH_API int fluid_sample_set_pitch (fluid_sample_t *sample, int root_key, int fine_tune)
 Set the pitch of a sample. More...
 

Detailed Description

SoundFont plugins.

It is possible to add new SoundFont loaders to the synthesizer. This API allows for virtual SoundFont files to be loaded and synthesized, which may not actually be SoundFont files, as long as they can be represented by the SoundFont synthesis model.

To add a new SoundFont loader to the synthesizer, call fluid_synth_add_sfloader() and pass a pointer to an fluid_sfloader_t instance created by new_fluid_sfloader(). On creation, you must specify a callback function load that will be called for every file attempting to load it and if successful returns a fluid_sfont_t instance, or NULL if it fails.

The fluid_sfont_t structure contains a callback to obtain the name of the SoundFont. It contains two functions to iterate though the contained presets, and one function to obtain a preset corresponding to a bank and preset number. This function should return a fluid_preset_t instance.

The fluid_preset_t instance contains some functions to obtain information from the preset (name, bank, number). The most important callback is the noteon function. The noteon function is called by fluidsynth internally and should call fluid_synth_alloc_voice() for every sample that has to be played. fluid_synth_alloc_voice() expects a pointer to a fluid_sample_t instance and returns a pointer to the opaque fluid_voice_t structure. To set or increment the values of a generator, use fluid_voice_gen_set() or fluid_voice_gen_incr(). When you are finished initializing the voice call fluid_voice_start() to start playing the synthesis voice.

Typedef Documentation

◆ fluid_sfloader_load_t

typedef fluid_sfont_t*(* fluid_sfloader_load_t) (fluid_sfloader_t *loader, const char *filename)

Method to load an instrument file (does not actually need to be a real file name, could be another type of string identifier that the loader understands).

Parameters
loaderSoundFont loader
filenameFile name or other string identifier
Returns
The loaded instrument file (SoundFont) or NULL if an error occured.

◆ fluid_sfloader_free_t

typedef void(* fluid_sfloader_free_t) (fluid_sfloader_t *loader)

The free method should free the memory allocated for a fluid_sfloader_t instance in addition to any private data.

Any custom user provided cleanup function must ultimately call delete_fluid_sfloader() to ensure proper cleanup of the fluid_sfloader_t struct. If no private data needs to be freed, setting this to delete_fluid_sfloader() is sufficient.

Parameters
loaderSoundFont loader

◆ fluid_sfloader_callback_open_t

typedef void*(* fluid_sfloader_callback_open_t) (const char *filename)

Opens the file or memory indicated by filename in binary read mode.

filename matches the string provided during the fluid_synth_sfload() call.

Returns
returns a file handle on success, NULL otherwise

◆ fluid_sfloader_callback_read_t

typedef int(* fluid_sfloader_callback_read_t) (void *buf, int count, void *handle)

Reads count bytes to the specified buffer buf.

Returns
returns FLUID_OK if exactly count bytes were successfully read, else returns FLUID_FAILED and leaves buf unmodified.

◆ fluid_sfloader_callback_seek_t

typedef int(* fluid_sfloader_callback_seek_t) (void *handle, long offset, int origin)

Same purpose and behaviour as fseek.

Parameters
origineither SEEK_SET, SEEK_CUR or SEEK_END
Returns
returns FLUID_OK if the seek was successfully performed while not seeking beyond a buffer or file, FLUID_FAILED otherwise

◆ fluid_sfloader_callback_close_t

typedef int(* fluid_sfloader_callback_close_t) (void *handle)

Closes the handle returned by fluid_sfloader_callback_open_t and frees used ressources.

Returns
returns FLUID_OK on success, FLUID_FAILED on error

◆ fluid_sfloader_callback_tell_t

typedef long(* fluid_sfloader_callback_tell_t) (void *handle)
Returns
returns current file offset or FLUID_FAILED on error

◆ fluid_sfont_get_name_t

typedef const char*(* fluid_sfont_get_name_t) (fluid_sfont_t *sfont)

Method to return the name of a virtual SoundFont.

Parameters
sfontVirtual SoundFont
Returns
The name of the virtual SoundFont.

◆ fluid_sfont_get_preset_t

typedef fluid_preset_t*(* fluid_sfont_get_preset_t) (fluid_sfont_t *sfont, int bank, int prenum)

Get a virtual SoundFont preset by bank and program numbers.

Parameters
sfontVirtual SoundFont
bankMIDI bank number (0-16383)
prenumMIDI preset number (0-127)
Returns
Should return an allocated virtual preset or NULL if it could not be found.

◆ fluid_sfont_iteration_start_t

typedef void(* fluid_sfont_iteration_start_t) (fluid_sfont_t *sfont)

Start virtual SoundFont preset iteration method.

Parameters
sfontVirtual SoundFont

Starts/re-starts virtual preset iteration in a SoundFont.

◆ fluid_sfont_iteration_next_t

typedef fluid_preset_t*(* fluid_sfont_iteration_next_t) (fluid_sfont_t *sfont)

Virtual SoundFont preset iteration function.

Parameters
sfontVirtual SoundFont
presetCaller supplied uninitialized buffer to fill in with current preset information
Returns
NULL when no more presets are available, otherwise the a pointer to the current preset

Should store preset information to the caller supplied preset structure and advance the internal iteration state to the next preset for subsequent calls.

◆ fluid_sfont_free_t

typedef int(* fluid_sfont_free_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 needs to be freed, setting this to delete_fluid_sfont() is sufficient.

Parameters
sfontVirtual SoundFont to free.
Returns
Should return 0 when it was able to free all resources or non-zero if some of the samples could not be freed because they are still in use, in which case the free will be tried again later, until success.

◆ fluid_preset_get_name_t

typedef const char*(* fluid_preset_get_name_t) (fluid_preset_t *preset)

Method to get a virtual SoundFont preset name.

Parameters
presetVirtual SoundFont preset
Returns
Should return the name of the preset. The returned string must be valid for the duration of the virtual preset (or the duration of the SoundFont, in the case of preset iteration).

◆ fluid_preset_get_banknum_t

typedef int(* fluid_preset_get_banknum_t) (fluid_preset_t *preset)

Method to get a virtual SoundFont preset MIDI bank number.

Parameters
presetVirtual SoundFont preset
returnThe bank number of the preset

◆ fluid_preset_get_num_t

typedef int(* fluid_preset_get_num_t) (fluid_preset_t *preset)

Method to get a virtual SoundFont preset MIDI program number.

Parameters
presetVirtual SoundFont preset
returnThe program number of the preset

◆ fluid_preset_noteon_t

typedef int(* fluid_preset_noteon_t) (fluid_preset_t *preset, fluid_synth_t *synth, int chan, int key, int vel)

Method to handle a noteon event (synthesize the instrument).

Parameters
presetVirtual SoundFont preset
synthSynthesizer instance
chanMIDI channel number of the note on event
keyMIDI note number (0-127)
velMIDI velocity (0-127)
Returns
FLUID_OK on success (0) or FLUID_FAILED (-1) otherwise

This method may be called from within synthesis context and therefore should be as efficient as possible and not perform any operations considered bad for realtime audio output (memory allocations and other OS calls).

Call fluid_synth_alloc_voice() for every sample that has to be played. fluid_synth_alloc_voice() expects a pointer to a fluid_sample_t structure and returns a pointer to the opaque fluid_voice_t structure. To set or increment the values of a generator, use fluid_voice_gen_set() or fluid_voice_gen_incr(). When you are finished initializing the voice call fluid_voice_start() to start playing the synthesis voice. Starting with FluidSynth 1.1.0 all voices created will be started at the same time.

◆ fluid_preset_free_t

typedef void(* fluid_preset_free_t) (fluid_preset_t *preset)

Method to free a virtual SoundFont preset.

Any custom user provided cleanup function must ultimately call delete_fluid_preset() to ensure proper cleanup of the fluid_preset_t struct. If no private data needs to be freed, setting this to delete_fluid_preset() is sufficient.

Parameters
presetVirtual SoundFont preset
Returns
Should return 0

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Some notification enums for presets and samples.

Enumerator
FLUID_PRESET_SELECTED 

Preset selected notify.

FLUID_PRESET_UNSELECTED 

Preset unselected notify.

FLUID_SAMPLE_DONE 

Sample no longer needed notify.

◆ fluid_sample_type

Indicates the type of a sample used by the _fluid_sample_t::sampletype field.

Enumerator
FLUID_SAMPLETYPE_MONO 

Used for mono samples.

FLUID_SAMPLETYPE_RIGHT 

Used for right samples of a stereo pair.

FLUID_SAMPLETYPE_LEFT 

Used for left samples of a stereo pair.

FLUID_SAMPLETYPE_LINKED 

Currently not used.

FLUID_SAMPLETYPE_OGG_VORBIS 

Used for Ogg Vorbis compressed samples.

Since
1.1.7
FLUID_SAMPLETYPE_ROM 

Indicates ROM samples, causes sample to be ignored.

Function Documentation

◆ new_fluid_sfloader()

FLUIDSYNTH_API fluid_sfloader_t* new_fluid_sfloader ( fluid_sfloader_load_t  load,
fluid_sfloader_free_t  free 
)

Creates a new SoundFont loader.

Parameters
loadPointer to a function that provides a fluid_sfont_t (see fluid_sfloader_load_t).
freePointer to a function that destroys this instance (see fluid_sfloader_free_t). Unless any private data needs to be freed it is sufficient to set this to delete_fluid_sfloader().
Returns
the SoundFont loader instance on success, NULL otherwise.

References FLUID_ERR, and fluid_sfloader_set_callbacks().

Referenced by new_fluid_defsfloader().

◆ delete_fluid_sfloader()

FLUIDSYNTH_API void delete_fluid_sfloader ( fluid_sfloader_t loader)

Frees a SoundFont loader created with new_fluid_sfloader().

Parameters
loaderThe SoundFont loader instance to free.

Referenced by new_fluid_defsfloader().

◆ new_fluid_defsfloader()

FLUIDSYNTH_API fluid_sfloader_t* new_fluid_defsfloader ( fluid_settings_t settings)

Creates a default soundfont2 loader that can be used with fluid_synth_add_sfloader().

By default every synth instance has an initial default soundfont loader instance. Calling this function is usually only necessary to load a soundfont from memory, by providing custom callback functions via fluid_sfloader_set_callbacks().

Parameters
settingsA settings instance obtained by new_fluid_settings()
Returns
A default soundfont2 loader struct
Examples:
fluidsynth_sfload_mem.c.

References delete_fluid_mod(), delete_fluid_preset(), delete_fluid_sample(), delete_fluid_sfloader(), delete_fluid_sfont(), FLUID_DBG, FLUID_ERR, FLUID_FAILED, FLUID_MOD_BIPOLAR, FLUID_MOD_CC, FLUID_MOD_CONCAVE, FLUID_MOD_CONVEX, FLUID_MOD_GC, FLUID_MOD_LINEAR, FLUID_MOD_NEGATIVE, FLUID_MOD_POSITIVE, FLUID_MOD_SWITCH, fluid_mod_test_identity(), FLUID_MOD_UNIPOLAR, FLUID_OK, fluid_preset_get_banknum(), fluid_preset_get_data(), fluid_preset_get_name(), fluid_preset_get_num(), FLUID_PRESET_SELECTED, fluid_preset_set_data(), FLUID_PRESET_UNSELECTED, FLUID_SAMPLE_DONE, FLUID_SAMPLETYPE_OGG_VORBIS, FLUID_SAMPLETYPE_ROM, fluid_settings_getint(), fluid_sfloader_get_data(), fluid_sfloader_set_data(), fluid_sfont_get_data(), fluid_sfont_set_data(), fluid_synth_start_voice(), FLUID_VOICE_ADD, fluid_voice_gen_incr(), fluid_voice_gen_set(), fluid_voice_optimize_sample(), FLUID_VOICE_OVERWRITE, GEN_ATTENUATION, GEN_KEYRANGE, GEN_VELRANGE, new_fluid_mod(), new_fluid_preset(), new_fluid_sample(), new_fluid_sfloader(), and new_fluid_sfont().

Referenced by new_fluid_synth().

◆ fluid_sfloader_set_callbacks()

FLUIDSYNTH_API int fluid_sfloader_set_callbacks ( fluid_sfloader_t loader,
fluid_sfloader_callback_open_t  open,
fluid_sfloader_callback_read_t  read,
fluid_sfloader_callback_seek_t  seek,
fluid_sfloader_callback_tell_t  tell,
fluid_sfloader_callback_close_t  close 
)

Set custom callbacks to be used upon soundfont loading.

Useful for loading a soundfont from memory, see doc/fluidsynth_sfload_mem.c as an example.

Parameters
loaderThe SoundFont loader instance.
openA function implementing fluid_sfloader_callback_open_t.
readA function implementing fluid_sfloader_callback_read_t.
seekA function implementing fluid_sfloader_callback_seek_t.
tellA function implementing fluid_sfloader_callback_tell_t.
closeA function implementing fluid_sfloader_callback_close_t.
Returns
FLUID_OK if the callbacks have been successfully set, FLUID_FAILED otherwise.
Examples:
fluidsynth_sfload_mem.c.

References FLUID_FAILED, and FLUID_OK.

Referenced by new_fluid_sfloader().

◆ fluid_sfloader_set_data()

FLUIDSYNTH_API int fluid_sfloader_set_data ( fluid_sfloader_t loader,
void *  data 
)

Specify private data to be used by fluid_sfloader_load_t.

Parameters
loaderThe SoundFont loader instance.
dataThe private data to store.
Returns
FLUID_OK on success, FLUID_FAILED otherwise.

References FLUID_FAILED, and FLUID_OK.

Referenced by new_fluid_defsfloader().

◆ fluid_sfloader_get_data()

FLUIDSYNTH_API void* fluid_sfloader_get_data ( fluid_sfloader_t loader)

Obtain private data previously set with fluid_sfloader_set_data().

Parameters
loaderThe SoundFont loader instance.
Returns
The private data or NULL if none explicitly set before.

Referenced by new_fluid_defsfloader().

◆ new_fluid_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_iteration_start_t  iter_start,
fluid_sfont_iteration_next_t  iter_next,
fluid_sfont_free_t  free 
)

Creates a new virtual SoundFont instance structure.

Parameters
get_nameA function implementing fluid_sfont_get_name_t.
get_presetA function implementing fluid_sfont_get_preset_t.
iter_startA function implementing fluid_sfont_iteration_start_t, or NULL if preset iteration not needed.
iter_nextA function implementing fluid_sfont_iteration_next_t, or NULL if preset iteration not needed.
freeA function implementing fluid_sfont_free_t.
Returns
The soundfont instance on success or NULL otherwise.

References FLUID_ERR.

Referenced by new_fluid_defsfloader().

◆ delete_fluid_sfont()

FLUIDSYNTH_API int delete_fluid_sfont ( fluid_sfont_t sfont)

Destroys a SoundFont instance created with new_fluid_sfont().

Implements fluid_sfont_free_t.

Parameters
sfontThe SoundFont instance to destroy.
Returns
Always returns 0.

Referenced by new_fluid_defsfloader().

◆ fluid_sfont_set_data()

FLUIDSYNTH_API int fluid_sfont_set_data ( fluid_sfont_t sfont,
void *  data 
)

Set private data to use with a SoundFont instance.

Parameters
sfontThe SoundFont instance.
dataThe private data to store.
Returns
FLUID_OK on success, FLUID_FAILED otherwise.

References FLUID_FAILED, and FLUID_OK.

Referenced by new_fluid_defsfloader().

◆ fluid_sfont_get_data()

FLUIDSYNTH_API void* fluid_sfont_get_data ( fluid_sfont_t sfont)

Retrieve the private data of a SoundFont instance.

Parameters
sfontThe SoundFont instance.
Returns
The private data or NULL if none explicitly set before.

Referenced by new_fluid_defsfloader().

◆ fluid_sfont_get_id()

FLUIDSYNTH_API int fluid_sfont_get_id ( fluid_sfont_t sfont)

◆ fluid_sfont_get_name()

FLUIDSYNTH_API const char* fluid_sfont_get_name ( fluid_sfont_t sfont)

Retrieve the name of a SoundFont instance.

Parameters
sfontThe SoundFont instance.
Returns
The name of the SoundFont.

Referenced by fluid_get_sysconf(), fluid_synth_get_pitch_wheel_sens(), fluid_synth_get_sfont_by_name(), and fluid_synth_sfreload().

◆ fluid_sfont_get_preset()

FLUIDSYNTH_API fluid_preset_t* fluid_sfont_get_preset ( fluid_sfont_t sfont,
int  bank,
int  prenum 
)

Retrieve the preset assigned the a SoundFont instance for the given bank and preset number.

Parameters
sfontThe SoundFont instance.
bankbank number of the preset
prenumprogram number of the preset
Returns
The preset instance or NULL if none found.

Referenced by fluid_synth_get_pitch_wheel_sens().

◆ fluid_sfont_iteration_start()

FLUIDSYNTH_API void fluid_sfont_iteration_start ( fluid_sfont_t sfont)

Starts / re-starts virtual preset iteration in a SoundFont.

Parameters
sfontVirtual SoundFont instance

Referenced by fluid_get_sysconf().

◆ fluid_sfont_iteration_next()

FLUIDSYNTH_API fluid_preset_t* fluid_sfont_iteration_next ( fluid_sfont_t 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.

Parameters
sfontThe SoundFont instance.
Returns
NULL when no more presets are available, otherwise the a pointer to the current preset

Referenced by fluid_get_sysconf().

◆ new_fluid_preset()

FLUIDSYNTH_API fluid_preset_t* new_fluid_preset ( fluid_sfont_t parent_sfont,
fluid_preset_get_name_t  get_name,
fluid_preset_get_banknum_t  get_bank,
fluid_preset_get_num_t  get_num,
fluid_preset_noteon_t  noteon,
fluid_preset_free_t  free 
)

Create a virtual SoundFont preset instance.

Parameters
parent_sfontThe SoundFont instance this preset shall belong to
get_nameA function implementing fluid_preset_get_name_t
get_bankA function implementing fluid_preset_get_banknum_t
get_numA function implementing fluid_preset_get_num_t
noteonA function implementing fluid_preset_noteon_t
freeA function implementing fluid_preset_free_t
Returns
The preset instance on success, NULL otherwise.

References FLUID_ERR.

Referenced by new_fluid_defsfloader().

◆ delete_fluid_preset()

FLUIDSYNTH_API void delete_fluid_preset ( fluid_preset_t preset)

Destroys a SoundFont preset instance created with new_fluid_preset().

Implements fluid_preset_free_t.

Parameters
presetThe SoundFont preset instance to destroy.

Referenced by new_fluid_defsfloader().

◆ fluid_preset_set_data()

FLUIDSYNTH_API int fluid_preset_set_data ( fluid_preset_t preset,
void *  data 
)

Set private data to use with a SoundFont preset instance.

Parameters
presetThe SoundFont preset instance.
dataThe private data to store.
Returns
FLUID_OK on success, FLUID_FAILED otherwise.

References FLUID_FAILED, and FLUID_OK.

Referenced by new_fluid_defsfloader().

◆ fluid_preset_get_data()

FLUIDSYNTH_API void* fluid_preset_get_data ( fluid_preset_t preset)

Retrieve the private data of a SoundFont preset instance.

Parameters
presetThe SoundFont preset instance.
Returns
The private data or NULL if none explicitly set before.

Referenced by new_fluid_defsfloader().

◆ fluid_preset_get_name()

FLUIDSYNTH_API const char* fluid_preset_get_name ( fluid_preset_t preset)

Retrieves the presets name by executing the get_name function provided on its creation.

Parameters
presetThe SoundFont preset instance.
Returns
Pointer to a NULL-terminated string containing the presets name.

Referenced by fluid_get_sysconf(), and new_fluid_defsfloader().

◆ fluid_preset_get_banknum()

FLUIDSYNTH_API int fluid_preset_get_banknum ( fluid_preset_t preset)

Retrieves the presets bank number by executing the get_bank function provided on its creation.

Parameters
presetThe SoundFont preset instance.
Returns
The bank number of preset.

Referenced by fluid_get_sysconf(), and new_fluid_defsfloader().

◆ fluid_preset_get_num()

FLUIDSYNTH_API int fluid_preset_get_num ( fluid_preset_t preset)

Retrieves the presets (instrument) number by executing the get_num function provided on its creation.

Parameters
presetThe SoundFont preset instance.
Returns
The number of preset.

Referenced by fluid_get_sysconf(), and new_fluid_defsfloader().

◆ fluid_preset_get_sfont()

FLUIDSYNTH_API fluid_sfont_t* fluid_preset_get_sfont ( fluid_preset_t preset)

Retrieves the presets parent SoundFont instance.

Parameters
presetThe SoundFont preset instance.
Returns
The parent SoundFont of preset.

◆ new_fluid_sample()

FLUIDSYNTH_API fluid_sample_t* new_fluid_sample ( void  )

Create a new sample instance.

Returns
The sample on success, NULL otherwise.

References FLUID_ERR.

Referenced by new_fluid_defsfloader().

◆ delete_fluid_sample()

FLUIDSYNTH_API void delete_fluid_sample ( fluid_sample_t sample)

Destroy a sample instance previously created with new_fluid_sample().

Parameters
sampleThe sample to destroy.

Referenced by new_fluid_defsfloader().

◆ fluid_sample_sizeof()

FLUIDSYNTH_API size_t fluid_sample_sizeof ( void  )

Returns the size of the fluid_sample_t structure.

Useful in low latency scenarios e.g. to allocate a sample on the stack.

Returns
Size of fluid_sample_t in bytes

◆ fluid_sample_set_name()

FLUIDSYNTH_API int fluid_sample_set_name ( fluid_sample_t sample,
const char *  name 
)

Set the name of a SoundFont sample.

Parameters
sampleSoundFont sample
nameName to assign to sample (20 chars in length + zero terminator)
Returns
FLUID_OK on success, FLUID_FAILED otherwise

References FLUID_FAILED, and FLUID_OK.

◆ fluid_sample_set_sound_data()

FLUIDSYNTH_API int fluid_sample_set_sound_data ( fluid_sample_t sample,
short *  data,
char *  data24,
unsigned int  nbframes,
unsigned int  sample_rate,
short  copy_data 
)

Assign sample data to a SoundFont sample.

Parameters
sampleSoundFont sample
dataBuffer containing 16 bit (mono-)audio sample data
data24If not NULL, pointer to the least significant byte counterparts of each sample data point in order to create 24 bit audio samples
nbframesNumber of samples in data
sample_rateSampling rate of the sample data
copy_dataTRUE to copy the sample data (and automatically free it upon delete_fluid_sample()), FALSE to use it directly (and not free it)
Returns
FLUID_OK on success, FLUID_FAILED otherwise
Note
If copy_data is FALSE, data should have 8 unused frames at start and 8 unused frames at the end and nbframes should be >=48

References FLUID_ERR, FLUID_FAILED, FLUID_OK, and FLUID_SAMPLETYPE_MONO.

◆ fluid_sample_set_loop()

FLUIDSYNTH_API int fluid_sample_set_loop ( fluid_sample_t sample,
unsigned int  loop_start,
unsigned int  loop_end 
)

Set the loop of a sample.

Parameters
sampleSoundFont sample
loop_startStart sample index of the loop.
loop_endEnd index of the loop (must be a valid sample as it marks the last sample to be played).
Returns
FLUID_OK on success, FLUID_FAILED otherwise.

References FLUID_FAILED, and FLUID_OK.

◆ fluid_sample_set_pitch()

FLUIDSYNTH_API int fluid_sample_set_pitch ( fluid_sample_t sample,
int  root_key,
int  fine_tune 
)

Set the pitch of a sample.

Parameters
sampleSoundFont sample
root_keyRoot MIDI note of sample (0-127)
fine_tuneFine tune in cents
Returns
FLUID_OK on success, FLUID_FAILED otherwise.

References FLUID_DBG, FLUID_FAILED, FLUID_OK, FLUID_SAMPLETYPE_OGG_VORBIS, FLUID_SAMPLETYPE_ROM, and FLUID_WARN.