SoundFont API

Includes Generators, Modulators, Loader etc
This commit is contained in:
Marcus Weseloh 2020-11-11 23:39:30 +01:00
parent 7f1ac22869
commit 9248032feb
8 changed files with 193 additions and 85 deletions

View file

@ -26,8 +26,10 @@ extern "C" {
#endif
/**
* @defgroup Generators SoundFont Generators
* @brief Functions and defines for SoundFont generator effects.
* @defgroup generators SoundFont Generators
* @ingroup soundfonts
*
* Functions and defines for SoundFont generator effects.
*
* @{
*/
@ -98,7 +100,7 @@ enum fluid_gen_type
GEN_OVERRIDEROOTKEY, /**< Sample root note override */
/**
* @brief Initial Pitch
* Initial Pitch
*
* @note This is not "standard" SoundFont generator, because it is not
* mentioned in the list of generators in the SF2 specifications.
@ -119,11 +121,10 @@ enum fluid_gen_type
GEN_CUSTOM_FILTERFC, /**< Custom filter cutoff frequency */
GEN_CUSTOM_FILTERQ, /**< Custom filter Q */
#ifndef __DOXYGEN__
GEN_LAST /**< @internal Value defines the count of generators (#fluid_gen_type) @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */
#endif
GEN_LAST /**< @internal Value defines the count of generators (#fluid_gen_type)
@warning This symbol is not part of the public API and ABI
stability guarantee and may change at any time! */
};
/* @} */
#ifdef __cplusplus

View file

@ -26,13 +26,14 @@ extern "C" {
#endif
/**
* @defgroup Modulators SoundFont Modulators
* @brief SoundFont modulator functions and constants.
* @defgroup modulators SoundFont Modulators
* @ingroup soundfonts
*
* SoundFont modulator functions and constants.
*
* @{
*/
/**
* Flags defining the polarity, mapping function and type of a modulator source.
* Compare with SoundFont 2.04 PDF section 8.2.
@ -92,7 +93,6 @@ FLUIDSYNTH_API int fluid_mod_has_source(const fluid_mod_t *mod, int cc, int ctrl
FLUIDSYNTH_API int fluid_mod_has_dest(const fluid_mod_t *mod, int gen);
FLUIDSYNTH_API void fluid_mod_clone(fluid_mod_t *mod, const fluid_mod_t *src);
/* @} */
#ifdef __cplusplus

View file

@ -25,10 +25,21 @@
extern "C" {
#endif
/**
* @defgroup soundfonts SountFonts
*
* SoundFont related functions
*
* This part of the API contains functions, defines and types that are mostly
* only used by internal or custom SoundFont loaders or client code that
* modifies loaded presets, SoundFonts or voices directly.
*/
/**
* @defgroup SoundFont SoundFont Loader
* @brief SoundFont plugins
* @defgroup soundfont_loader SoundFont Loader
* @ingroup soundfonts
*
* Create custom SoundFont loaders
*
* It is possible to add new SoundFont loaders to the
* synthesizer. This API allows for virtual SoundFont files to be loaded
@ -77,6 +88,7 @@ enum
/**
* Indicates the type of a sample used by the _fluid_sample_t::sampletype field.
*
* This enum corresponds to the \c SFSampleLink enum in the SoundFont spec.
* One \c flag may be bit-wise OR-ed with one \c value.
*/
@ -94,6 +106,7 @@ enum fluid_sample_type
/**
* 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 \a loader understands).
*
* @param loader SoundFont loader
* @param filename File name or other string identifier
* @return The loaded instrument file (SoundFont) or NULL if an error occurred.
@ -102,10 +115,14 @@ typedef fluid_sfont_t *(*fluid_sfloader_load_t)(fluid_sfloader_t *loader, const
/**
* 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
* addition to any private data.
*
* @param loader SoundFont loader
*
* 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.
* @param loader SoundFont loader
*
*/
typedef void (*fluid_sfloader_free_t)(fluid_sfloader_t *loader);
@ -117,9 +134,10 @@ FLUIDSYNTH_API fluid_sfloader_t *new_fluid_defsfloader(fluid_settings_t *setting
/**
* Opens the file or memory indicated by \c filename in binary read mode.
* \c filename matches the string provided during the fluid_synth_sfload() call.
*
* @return returns a file handle on success, NULL otherwise
*
* \c filename matches the string provided during the fluid_synth_sfload() call.
*/
typedef void *(* fluid_sfloader_callback_open_t)(const char *filename);
@ -134,7 +152,6 @@ typedef int (* fluid_sfloader_callback_read_t)(void *buf, fluid_long_long_t coun
* Same purpose and behaviour as fseek.
*
* @param origin either \c SEEK_SET, \c SEEK_CUR or \c SEEK_END
*
* @return returns #FLUID_OK if the seek was successfully performed while not seeking beyond a buffer or file, #FLUID_FAILED otherwise
*/
typedef int (* fluid_sfloader_callback_seek_t)(void *handle, fluid_long_long_t offset, int origin);
@ -164,6 +181,7 @@ FLUIDSYNTH_API void *fluid_sfloader_get_data(fluid_sfloader_t *loader);
/**
* Method to return the name of a virtual SoundFont.
*
* @param sfont Virtual SoundFont
* @return The name of the virtual SoundFont.
*/
@ -171,6 +189,7 @@ typedef const char *(*fluid_sfont_get_name_t)(fluid_sfont_t *sfont);
/**
* Get a virtual SoundFont preset by bank and program numbers.
*
* @param sfont Virtual SoundFont
* @param bank MIDI bank number (0-16383)
* @param prenum MIDI preset number (0-127)
@ -181,6 +200,7 @@ typedef fluid_preset_t *(*fluid_sfont_get_preset_t)(fluid_sfont_t *sfont, int ba
/**
* Start virtual SoundFont preset iteration method.
*
* @param sfont Virtual SoundFont
*
* Starts/re-starts virtual preset iteration in a SoundFont.
@ -189,6 +209,7 @@ typedef void (*fluid_sfont_iteration_start_t)(fluid_sfont_t *sfont);
/**
* Virtual SoundFont preset iteration function.
*
* @param sfont Virtual SoundFont
* @return NULL when no more presets are available, otherwise the a pointer to the current preset
*
@ -198,13 +219,16 @@ typedef void (*fluid_sfont_iteration_start_t)(fluid_sfont_t *sfont);
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
* needs to be freed, setting this to delete_fluid_sfont() is sufficient.
* Method to free a virtual SoundFont bank.
*
* @param sfont Virtual SoundFont to free.
* @return 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.
*
* 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.
*/
typedef int (*fluid_sfont_free_t)(fluid_sfont_t *sfont);
@ -228,6 +252,7 @@ FLUIDSYNTH_API fluid_preset_t *fluid_sfont_iteration_next(fluid_sfont_t *sfont);
/**
* Method to get a virtual SoundFont preset name.
*
* @param preset Virtual SoundFont preset
* @return 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
@ -237,6 +262,7 @@ typedef const char *(*fluid_preset_get_name_t)(fluid_preset_t *preset);
/**
* Method to get a virtual SoundFont preset MIDI bank number.
*
* @param preset Virtual SoundFont preset
* @param return The bank number of the preset
*/
@ -244,6 +270,7 @@ typedef int (*fluid_preset_get_banknum_t)(fluid_preset_t *preset);
/**
* Method to get a virtual SoundFont preset MIDI program number.
*
* @param preset Virtual SoundFont preset
* @param return The program number of the preset
*/
@ -251,6 +278,7 @@ typedef int (*fluid_preset_get_num_t)(fluid_preset_t *preset);
/**
* Method to handle a noteon event (synthesize the instrument).
*
* @param preset Virtual SoundFont preset
* @param synth Synthesizer instance
* @param chan MIDI channel number of the note on event
@ -274,11 +302,14 @@ typedef int (*fluid_preset_get_num_t)(fluid_preset_t *preset);
typedef int (*fluid_preset_noteon_t)(fluid_preset_t *preset, fluid_synth_t *synth, int chan, int key, int vel);
/**
* 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.
* Method to free a virtual SoundFont preset.
*
* @param preset Virtual SoundFont preset
* @return Should return 0
*
* 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.
*/
typedef void (*fluid_preset_free_t)(fluid_preset_t *preset);

View file

@ -26,18 +26,21 @@ extern "C" {
#endif
/**
* @defgroup VoiceManipulation Voice Manipulation
* @brief Synthesis voice manipulation functions.
* @defgroup voices Voice Manipulation
* @ingroup soundfonts
*
* Synthesis voice manipulation functions.
*
* The interface to the synthesizer's voices.
* Examples on using them can be found in fluid_defsfont.c.
* Examples on using them can be found in the source code of the default SoundFont
* loader (fluid_defsfont.c).
*
* Most of these functions should only be called from within synthesis context,
* such as the SoundFont loader's noteon method.
*
* @{
*/
/**
* Enum used with fluid_voice_add_mod() to specify how to handle duplicate modulators.
*/
@ -65,10 +68,8 @@ FLUIDSYNTH_API int fluid_voice_is_sustained(const fluid_voice_t *voice);
FLUIDSYNTH_API int fluid_voice_is_sostenuto(const fluid_voice_t *voice);
FLUIDSYNTH_API int fluid_voice_optimize_sample(fluid_sample_t *s);
FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t *voice, int gen);
/* @} */
#ifdef __cplusplus
}
#endif

View file

@ -156,8 +156,6 @@ void *fluid_sfloader_get_data(fluid_sfloader_t *loader)
/**
* Set custom callbacks to be used upon soundfont loading.
*
* Useful for loading a soundfont from memory, see \a doc/fluidsynth_sfload_mem.c as an example.
*
* @param loader The SoundFont loader instance.
* @param open A function implementing #fluid_sfloader_callback_open_t.
* @param read A function implementing #fluid_sfloader_callback_read_t.
@ -165,6 +163,9 @@ void *fluid_sfloader_get_data(fluid_sfloader_t *loader)
* @param tell A function implementing #fluid_sfloader_callback_tell_t.
* @param close A function implementing #fluid_sfloader_callback_close_t.
* @return #FLUID_OK if the callbacks have been successfully set, #FLUID_FAILED otherwise.
*
* Useful for loading a soundfont from memory, see \a doc/fluidsynth_sfload_mem.c as an example.
*
*/
int fluid_sfloader_set_callbacks(fluid_sfloader_t *loader,
fluid_sfloader_callback_open_t open,
@ -196,6 +197,7 @@ 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.
@ -285,8 +287,8 @@ 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.
* 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
@ -300,6 +302,7 @@ fluid_preset_t *fluid_sfont_get_preset(fluid_sfont_t *sfont, int bank, int prenu
/**
* Starts / re-starts virtual preset iteration in a SoundFont.
*
* @param sfont Virtual SoundFont instance
*/
void fluid_sfont_iteration_start(fluid_sfont_t *sfont)
@ -329,10 +332,11 @@ fluid_preset_t *fluid_sfont_iteration_next(fluid_sfont_t *sfont)
/**
* Destroys a SoundFont instance created with new_fluid_sfont().
*
* Implements #fluid_sfont_free_t.
*
* @param sfont The SoundFont instance to destroy.
* @return Always returns 0.
*
* Implements #fluid_sfont_free_t.
*
*/
int delete_fluid_sfont(fluid_sfont_t *sfont)
{
@ -467,9 +471,10 @@ fluid_sfont_t *fluid_preset_get_sfont(fluid_preset_t *preset)
/**
* Destroys a SoundFont preset instance created with new_fluid_preset().
*
* @param preset The SoundFont preset instance to destroy.
*
* Implements #fluid_preset_free_t.
*
* @param preset The SoundFont preset instance to destroy.
*/
void delete_fluid_preset(fluid_preset_t *preset)
{
@ -480,6 +485,7 @@ void delete_fluid_preset(fluid_preset_t *preset)
/**
* Create a new sample instance.
*
* @return The sample on success, NULL otherwise.
*/
fluid_sample_t *
@ -502,6 +508,7 @@ new_fluid_sample()
/**
* Destroy a sample instance previously created with new_fluid_sample().
*
* @param sample The sample to destroy.
*/
void
@ -521,10 +528,10 @@ delete_fluid_sample(fluid_sample_t *sample)
/**
* Returns the size of the fluid_sample_t structure.
*
* Useful in low latency scenarios e.g. to allocate a pool of samples.
*
* @return Size of fluid_sample_t in bytes
*
* Useful in low latency scenarios e.g. to allocate a pool of samples.
*
* @note It is recommend to zero initialize the memory before using the object.
*
* @warning Do NOT allocate samples on the stack and assign them to a voice!
@ -536,6 +543,7 @@ size_t fluid_sample_sizeof()
/**
* Set the name of a SoundFont sample.
*
* @param sample SoundFont sample
* @param name Name to assign to sample (20 chars in length + zero terminator)
* @return #FLUID_OK on success, #FLUID_FAILED otherwise
@ -551,6 +559,7 @@ int fluid_sample_set_name(fluid_sample_t *sample, const char *name)
/**
* Assign sample data to a SoundFont sample.
*
* @param sample SoundFont sample
* @param data Buffer containing 16 bit (mono-)audio sample data
* @param data24 If not NULL, pointer to the least significant byte counterparts of each sample data point in order to create 24 bit audio samples

View file

@ -24,8 +24,10 @@
/**
* Clone the modulators destination, sources, flags and amount.
*
* @param mod the modulator to store the copy to
* @param src the source modulator to retrieve the information from
*
* @note The \c next member of \c mod will be left unchanged.
*/
void
@ -41,6 +43,7 @@ fluid_mod_clone(fluid_mod_t *mod, const fluid_mod_t *src)
/**
* Set a modulator's primary source controller and flags.
*
* @param mod The modulator instance
* @param src Modulator source (#fluid_mod_src or a MIDI controller number)
* @param flags Flags determining mapping function and whether the source
@ -56,6 +59,7 @@ fluid_mod_set_source1(fluid_mod_t *mod, int src, int flags)
/**
* Set a modulator's secondary source controller and flags.
*
* @param mod The modulator instance
* @param src Modulator source (#fluid_mod_src or a MIDI controller number)
* @param flags Flags determining mapping function and whether the source
@ -71,6 +75,7 @@ fluid_mod_set_source2(fluid_mod_t *mod, int src, int flags)
/**
* Set the destination effect of a modulator.
*
* @param mod The modulator instance
* @param dest Destination generator (#fluid_gen_type)
*/
@ -82,6 +87,7 @@ fluid_mod_set_dest(fluid_mod_t *mod, int dest)
/**
* Set the scale amount of a modulator.
*
* @param mod The modulator instance
* @param amount Scale amount to assign
*/
@ -93,6 +99,7 @@ fluid_mod_set_amount(fluid_mod_t *mod, double amount)
/**
* Get the primary source value from a modulator.
*
* @param mod The modulator instance
* @return The primary source value (#fluid_mod_src or a MIDI CC controller value).
*/
@ -104,6 +111,7 @@ fluid_mod_get_source1(const fluid_mod_t *mod)
/**
* Get primary source flags from a modulator.
*
* @param mod The modulator instance
* @return The primary source flags (#fluid_mod_flags).
*/
@ -115,6 +123,7 @@ fluid_mod_get_flags1(const fluid_mod_t *mod)
/**
* Get the secondary source value from a modulator.
*
* @param mod The modulator instance
* @return The secondary source value (#fluid_mod_src or a MIDI CC controller value).
*/
@ -126,6 +135,7 @@ fluid_mod_get_source2(const fluid_mod_t *mod)
/**
* Get secondary source flags from a modulator.
*
* @param mod The modulator instance
* @return The secondary source flags (#fluid_mod_flags).
*/
@ -137,6 +147,7 @@ fluid_mod_get_flags2(const fluid_mod_t *mod)
/**
* Get destination effect from a modulator.
*
* @param mod The modulator instance
* @return Destination generator (#fluid_gen_type)
*/
@ -148,6 +159,7 @@ fluid_mod_get_dest(const fluid_mod_t *mod)
/**
* Get the scale amount from a modulator.
*
* @param mod The modulator instance
* @return Scale amount
*/
@ -466,6 +478,7 @@ fluid_mod_get_value(fluid_mod_t *mod, fluid_voice_t *voice)
/**
* Create a new uninitialized modulator structure.
*
* @return New allocated modulator or NULL if out of memory
*/
fluid_mod_t *
@ -484,6 +497,7 @@ new_fluid_mod()
/**
* Free a modulator structure.
*
* @param mod Modulator to free
*/
void
@ -495,9 +509,9 @@ delete_fluid_mod(fluid_mod_t *mod)
/**
* Returns the size of the fluid_mod_t structure.
*
* Useful in low latency scenarios e.g. to allocate a modulator on the stack.
*
* @return Size of fluid_mod_t in bytes
*
* Useful in low latency scenarios e.g. to allocate a modulator on the stack.
*/
size_t fluid_mod_sizeof()
{
@ -518,13 +532,14 @@ fluid_mod_is_src1_none(const fluid_mod_t *mod)
/**
* Checks if modulators source other than CC source is invalid.
* (specs SF 2.01 7.4, 7.8, 8.2.1)
*
* @param mod, modulator.
* @param src1_select, source input selection to check.
* 1 to check src1 source.
* 0 to check src2 source.
* @return FALSE if selected modulator source other than cc is invalid, TRUE otherwise.
*
* (specs SF 2.01 7.4, 7.8, 8.2.1)
*/
static int
fluid_mod_check_non_cc_source(const fluid_mod_t *mod, unsigned char src1_select)
@ -556,6 +571,7 @@ fluid_mod_check_non_cc_source(const fluid_mod_t *mod, unsigned char src1_select)
/**
* Checks if modulator CC source is invalid (specs SF 2.01 7.4, 7.8, 8.2.1).
*
* @param mod, modulator.
* @src1_select, source input selection:
* 1 to check src1 source or
@ -599,6 +615,7 @@ fluid_mod_check_cc_source(const fluid_mod_t *mod, unsigned char src1_select)
/**
* Checks valid modulator sources (specs SF 2.01 7.4, 7.8, 8.2.1)
*
* @param mod, modulator.
* @param name,if not NULL, pointer on a string displayed as a warning.
* @return TRUE if modulator sources src1, src2 are valid, FALSE otherwise.
@ -677,6 +694,7 @@ int fluid_mod_check_sources(const fluid_mod_t *mod, char *name)
/**
* Checks if two modulators are identical in sources, flags and destination.
*
* @param mod1 First modulator
* @param mod2 Second modulator
* @return TRUE if identical, FALSE otherwise
@ -720,6 +738,7 @@ int fluid_mod_has_source(const fluid_mod_t *mod, int cc, int ctrl)
/**
* Check if the modulator has the given destination.
*
* @param mod The modulator instance
* @param gen The destination generator of type #fluid_gen_type to check for
* @return TRUE if the modulator has the given destination, FALSE otherwise.

View file

@ -3021,15 +3021,6 @@ fluid_synth_program_select(fluid_synth_t *synth, int chan, int sfont_id,
/**
* Pins all samples of the given preset.
*
* This function will attempt to pin all samples of the given preset and
* load them into memory, if they are currently unloaded. "To pin" in this
* context means preventing them from being unloaded by an upcoming channel
* prog change.
*
* @note This function is only useful if <code>synth.dynamic-sample-loading</code> is enabled.
* By default, dynamic-sample-loading is disabled and all samples are kept in memory.
* Furthermore, this is only useful for presets which support dynamic-sample-loading (currently,
* only preset loaded with the default soundfont loader do).
* @param synth FluidSynth instance
* @param sfont_id ID of a loaded SoundFont
* @param bank_num MIDI bank number
@ -3038,6 +3029,17 @@ fluid_synth_program_select(fluid_synth_t *synth, int chan, int sfont_id,
* into memory successfully. #FLUID_FAILED otherwise. Note that #FLUID_OK
* is returned, even if <code>synth.dynamic-sample-loading</code> is disabled or
* the preset doesn't support dynamic-sample-loading.
*
* This function will attempt to pin all samples of the given preset and
* load them into memory, if they are currently unloaded. "To pin" in this
* context means preventing them from being unloaded by an upcoming channel
* prog change.
*
* @note This function is only useful if \ref settings_synth_dynamic-sample-loading is enabled.
* By default, dynamic-sample-loading is disabled and all samples are kept in memory.
* Furthermore, this is only useful for presets which support dynamic-sample-loading (currently,
* only preset loaded with the default soundfont loader do).
*
* @since 2.2.0
*/
int
@ -3070,16 +3072,18 @@ fluid_synth_pin_preset(fluid_synth_t *synth, int sfont_id, int bank_num, int pre
/**
* Unpin all samples of the given preset.
*
* This function undoes the effect of fluid_synth_pin_preset(). If the preset is
* not currently used, its samples will be unloaded.
*
* @note Only useful for presets loaded with the default soundfont loader and
* only if <code>synth.dynamic-sample-loading</code> is enabled.
* @param synth FluidSynth instance
* @param sfont_id ID of a loaded SoundFont
* @param bank_num MIDI bank number
* @param preset_num MIDI program number
* @return #FLUID_OK if preset was found, #FLUID_FAILED otherwise
*
* This function undoes the effect of fluid_synth_pin_preset(). If the preset is
* not currently used, its samples will be unloaded.
*
* @note Only useful for presets loaded with the default soundfont loader and
* only if \ref settings_synth_dynamic-sample-loading is enabled.
*
* @since 2.2.0
*/
int
@ -7047,7 +7051,7 @@ static void fluid_synth_handle_important_channels(void *data, const char *name,
}
/** API legato mode *********************************************************/
/* API legato mode *********************************************************/
/**
* Sets the legato mode of a channel.
@ -7100,7 +7104,7 @@ int fluid_synth_get_legato_mode(fluid_synth_t *synth, int chan, int *legatomode)
FLUID_API_RETURN(FLUID_OK);
}
/** API portamento mode *********************************************************/
/* API portamento mode *********************************************************/
/**
* Sets the portamento mode of a channel.
@ -7153,7 +7157,7 @@ int fluid_synth_get_portamento_mode(fluid_synth_t *synth, int chan,
FLUID_API_RETURN(FLUID_OK);
}
/** API breath mode *********************************************************/
/* API breath mode *********************************************************/
/**
* Sets the breath mode of a channel.

View file

@ -367,6 +367,7 @@ fluid_voice_init(fluid_voice_t *voice, fluid_sample_t *sample,
/**
* Update sample rate.
*
* @note If the voice is active, it will be turned off.
*/
void
@ -385,6 +386,7 @@ fluid_voice_set_output_rate(fluid_voice_t *voice, fluid_real_t value)
/**
* Set the value of a generator.
*
* @param voice Voice instance
* @param i Generator ID (#fluid_gen_type)
* @param val Generator value
@ -403,6 +405,7 @@ fluid_voice_gen_set(fluid_voice_t *voice, int i, float val)
/**
* Offset the value of a generator.
*
* @param voice Voice instance
* @param i Generator ID (#fluid_gen_type)
* @param val Value to add to the existing value
@ -416,6 +419,7 @@ fluid_voice_gen_incr(fluid_voice_t *voice, int i, float val)
/**
* Get the value of a generator.
*
* @param voice Voice instance
* @param gen Generator ID (#fluid_gen_type)
* @return Current generator value
@ -734,13 +738,14 @@ calculate_hold_decay_buffers(fluid_voice_t *voice, int gen_base,
* NRPN system. fluid_voice_gen_value(voice, generator_enumerator) returns the sum
* of all three.
*/
/**
* Update all the synthesis parameters, which depend on generator \a gen.
* Update all the synthesis parameters which depend on generator \a gen.
*
* @param voice Voice instance
* @param gen Generator id (#fluid_gen_type)
*
* This is only necessary after changing a generator of an already operating voice.
* Most applications will not need this function.
* Calling this function is only necessary after changing a generator of an already playing voice.
*/
void
fluid_voice_update_param(fluid_voice_t *voice, int gen)
@ -1140,6 +1145,7 @@ fluid_voice_update_param(fluid_voice_t *voice, int gen)
/**
* Recalculate voice parameters for a given control.
*
* @param voice the synthesis voice
* @param cc flag to distinguish between a continuous control and a channel control (pitch bend, ...)
* @param ctrl the control number:
@ -1236,17 +1242,18 @@ int fluid_voice_modulate(fluid_voice_t *voice, int cc, int ctrl)
}
/**
* Update all the modulators. This function is called after a
* ALL_CTRL_OFF MIDI message has been received (CC 121).
* Update all the modulators.
*
* All destination of all modulators must be updated.
* This function is called after a ALL_CTRL_OFF MIDI message has been received (CC 121).
* All destinations of all modulators will be updated.
*/
int fluid_voice_modulate_all(fluid_voice_t *voice)
{
return fluid_voice_modulate(voice, 0, -1);
}
/** legato update functions --------------------------------------------------*/
/* legato update functions --------------------------------------------------*/
/* Updates voice portamento parameters
*
* @voice voice the synthesis voice
@ -1456,6 +1463,7 @@ fluid_voice_stop(fluid_voice_t *voice)
/**
* Adds a modulator to the voice if the modulator has valid sources.
*
* @param voice Voice instance.
* @param mod Modulator info (copied).
* @param mode Determines how to handle an existing identical modulator.
@ -1543,15 +1551,16 @@ fluid_voice_add_mod_local(fluid_voice_t *voice, fluid_mod_t *mod, int mode, int
/**
* Get the unique ID of the noteon-event.
*
* @param voice Voice instance
* @return Note on unique ID
*
* A SoundFont loader may store the voice processes it has created for
* A SoundFont loader may store pointers to voices it has created for
* real-time control during the operation of a voice (for example: parameter
* changes in SoundFont editor). The synth uses a pool of voices, which are
* changes in SoundFont editor). The synth uses a pool of voices internally which are
* 'recycled' and never deallocated.
*
* Before modifying an existing voice, check
* However, before modifying an existing voice, check
* - that its state is still 'playing'
* - that the ID is still the same
*
@ -1563,9 +1572,13 @@ unsigned int fluid_voice_get_id(const fluid_voice_t *voice)
}
/**
* Check if a voice is producing sound. This is also true after a voice received a noteoff as it may be playing in release phase.
* Check if a voice is producing sound.
*
* @param voice Voice instance
* @return TRUE if playing, FALSE otherwise
*
* This might also return TRUE after the voice received a noteoff event, as it may
* still be playing in release phase.
*/
int fluid_voice_is_playing(const fluid_voice_t *voice)
{
@ -1576,9 +1589,13 @@ int fluid_voice_is_playing(const fluid_voice_t *voice)
}
/**
* Check if a voice is ON. A voice is ON, if it has not yet received a noteoff event.
* Check if a voice is ON.
*
* @param voice Voice instance
* @return TRUE if on, FALSE otherwise
*
* A voice is ON if it has not yet received a noteoff event.
*
* @since 1.1.7
*/
int fluid_voice_is_on(const fluid_voice_t *voice)
@ -1588,8 +1605,10 @@ int fluid_voice_is_on(const fluid_voice_t *voice)
/**
* Check if a voice keeps playing after it has received a noteoff due to being held by sustain.
*
* @param voice Voice instance
* @return TRUE if sustained, FALSE otherwise
*
* @since 1.1.7
*/
int fluid_voice_is_sustained(const fluid_voice_t *voice)
@ -1599,8 +1618,10 @@ int fluid_voice_is_sustained(const fluid_voice_t *voice)
/**
* Check if a voice keeps playing after it has received a noteoff due to being held by sostenuto.
*
* @param voice Voice instance
* @return TRUE if sostenuto, FALSE otherwise
*
* @since 1.1.7
*/
int fluid_voice_is_sostenuto(const fluid_voice_t *voice)
@ -1609,9 +1630,13 @@ int fluid_voice_is_sostenuto(const fluid_voice_t *voice)
}
/**
* If the voice is playing, gets the midi channel the voice is playing on. Else the result is undefined.
* Return the MIDI channel the voice is playing on.
*
* @param voice Voice instance
* @return The channel assigned to this voice
*
* @note The result of this function is only valid if the voice is playing.
*
* @since 1.1.7
*/
int fluid_voice_get_channel(const fluid_voice_t *voice)
@ -1620,11 +1645,16 @@ int fluid_voice_get_channel(const fluid_voice_t *voice)
}
/**
* If the voice is playing, gets the midi key the voice is actually playing at. Else the result is undefined.
* If the voice was started from an instrument which uses a fixed key generator, it returns that.
* Else returns the same as \c fluid_voice_get_key.
* Return the effective MIDI key of the playing voice.
*
* @param voice Voice instance
* @return The midi key this voice is playing at
* @return The MIDI key this voice is playing at
*
* If the voice was started from an instrument which uses a fixed key generator, it returns that.
* Otherwise returns the same value as \c fluid_voice_get_key.
*
* @note The result of this function is only valid if the voice is playing.
*
* @since 1.1.7
*/
int fluid_voice_get_actual_key(const fluid_voice_t *voice)
@ -1642,10 +1672,13 @@ int fluid_voice_get_actual_key(const fluid_voice_t *voice)
}
/**
* If the voice is playing, gets the midi key from the noteon event, by which the voice was initially turned on with.
* Else the result is undefined.
* Return the MIDI key from the starting noteon event.
*
* @param voice Voice instance
* @return The midi key of the noteon event that originally turned on this voice
* @return The MIDI key of the noteon event that originally turned on this voice
*
* @note The result of this function is only valid if the voice is playing.
*
* @since 1.1.7
*/
int fluid_voice_get_key(const fluid_voice_t *voice)
@ -1654,11 +1687,16 @@ int fluid_voice_get_key(const fluid_voice_t *voice)
}
/**
* If the voice is playing, gets the midi velocity the voice is actually playing at. Else the result is undefined.
* If the voice was started from an instrument which uses a fixed velocity generator, it returns that.
* Else returns the same as \c fluid_voice_get_velocity.
* Return the effective MIDI velocity of the playing voice.
*
* @param voice Voice instance
* @return The midi velocity this voice is playing at
* @return The MIDI velocity this voice is playing at
*
* If the voice was started from an instrument which uses a fixed velocity generator, it returns that.
* Otherwise it returns the same value as \c fluid_voice_get_velocity.
*
* @note The result of this function is only valid if the voice is playing.
*
* @since 1.1.7
*/
int fluid_voice_get_actual_velocity(const fluid_voice_t *voice)
@ -1676,10 +1714,13 @@ int fluid_voice_get_actual_velocity(const fluid_voice_t *voice)
}
/**
* If the voice is playing, gets the midi velocity from the noteon event, by which the voice was initially
* turned on with. Else the result is undefined.
* Return the MIDI velocity from the starting noteon event.
*
* @param voice Voice instance
* @return The midi velocity which originally turned on this voice
* @return The MIDI velocity which originally turned on this voice
*
* @note The result of this function is only valid if the voice is playing.
*
* @since 1.1.7
*/
int fluid_voice_get_velocity(const fluid_voice_t *voice)
@ -1819,8 +1860,10 @@ int fluid_voice_set_gain(fluid_voice_t *voice, fluid_real_t gain)
* - Calculate, what factor will make the loop inaudible
* - Store in sample
*/
/**
* Calculate the peak volume of a sample for voice off optimization.
*
* @param s Sample to optimize
* @return #FLUID_OK on success, #FLUID_FAILED otherwise
*