update fluidsynth to 2.2.0

This commit is contained in:
alexey.lysiuk 2021-04-03 12:10:44 +03:00
parent 68f2e20f50
commit e100cbbdf4
20 changed files with 790 additions and 271 deletions

View file

@ -43,6 +43,9 @@ extern "C" {
#elif defined(MACOS9) #elif defined(MACOS9)
#define FLUIDSYNTH_API __declspec(export) #define FLUIDSYNTH_API __declspec(export)
#elif defined(__OS2__)
#define FLUIDSYNTH_API __declspec(dllexport)
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define FLUIDSYNTH_API __attribute__ ((visibility ("default"))) #define FLUIDSYNTH_API __attribute__ ((visibility ("default")))

View file

@ -26,29 +26,39 @@ extern "C" {
#endif #endif
/** /**
* @file audio.h * @defgroup audio_output Audio Output
* @brief Functions for audio driver output. *
* @defgroup AudioFunctions Functions for audio output * Functions for managing audio drivers and file renderers.
*
* The file renderer is used for fast rendering of MIDI files to
* audio files. The audio drivers are a high-level interface to
* connect the synthesizer with external audio sinks or to render
* real-time audio to files.
*/
/**
* @defgroup audio_driver Audio Driver
* @ingroup audio_output
*
* Functions for managing audio drivers.
* *
* Defines functions for creating audio driver output. Use * Defines functions for creating audio driver output. Use
* new_fluid_audio_driver() to create a new audio driver for a given synth * new_fluid_audio_driver() to create a new audio driver for a given synth
* and configuration settings. The function new_fluid_audio_driver2() can be * and configuration settings.
*
* The function new_fluid_audio_driver2() can be
* used if custom audio processing is desired before the audio is sent to the * used if custom audio processing is desired before the audio is sent to the
* audio driver (although it is not as efficient). * audio driver (although it is not as efficient).
* *
* @sa @ref CreatingAudioDriver * @sa @ref CreatingAudioDriver
*
* @{
*/ */
/** /**
* Callback function type used with new_fluid_audio_driver2() to allow for * Callback function type used with new_fluid_audio_driver2() to allow for
* custom user audio processing before the audio is sent to the driver. This * custom user audio processing before the audio is sent to the driver.
* function is responsible for rendering audio to the buffers. *
* The buffers passed to this function are allocated and owned by the respective
* audio driver and are only valid during that specific call (do not cache them).
* For further details please refer to fluid_synth_process().
* @note Whereas fluid_synth_process() allows aliasing buffers, there is the guarentee that @p out
* and @p fx buffers provided by fluidsynth's audio drivers never alias. This prevents downstream
* applications from e.g. applying a custom effect accidentially to the same buffer multiple times.
* @param data The user data parameter as passed to new_fluid_audio_driver2(). * @param data The user data parameter as passed to new_fluid_audio_driver2().
* @param len Count of audio frames to synthesize. * @param len Count of audio frames to synthesize.
* @param nfx Count of arrays in \c fx. * @param nfx Count of arrays in \c fx.
@ -56,11 +66,49 @@ extern "C" {
* @param nout Count of arrays in \c out. * @param nout Count of arrays in \c out.
* @param out Array of buffers to store (dry) audio to. Buffers may alias with buffers of \c fx. * @param out Array of buffers to store (dry) audio to. Buffers may alias with buffers of \c fx.
* @return Should return #FLUID_OK on success, #FLUID_FAILED if an error occurred. * @return Should return #FLUID_OK on success, #FLUID_FAILED if an error occurred.
*
* This function is responsible for rendering audio to the buffers.
* The buffers passed to this function are allocated and owned by the respective
* audio driver and are only valid during that specific call (do not cache them).
* The buffers have already been zeroed-out.
* For further details please refer to fluid_synth_process().
*
* @parblock
* @note Whereas fluid_synth_process() allows aliasing buffers, there is the guarentee that @p out
* and @p fx buffers provided by fluidsynth's audio drivers never alias. This prevents downstream
* applications from e.g. applying a custom effect accidentially to the same buffer multiple times.
* @endparblock
*
* @parblock
* @note Also note that the Jack driver is currently the only driver that has dedicated @p fx buffers
* (but only if \setting{audio_jack_multi} is true). All other drivers do not provide @p fx buffers.
* In this case, users are encouraged to mix the effects into the provided dry buffers when calling
* fluid_synth_process().
* @code{.cpp}
int myCallback(void *, int len, int nfx, float *fx[], int nout, float *out[])
{
int ret;
if(nfx == 0)
{
float *fxb[4] = {out[0], out[1], out[0], out[1]};
ret = fluid_synth_process(synth, len, sizeof(fxb) / sizeof(fxb[0]), fxb, nout, out);
}
else
{
ret = fluid_synth_process(synth, len, nfx, fx, nout, out);
}
// ... client-code ...
return ret;
}
* @endcode
* For other possible use-cases refer to \ref fluidsynth_process.c .
* @endparblock
*/ */
typedef int (*fluid_audio_func_t)(void *data, int len, typedef int (*fluid_audio_func_t)(void *data, int len,
int nfx, float *fx[], int nfx, float *fx[],
int nout, float *out[]); int nout, float *out[]);
/** @startlifecycle{Audio Driver} */
FLUIDSYNTH_API fluid_audio_driver_t *new_fluid_audio_driver(fluid_settings_t *settings, FLUIDSYNTH_API fluid_audio_driver_t *new_fluid_audio_driver(fluid_settings_t *settings,
fluid_synth_t *synth); fluid_synth_t *synth);
@ -69,13 +117,36 @@ FLUIDSYNTH_API fluid_audio_driver_t *new_fluid_audio_driver2(fluid_settings_t *s
void *data); void *data);
FLUIDSYNTH_API void delete_fluid_audio_driver(fluid_audio_driver_t *driver); FLUIDSYNTH_API void delete_fluid_audio_driver(fluid_audio_driver_t *driver);
/** @endlifecycle */
FLUIDSYNTH_API fluid_file_renderer_t *new_fluid_file_renderer(fluid_synth_t *synth);
FLUIDSYNTH_API int fluid_file_renderer_process_block(fluid_file_renderer_t *dev);
FLUIDSYNTH_API void delete_fluid_file_renderer(fluid_file_renderer_t *dev);
FLUIDSYNTH_API int fluid_file_set_encoding_quality(fluid_file_renderer_t *dev, double q);
FLUIDSYNTH_API int fluid_audio_driver_register(const char **adrivers); FLUIDSYNTH_API int fluid_audio_driver_register(const char **adrivers);
/* @} */
/**
* @defgroup file_renderer File Renderer
* @ingroup audio_output
*
* Functions for managing file renderers and triggering the rendering.
*
* The file renderer is only used to render a MIDI file to audio as fast
* as possible. Please see \ref FileRenderer for a full example.
*
* If you are looking for a way to write audio generated
* from real-time events (for example from an external sequencer or a MIDI controller) to a file,
* please have a look at the \c file \ref audio_driver instead.
*
*
* @{
*/
/** @startlifecycle{File Renderer} */
FLUIDSYNTH_API fluid_file_renderer_t *new_fluid_file_renderer(fluid_synth_t *synth);
FLUIDSYNTH_API void delete_fluid_file_renderer(fluid_file_renderer_t *dev);
/** @endlifecycle */
FLUIDSYNTH_API int fluid_file_renderer_process_block(fluid_file_renderer_t *dev);
FLUIDSYNTH_API int fluid_file_set_encoding_quality(fluid_file_renderer_t *dev, double q);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -26,10 +26,12 @@ extern "C" {
#endif #endif
/** /**
* @file event.h * @defgroup sequencer_events Sequencer Events
* @brief Sequencer event functions and defines. * @ingroup sequencer
* *
* Functions and constants for creating/processing sequencer events. * Create, modify, query and destroy sequencer events.
*
* @{
*/ */
/** /**
@ -55,19 +57,21 @@ enum fluid_seq_event_type
FLUID_SEQ_REVERBSEND, /**< Reverb send set event */ FLUID_SEQ_REVERBSEND, /**< Reverb send set event */
FLUID_SEQ_CHORUSSEND, /**< Chorus send set event */ FLUID_SEQ_CHORUSSEND, /**< Chorus send set event */
FLUID_SEQ_TIMER, /**< Timer event (useful for giving a callback at a certain time) */ FLUID_SEQ_TIMER, /**< Timer event (useful for giving a callback at a certain time) */
FLUID_SEQ_ANYCONTROLCHANGE, /**< Any control change message (only internally used for remove_events) */
FLUID_SEQ_CHANNELPRESSURE, /**< Channel aftertouch event @since 1.1.0 */ FLUID_SEQ_CHANNELPRESSURE, /**< Channel aftertouch event @since 1.1.0 */
FLUID_SEQ_KEYPRESSURE, /**< Polyphonic aftertouch event @since 2.0.0 */ FLUID_SEQ_KEYPRESSURE, /**< Polyphonic aftertouch event @since 2.0.0 */
FLUID_SEQ_SYSTEMRESET, /**< System reset event @since 1.1.0 */ FLUID_SEQ_SYSTEMRESET, /**< System reset event @since 1.1.0 */
FLUID_SEQ_UNREGISTERING, /**< Called when a sequencer client is being unregistered. @since 1.1.0 */ FLUID_SEQ_UNREGISTERING, /**< Called when a sequencer client is being unregistered. @since 1.1.0 */
#ifndef __DOXYGEN__ FLUID_SEQ_SCALE, /**< Sets a new time scale for the sequencer @since 2.2.0 */
FLUID_SEQ_LASTEVENT /**< @internal Defines the count of events enums @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */ FLUID_SEQ_LASTEVENT /**< @internal Defines the count of events enums @warning This symbol
#endif is not part of the public API and ABI stability guarantee and
may change at any time! */
}; };
/* Event alloc/free */ /* Event alloc/free */
/** @startlifecycle{Sequencer Event} */
FLUIDSYNTH_API fluid_event_t *new_fluid_event(void); FLUIDSYNTH_API fluid_event_t *new_fluid_event(void);
FLUIDSYNTH_API void delete_fluid_event(fluid_event_t *evt); FLUIDSYNTH_API void delete_fluid_event(fluid_event_t *evt);
/** @endlifecycle */
/* Initializing events */ /* Initializing events */
FLUIDSYNTH_API void fluid_event_set_source(fluid_event_t *evt, fluid_seq_id_t src); FLUIDSYNTH_API void fluid_event_set_source(fluid_event_t *evt, fluid_seq_id_t src);
@ -88,34 +92,32 @@ FLUIDSYNTH_API void fluid_event_all_notes_off(fluid_event_t *evt, int channel);
/* Instrument selection */ /* Instrument selection */
FLUIDSYNTH_API void fluid_event_bank_select(fluid_event_t *evt, int channel, short bank_num); FLUIDSYNTH_API void fluid_event_bank_select(fluid_event_t *evt, int channel, short bank_num);
FLUIDSYNTH_API void fluid_event_program_change(fluid_event_t *evt, int channel, short preset_num); FLUIDSYNTH_API void fluid_event_program_change(fluid_event_t *evt, int channel, int preset_num);
FLUIDSYNTH_API void fluid_event_program_select(fluid_event_t *evt, int channel, unsigned int sfont_id, short bank_num, short preset_num); FLUIDSYNTH_API void fluid_event_program_select(fluid_event_t *evt, int channel, unsigned int sfont_id, short bank_num, short preset_num);
/* Real-time generic instrument controllers */ /* Real-time generic instrument controllers */
FLUIDSYNTH_API FLUIDSYNTH_API
void fluid_event_control_change(fluid_event_t *evt, int channel, short control, short val); void fluid_event_control_change(fluid_event_t *evt, int channel, short control, int val);
/* Real-time instrument controllers shortcuts */ /* Real-time instrument controllers shortcuts */
FLUIDSYNTH_API void fluid_event_pitch_bend(fluid_event_t *evt, int channel, int val); FLUIDSYNTH_API void fluid_event_pitch_bend(fluid_event_t *evt, int channel, int val);
FLUIDSYNTH_API void fluid_event_pitch_wheelsens(fluid_event_t *evt, int channel, short val); FLUIDSYNTH_API void fluid_event_pitch_wheelsens(fluid_event_t *evt, int channel, int val);
FLUIDSYNTH_API void fluid_event_modulation(fluid_event_t *evt, int channel, short val); FLUIDSYNTH_API void fluid_event_modulation(fluid_event_t *evt, int channel, int val);
FLUIDSYNTH_API void fluid_event_sustain(fluid_event_t *evt, int channel, short val); FLUIDSYNTH_API void fluid_event_sustain(fluid_event_t *evt, int channel, int val);
FLUIDSYNTH_API void fluid_event_pan(fluid_event_t *evt, int channel, short val); FLUIDSYNTH_API void fluid_event_pan(fluid_event_t *evt, int channel, int val);
FLUIDSYNTH_API void fluid_event_volume(fluid_event_t *evt, int channel, short val); FLUIDSYNTH_API void fluid_event_volume(fluid_event_t *evt, int channel, int val);
FLUIDSYNTH_API void fluid_event_reverb_send(fluid_event_t *evt, int channel, short val); FLUIDSYNTH_API void fluid_event_reverb_send(fluid_event_t *evt, int channel, int val);
FLUIDSYNTH_API void fluid_event_chorus_send(fluid_event_t *evt, int channel, short val); FLUIDSYNTH_API void fluid_event_chorus_send(fluid_event_t *evt, int channel, int val);
FLUIDSYNTH_API void fluid_event_key_pressure(fluid_event_t *evt, int channel, short key, short val); FLUIDSYNTH_API void fluid_event_key_pressure(fluid_event_t *evt, int channel, short key, int val);
FLUIDSYNTH_API void fluid_event_channel_pressure(fluid_event_t *evt, int channel, short val); FLUIDSYNTH_API void fluid_event_channel_pressure(fluid_event_t *evt, int channel, int val);
FLUIDSYNTH_API void fluid_event_system_reset(fluid_event_t *evt); FLUIDSYNTH_API void fluid_event_system_reset(fluid_event_t *evt);
/* Only for removing events */
FLUID_DEPRECATED FLUIDSYNTH_API void fluid_event_any_control_change(fluid_event_t *evt, int channel);
/* Only when unregistering clients */ /* Only when unregistering clients */
FLUIDSYNTH_API void fluid_event_unregistering(fluid_event_t *evt); FLUIDSYNTH_API void fluid_event_unregistering(fluid_event_t *evt);
FLUIDSYNTH_API void fluid_event_scale(fluid_event_t *evt, double new_scale);
/* Accessing event data */ /* Accessing event data */
FLUIDSYNTH_API int fluid_event_get_type(fluid_event_t *evt); FLUIDSYNTH_API int fluid_event_get_type(fluid_event_t *evt);
FLUIDSYNTH_API fluid_seq_id_t fluid_event_get_source(fluid_event_t *evt); FLUIDSYNTH_API fluid_seq_id_t fluid_event_get_source(fluid_event_t *evt);
@ -124,13 +126,15 @@ FLUIDSYNTH_API int fluid_event_get_channel(fluid_event_t *evt);
FLUIDSYNTH_API short fluid_event_get_key(fluid_event_t *evt); FLUIDSYNTH_API short fluid_event_get_key(fluid_event_t *evt);
FLUIDSYNTH_API short fluid_event_get_velocity(fluid_event_t *evt); FLUIDSYNTH_API short fluid_event_get_velocity(fluid_event_t *evt);
FLUIDSYNTH_API short fluid_event_get_control(fluid_event_t *evt); FLUIDSYNTH_API short fluid_event_get_control(fluid_event_t *evt);
FLUIDSYNTH_API short fluid_event_get_value(fluid_event_t *evt); FLUIDSYNTH_API int fluid_event_get_value(fluid_event_t *evt);
FLUIDSYNTH_API short fluid_event_get_program(fluid_event_t *evt); FLUIDSYNTH_API int fluid_event_get_program(fluid_event_t *evt);
FLUIDSYNTH_API void *fluid_event_get_data(fluid_event_t *evt); FLUIDSYNTH_API void *fluid_event_get_data(fluid_event_t *evt);
FLUIDSYNTH_API unsigned int fluid_event_get_duration(fluid_event_t *evt); FLUIDSYNTH_API unsigned int fluid_event_get_duration(fluid_event_t *evt);
FLUIDSYNTH_API short fluid_event_get_bank(fluid_event_t *evt); FLUIDSYNTH_API short fluid_event_get_bank(fluid_event_t *evt);
FLUIDSYNTH_API int fluid_event_get_pitch(fluid_event_t *evt); FLUIDSYNTH_API int fluid_event_get_pitch(fluid_event_t *evt);
FLUIDSYNTH_API double fluid_event_get_scale(fluid_event_t *evt);
FLUIDSYNTH_API unsigned int fluid_event_get_sfont_id(fluid_event_t *evt); FLUIDSYNTH_API unsigned int fluid_event_get_sfont_id(fluid_event_t *evt);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

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

View file

@ -26,16 +26,19 @@ extern "C" {
#endif #endif
/** /**
* @file ladspa.h * @defgroup ladspa Effect - LADSPA
* @brief Functions for manipulating the ladspa effects unit * @ingroup synth
*
* Functions for configuring the LADSPA effects unit
* *
* This header defines useful functions for programmatically manipulating the ladspa * This header defines useful functions for programmatically manipulating the ladspa
* effects unit of the synth that can be retrieved via fluid_synth_get_ladspa_fx(). * effects unit of the synth that can be retrieved via fluid_synth_get_ladspa_fx().
* *
* Using any of those functions requires fluidsynth to be compiled with ladspa support. * Using any of those functions requires fluidsynth to be compiled with LADSPA support.
* Else all of those functions are useless dummies. * Else all of those functions are useless dummies.
*
* @{
*/ */
FLUIDSYNTH_API int fluid_ladspa_is_active(fluid_ladspa_fx_t *fx); FLUIDSYNTH_API int fluid_ladspa_is_active(fluid_ladspa_fx_t *fx);
FLUIDSYNTH_API int fluid_ladspa_activate(fluid_ladspa_fx_t *fx); FLUIDSYNTH_API int fluid_ladspa_activate(fluid_ladspa_fx_t *fx);
FLUIDSYNTH_API int fluid_ladspa_deactivate(fluid_ladspa_fx_t *fx); FLUIDSYNTH_API int fluid_ladspa_deactivate(fluid_ladspa_fx_t *fx);
@ -56,6 +59,7 @@ FLUIDSYNTH_API int fluid_ladspa_effect_set_control(fluid_ladspa_fx_t *fx, const
const char *port_name, float val); const char *port_name, float val);
FLUIDSYNTH_API int fluid_ladspa_effect_link(fluid_ladspa_fx_t *fx, const char *effect_name, FLUIDSYNTH_API int fluid_ladspa_effect_link(fluid_ladspa_fx_t *fx, const char *effect_name,
const char *port_name, const char *name); const char *port_name, const char *name);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -28,25 +28,31 @@ extern "C" {
/** /**
* @file log.h * @defgroup logging Logging
* @brief Logging interface
* *
* The default logging function of the fluidsynth prints its messages * Logging interface
* to the stderr. The synthesizer uses five level of messages: #FLUID_PANIC, *
* The default logging function of the fluidsynth prints its messages to the
* stderr. The synthesizer uses five level of messages: #FLUID_PANIC,
* #FLUID_ERR, #FLUID_WARN, #FLUID_INFO, and #FLUID_DBG. * #FLUID_ERR, #FLUID_WARN, #FLUID_INFO, and #FLUID_DBG.
* *
* A client application can install a new log function to handle the * A client application can install a new log function to handle the messages
* messages differently. In the following example, the application * differently. In the following example, the application sets a callback
* sets a callback function to display #FLUID_PANIC messages in a dialog, * function to display #FLUID_PANIC messages in a dialog, and ignores all other
* and ignores all other messages by setting the log function to * messages by setting the log function to NULL:
* NULL:
* *
* @code * @code
* fluid_set_log_function(FLUID_PANIC, show_dialog, (void*) root_window); * fluid_set_log_function(FLUID_PANIC, show_dialog, (void*) root_window);
* fluid_set_log_function(FLUID_ERR, NULL, NULL); * fluid_set_log_function(FLUID_ERR, NULL, NULL);
* fluid_set_log_function(FLUID_WARN, NULL, NULL); * fluid_set_log_function(FLUID_WARN, NULL, NULL);
* fluid_set_log_function(FLUID_DBG, NULL, NULL); * fluid_set_log_function(FLUID_DBG, NULL, NULL);
* @endcode * @endcode
*
* @note The logging configuration is global and not tied to a specific
* synthesizer instance. That means that all synthesizer instances created in
* the same process share the same logging configuration.
*
* @{
*/ */
/** /**
@ -59,13 +65,13 @@ enum fluid_log_level
FLUID_WARN, /**< Warning */ FLUID_WARN, /**< Warning */
FLUID_INFO, /**< Verbose informational messages */ FLUID_INFO, /**< Verbose informational messages */
FLUID_DBG, /**< Debugging messages */ FLUID_DBG, /**< Debugging messages */
#ifndef __DOXYGEN__ LAST_LOG_LEVEL /**< @internal This symbol is not part of the public API and ABI
LAST_LOG_LEVEL /**< @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */ stability guarantee and may change at any time! */
#endif
}; };
/** /**
* Log function handler callback type used by fluid_set_log_function(). * Log function handler callback type used by fluid_set_log_function().
*
* @param level Log level (#fluid_log_level) * @param level Log level (#fluid_log_level)
* @param message Log message text * @param message Log message text
* @param data User data pointer supplied to fluid_set_log_function(). * @param data User data pointer supplied to fluid_set_log_function().
@ -82,7 +88,7 @@ FLUIDSYNTH_API int fluid_log(int level, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3))) __attribute__ ((format (printf, 2, 3)))
#endif #endif
; ;
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -26,12 +26,92 @@ extern "C" {
#endif #endif
/** /**
* @file midi.h * @defgroup midi_input MIDI Input
* @brief Functions for MIDI events, drivers and MIDI file playback. *
* MIDI Input Subsystem
*
* There are multiple ways to send MIDI events to the synthesizer. They can come
* from MIDI files, from external MIDI sequencers or raw MIDI event sources,
* can be modified via MIDI routers and also generated manually.
*
* The interface connecting all sources and sinks of MIDI events in libfluidsynth
* is \ref handle_midi_event_func_t.
*
* @{
*/ */
/**
* Generic callback function for MIDI event handler.
*
* @param data User defined data pointer
* @param event The MIDI event
* @return Should return #FLUID_OK on success, #FLUID_FAILED otherwise
*
* This callback is used to pass MIDI events
* - from \ref midi_player, \ref midi_router or \ref midi_driver
* - to \ref midi_router via fluid_midi_router_handle_midi_event()
* - or to \ref synth via fluid_synth_handle_midi_event().
*
* Additionally, there is a translation layer to pass MIDI events to
* a \ref sequencer via fluid_sequencer_add_midi_event_to_buffer().
*/
typedef int (*handle_midi_event_func_t)(void *data, fluid_midi_event_t *event);
/**
* Generic callback function fired once by MIDI tick change.
*
* @param data User defined data pointer
* @param tick The current (zero-based) tick, which triggered the callback
* @return Should return #FLUID_OK on success, #FLUID_FAILED otherwise
*
* This callback is fired at a constant rate depending on the current BPM and PPQ.
* e.g. for PPQ = 192 and BPM = 140 the callback is fired 192 * 140 times per minute (448/sec).
*
* It can be used to sync external elements with the beat,
* or stop / loop the song on a given tick.
* Ticks being BPM-dependent, you can manipulate values such as bars or beats,
* without having to care about BPM.
*
* For example, this callback loops the song whenever it reaches the 5th bar :
*
* @code{.cpp}
int handle_tick(void *data, int tick)
{
fluid_player_t *player = (fluid_player_t *)data;
int ppq = 192; // From MIDI header
int beatsPerBar = 4; // From the song's time signature
int loopBar = 5;
int loopTick = (loopBar - 1) * ppq * beatsPerBar;
if (tick == loopTick)
{
return fluid_player_seek(player, 0);
}
return FLUID_OK;
}
* @endcode
*/
typedef int (*handle_midi_tick_func_t)(void *data, int tick);
/* @} */
/**
* @defgroup midi_events MIDI Events
* @ingroup midi_input
*
* Functions to create, modify, query and delete MIDI events.
*
* These functions are intended to be used in MIDI routers and other filtering
* and processing functions in the MIDI event path. If you want to simply
* send MIDI messages to the synthesizer, you can use the more convenient
* \ref midi_messages interface.
*
* @{
*/
/** @startlifecycle{MIDI Event} */
FLUIDSYNTH_API fluid_midi_event_t *new_fluid_midi_event(void); FLUIDSYNTH_API fluid_midi_event_t *new_fluid_midi_event(void);
FLUIDSYNTH_API void delete_fluid_midi_event(fluid_midi_event_t *event); FLUIDSYNTH_API void delete_fluid_midi_event(fluid_midi_event_t *event);
/** @endlifecycle */
FLUIDSYNTH_API int fluid_midi_event_set_type(fluid_midi_event_t *evt, int type); FLUIDSYNTH_API int fluid_midi_event_set_type(fluid_midi_event_t *evt, int type);
FLUIDSYNTH_API int fluid_midi_event_get_type(fluid_midi_event_t *evt); FLUIDSYNTH_API int fluid_midi_event_get_type(fluid_midi_event_t *evt);
@ -59,9 +139,20 @@ FLUIDSYNTH_API int fluid_midi_event_set_lyrics(fluid_midi_event_t *evt,
void *data, int size, int dynamic); void *data, int size, int dynamic);
FLUIDSYNTH_API int fluid_midi_event_get_lyrics(fluid_midi_event_t *evt, FLUIDSYNTH_API int fluid_midi_event_get_lyrics(fluid_midi_event_t *evt,
void **data, int *size); void **data, int *size);
/* @} */
/**
* @defgroup midi_router MIDI Router
* @ingroup midi_input
*
* Rule based tranformation and filtering of MIDI events.
*
* @{
*/
/** /**
* MIDI router rule type. * MIDI router rule type.
*
* @since 1.1.0 * @since 1.1.0
*/ */
typedef enum typedef enum
@ -72,35 +163,30 @@ typedef enum
FLUID_MIDI_ROUTER_RULE_PITCH_BEND, /**< MIDI pitch bend rule */ FLUID_MIDI_ROUTER_RULE_PITCH_BEND, /**< MIDI pitch bend rule */
FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE, /**< MIDI channel pressure rule */ FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE, /**< MIDI channel pressure rule */
FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE, /**< MIDI key pressure rule */ FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE, /**< MIDI key pressure rule */
#ifndef __DOXYGEN__ FLUID_MIDI_ROUTER_RULE_COUNT /**< @internal Total count of rule types. This symbol
FLUID_MIDI_ROUTER_RULE_COUNT /**< @internal Total count of rule types @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time!*/ is not part of the public API and ABI stability
#endif guarantee and may change at any time!*/
} fluid_midi_router_rule_type; } fluid_midi_router_rule_type;
/**
* Generic callback function for MIDI events.
* @param data User defined data pointer
* @param event The MIDI event
* @return Should return #FLUID_OK on success, #FLUID_FAILED otherwise
*
* Will be used between
* - MIDI driver and MIDI router
* - MIDI router and synth
* to communicate events.
* In the not-so-far future...
*/
typedef int (*handle_midi_event_func_t)(void *data, fluid_midi_event_t *event);
/** @startlifecycle{MIDI Router} */
FLUIDSYNTH_API fluid_midi_router_t *new_fluid_midi_router(fluid_settings_t *settings, FLUIDSYNTH_API fluid_midi_router_t *new_fluid_midi_router(fluid_settings_t *settings,
handle_midi_event_func_t handler, handle_midi_event_func_t handler,
void *event_handler_data); void *event_handler_data);
FLUIDSYNTH_API void delete_fluid_midi_router(fluid_midi_router_t *handler); FLUIDSYNTH_API void delete_fluid_midi_router(fluid_midi_router_t *handler);
/** @endlifecycle */
FLUIDSYNTH_API int fluid_midi_router_set_default_rules(fluid_midi_router_t *router); FLUIDSYNTH_API int fluid_midi_router_set_default_rules(fluid_midi_router_t *router);
FLUIDSYNTH_API int fluid_midi_router_clear_rules(fluid_midi_router_t *router); FLUIDSYNTH_API int fluid_midi_router_clear_rules(fluid_midi_router_t *router);
FLUIDSYNTH_API int fluid_midi_router_add_rule(fluid_midi_router_t *router, FLUIDSYNTH_API int fluid_midi_router_add_rule(fluid_midi_router_t *router,
fluid_midi_router_rule_t *rule, int type); fluid_midi_router_rule_t *rule, int type);
/** @startlifecycle{MIDI Router Rule} */
FLUIDSYNTH_API fluid_midi_router_rule_t *new_fluid_midi_router_rule(void); FLUIDSYNTH_API fluid_midi_router_rule_t *new_fluid_midi_router_rule(void);
FLUIDSYNTH_API void delete_fluid_midi_router_rule(fluid_midi_router_rule_t *rule); FLUIDSYNTH_API void delete_fluid_midi_router_rule(fluid_midi_router_rule_t *rule);
/** @endlifecycle */
FLUIDSYNTH_API void fluid_midi_router_rule_set_chan(fluid_midi_router_rule_t *rule, FLUIDSYNTH_API void fluid_midi_router_rule_set_chan(fluid_midi_router_rule_t *rule,
int min, int max, float mul, int add); int min, int max, float mul, int add);
FLUIDSYNTH_API void fluid_midi_router_rule_set_param1(fluid_midi_router_rule_t *rule, FLUIDSYNTH_API void fluid_midi_router_rule_set_param1(fluid_midi_router_rule_t *rule,
@ -110,38 +196,88 @@ FLUIDSYNTH_API void fluid_midi_router_rule_set_param2(fluid_midi_router_rule_t *
FLUIDSYNTH_API int fluid_midi_router_handle_midi_event(void *data, fluid_midi_event_t *event); FLUIDSYNTH_API int fluid_midi_router_handle_midi_event(void *data, fluid_midi_event_t *event);
FLUIDSYNTH_API int fluid_midi_dump_prerouter(void *data, fluid_midi_event_t *event); FLUIDSYNTH_API int fluid_midi_dump_prerouter(void *data, fluid_midi_event_t *event);
FLUIDSYNTH_API int fluid_midi_dump_postrouter(void *data, fluid_midi_event_t *event); FLUIDSYNTH_API int fluid_midi_dump_postrouter(void *data, fluid_midi_event_t *event);
/* @} */
/**
* @defgroup midi_driver MIDI Driver
* @ingroup midi_input
*
* Functions for managing MIDI drivers.
*
* The available MIDI drivers depend on your platform. See \ref settings_midi for all
* available configuration options.
*
* To create a MIDI driver, you need to specify a source for the MIDI events to be
* forwarded to via the \ref fluid_midi_event_t callback. Normally this will be
* either a \ref midi_router via fluid_midi_router_handle_midi_event() or the synthesizer
* via fluid_synth_handle_midi_event().
*
* But you can also write your own handler function that preprocesses the events and
* forwards them on to the router or synthesizer instead.
*
* @{
*/
/** @startlifecycle{MIDI Driver} */
FLUIDSYNTH_API FLUIDSYNTH_API
fluid_midi_driver_t *new_fluid_midi_driver(fluid_settings_t *settings, fluid_midi_driver_t *new_fluid_midi_driver(fluid_settings_t *settings,
handle_midi_event_func_t handler, handle_midi_event_func_t handler,
void *event_handler_data); void *event_handler_data);
FLUIDSYNTH_API void delete_fluid_midi_driver(fluid_midi_driver_t *driver); FLUIDSYNTH_API void delete_fluid_midi_driver(fluid_midi_driver_t *driver);
/** @endlifecycle */
/* @} */
/** /**
* MIDI player status enum. * @defgroup midi_player MIDI File Player
* @ingroup midi_input
*
* Parse standard MIDI files and emit MIDI events.
*
* @{
*/
/**
* MIDI File Player status enum.
* @since 1.1.0 * @since 1.1.0
*/ */
enum fluid_player_status enum fluid_player_status
{ {
FLUID_PLAYER_READY, /**< Player is ready */ FLUID_PLAYER_READY, /**< Player is ready */
FLUID_PLAYER_PLAYING, /**< Player is currently playing */ FLUID_PLAYER_PLAYING, /**< Player is currently playing */
FLUID_PLAYER_STOPPING, /**< Player is stopping, but hasn't finished yet */
FLUID_PLAYER_DONE /**< Player is finished playing */ FLUID_PLAYER_DONE /**< Player is finished playing */
}; };
/**
* MIDI File Player tempo enum.
* @since 2.2.0
*/
enum fluid_player_set_tempo_type
{
FLUID_PLAYER_TEMPO_INTERNAL, /**< Use midi file tempo set in midi file (120 bpm by default). Multiplied by a factor */
FLUID_PLAYER_TEMPO_EXTERNAL_BPM, /**< Set player tempo in bpm, supersede midi file tempo */
FLUID_PLAYER_TEMPO_EXTERNAL_MIDI, /**< Set player tempo in us per quarter note, supersede midi file tempo */
FLUID_PLAYER_TEMPO_NBR /**< @internal Value defines the count of player tempo type (#fluid_player_set_tempo_type) @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */
};
/** @startlifecycle{MIDI File Player} */
FLUIDSYNTH_API fluid_player_t *new_fluid_player(fluid_synth_t *synth); FLUIDSYNTH_API fluid_player_t *new_fluid_player(fluid_synth_t *synth);
FLUIDSYNTH_API void delete_fluid_player(fluid_player_t *player); FLUIDSYNTH_API void delete_fluid_player(fluid_player_t *player);
/** @endlifecycle */
FLUIDSYNTH_API int fluid_player_add(fluid_player_t *player, const char *midifile); FLUIDSYNTH_API int fluid_player_add(fluid_player_t *player, const char *midifile);
FLUIDSYNTH_API int fluid_player_add_mem(fluid_player_t *player, const void *buffer, size_t len); FLUIDSYNTH_API int fluid_player_add_mem(fluid_player_t *player, const void *buffer, size_t len);
FLUIDSYNTH_API int fluid_player_play(fluid_player_t *player); FLUIDSYNTH_API int fluid_player_play(fluid_player_t *player);
FLUIDSYNTH_API int fluid_player_stop(fluid_player_t *player); FLUIDSYNTH_API int fluid_player_stop(fluid_player_t *player);
FLUIDSYNTH_API int fluid_player_join(fluid_player_t *player); FLUIDSYNTH_API int fluid_player_join(fluid_player_t *player);
FLUIDSYNTH_API int fluid_player_set_loop(fluid_player_t *player, int loop); FLUIDSYNTH_API int fluid_player_set_loop(fluid_player_t *player, int loop);
FLUIDSYNTH_API int fluid_player_set_midi_tempo(fluid_player_t *player, int tempo); FLUIDSYNTH_API int fluid_player_set_tempo(fluid_player_t *player, int tempo_type, double tempo);
FLUIDSYNTH_API int fluid_player_set_bpm(fluid_player_t *player, int bpm); FLUID_DEPRECATED FLUIDSYNTH_API int fluid_player_set_midi_tempo(fluid_player_t *player, int tempo);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_player_set_bpm(fluid_player_t *player, int bpm);
FLUIDSYNTH_API int fluid_player_set_playback_callback(fluid_player_t *player, handle_midi_event_func_t handler, void *handler_data); FLUIDSYNTH_API int fluid_player_set_playback_callback(fluid_player_t *player, handle_midi_event_func_t handler, void *handler_data);
FLUIDSYNTH_API int fluid_player_set_tick_callback(fluid_player_t *player, handle_midi_tick_func_t handler, void *handler_data);
FLUIDSYNTH_API int fluid_player_get_status(fluid_player_t *player); FLUIDSYNTH_API int fluid_player_get_status(fluid_player_t *player);
FLUIDSYNTH_API int fluid_player_get_current_tick(fluid_player_t *player); FLUIDSYNTH_API int fluid_player_get_current_tick(fluid_player_t *player);
@ -149,8 +285,7 @@ FLUIDSYNTH_API int fluid_player_get_total_ticks(fluid_player_t *player);
FLUIDSYNTH_API int fluid_player_get_bpm(fluid_player_t *player); FLUIDSYNTH_API int fluid_player_get_bpm(fluid_player_t *player);
FLUIDSYNTH_API int fluid_player_get_midi_tempo(fluid_player_t *player); FLUIDSYNTH_API int fluid_player_get_midi_tempo(fluid_player_t *player);
FLUIDSYNTH_API int fluid_player_seek(fluid_player_t *player, int ticks); FLUIDSYNTH_API int fluid_player_seek(fluid_player_t *player, int ticks);
/* @} */
///
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -28,13 +28,15 @@ extern "C" {
/** /**
* @file misc.h * @defgroup misc Miscellaneous
* @brief Miscellaneous utility functions and defines *
* Miscellaneous utility functions and defines
*
* @{
*/ */
/** /**
* Value that indicates success, used by most libfluidsynth functions. * Value that indicates success, used by most libfluidsynth functions.
* @since 1.1.0
* *
* @note This was not publicly defined prior to libfluidsynth 1.1.0. When * @note This was not publicly defined prior to libfluidsynth 1.1.0. When
* writing code which should also be compatible with older versions, something * writing code which should also be compatible with older versions, something
@ -48,14 +50,17 @@ extern "C" {
* #define FLUID_FAILED (-1) * #define FLUID_FAILED (-1)
* #endif * #endif
* @endcode * @endcode
*
* @since 1.1.0
*/ */
#define FLUID_OK (0) #define FLUID_OK (0)
/** /**
* Value that indicates failure, used by most libfluidsynth functions. * Value that indicates failure, used by most libfluidsynth functions.
* @since 1.1.0
* *
* @note See #FLUID_OK for more details. * @note See #FLUID_OK for more details.
*
* @since 1.1.0
*/ */
#define FLUID_FAILED (-1) #define FLUID_FAILED (-1)
@ -63,7 +68,7 @@ extern "C" {
FLUIDSYNTH_API int fluid_is_soundfont(const char *filename); FLUIDSYNTH_API int fluid_is_soundfont(const char *filename);
FLUIDSYNTH_API int fluid_is_midifile(const char *filename); FLUIDSYNTH_API int fluid_is_midifile(const char *filename);
FLUIDSYNTH_API void fluid_free(void* ptr); FLUIDSYNTH_API void fluid_free(void* ptr);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -26,11 +26,14 @@ extern "C" {
#endif #endif
/** /**
* @file mod.h * @defgroup modulators SoundFont Modulators
* @brief SoundFont modulator functions and constants. * @ingroup soundfonts
*
* SoundFont modulator functions and constants.
*
* @{
*/ */
/** /**
* Flags defining the polarity, mapping function and type of a modulator source. * Flags defining the polarity, mapping function and type of a modulator source.
* Compare with SoundFont 2.04 PDF section 8.2. * Compare with SoundFont 2.04 PDF section 8.2.
@ -69,8 +72,11 @@ enum fluid_mod_src
FLUID_MOD_PITCHWHEELSENS = 16 /**< Pitch wheel sensitivity */ FLUID_MOD_PITCHWHEELSENS = 16 /**< Pitch wheel sensitivity */
}; };
/** @startlifecycle{Modulator} */
FLUIDSYNTH_API fluid_mod_t *new_fluid_mod(void); FLUIDSYNTH_API fluid_mod_t *new_fluid_mod(void);
FLUIDSYNTH_API void delete_fluid_mod(fluid_mod_t *mod); FLUIDSYNTH_API void delete_fluid_mod(fluid_mod_t *mod);
/** @endlifecycle */
FLUIDSYNTH_API size_t fluid_mod_sizeof(void); FLUIDSYNTH_API size_t fluid_mod_sizeof(void);
FLUIDSYNTH_API void fluid_mod_set_source1(fluid_mod_t *mod, int src, int flags); FLUIDSYNTH_API void fluid_mod_set_source1(fluid_mod_t *mod, int src, int flags);
@ -90,6 +96,7 @@ 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 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); FLUIDSYNTH_API void fluid_mod_clone(fluid_mod_t *mod, const fluid_mod_t *src);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -26,12 +26,21 @@ extern "C" {
#endif #endif
/** /**
* @file seq.h * @defgroup sequencer MIDI Sequencer
* @brief MIDI event sequencer. *
* MIDI event sequencer.
*
* The MIDI sequencer can be used to play MIDI events in a more flexible way than
* using the MIDI file player, which expects the events to be stored as
* Standard MIDI Files. Using the sequencer, you can provide the events one by
* one, with an optional timestamp for scheduling.
*
* @{
*/ */
/** /**
* Event callback prototype for destination clients. * Event callback prototype for destination clients.
*
* @param time Current sequencer tick value (see fluid_sequencer_get_tick()). * @param time Current sequencer tick value (see fluid_sequencer_get_tick()).
* @param event The event being received * @param event The event being received
* @param seq The sequencer instance * @param seq The sequencer instance
@ -41,9 +50,12 @@ typedef void (*fluid_event_callback_t)(unsigned int time, fluid_event_t *event,
fluid_sequencer_t *seq, void *data); fluid_sequencer_t *seq, void *data);
/** @startlifecycle{MIDI Sequencer} */
FLUID_DEPRECATED FLUIDSYNTH_API fluid_sequencer_t *new_fluid_sequencer(void); FLUID_DEPRECATED FLUIDSYNTH_API fluid_sequencer_t *new_fluid_sequencer(void);
FLUIDSYNTH_API fluid_sequencer_t *new_fluid_sequencer2(int use_system_timer); FLUIDSYNTH_API fluid_sequencer_t *new_fluid_sequencer2(int use_system_timer);
FLUIDSYNTH_API void delete_fluid_sequencer(fluid_sequencer_t *seq); FLUIDSYNTH_API void delete_fluid_sequencer(fluid_sequencer_t *seq);
/** @endlifecycle */
FLUIDSYNTH_API int fluid_sequencer_get_use_system_timer(fluid_sequencer_t *seq); FLUIDSYNTH_API int fluid_sequencer_get_use_system_timer(fluid_sequencer_t *seq);
FLUIDSYNTH_API FLUIDSYNTH_API
fluid_seq_id_t fluid_sequencer_register_client(fluid_sequencer_t *seq, const char *name, fluid_seq_id_t fluid_sequencer_register_client(fluid_sequencer_t *seq, const char *name,
@ -63,6 +75,7 @@ void fluid_sequencer_remove_events(fluid_sequencer_t *seq, fluid_seq_id_t source
FLUIDSYNTH_API unsigned int fluid_sequencer_get_tick(fluid_sequencer_t *seq); FLUIDSYNTH_API unsigned int fluid_sequencer_get_tick(fluid_sequencer_t *seq);
FLUIDSYNTH_API void fluid_sequencer_set_time_scale(fluid_sequencer_t *seq, double scale); FLUIDSYNTH_API void fluid_sequencer_set_time_scale(fluid_sequencer_t *seq, double scale);
FLUIDSYNTH_API double fluid_sequencer_get_time_scale(fluid_sequencer_t *seq); FLUIDSYNTH_API double fluid_sequencer_get_time_scale(fluid_sequencer_t *seq);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -28,15 +28,15 @@ extern "C" {
#endif #endif
/** /**
* @file seqbind.h * @addtogroup sequencer
* @brief Functions for binding sequencer objects to other subsystems. *
* @{
*/ */
FLUIDSYNTH_API FLUIDSYNTH_API
fluid_seq_id_t fluid_sequencer_register_fluidsynth(fluid_sequencer_t *seq, fluid_synth_t *synth); fluid_seq_id_t fluid_sequencer_register_fluidsynth(fluid_sequencer_t *seq, fluid_synth_t *synth);
FLUIDSYNTH_API int FLUIDSYNTH_API int
fluid_sequencer_add_midi_event_to_buffer(void *data, fluid_midi_event_t *event); fluid_sequencer_add_midi_event_to_buffer(void *data, fluid_midi_event_t *event);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -26,9 +26,9 @@ extern "C" {
#endif #endif
/** /**
* @file settings.h * @defgroup settings Settings
* @brief Synthesizer settings *
* @defgroup SettingsFunctions Functions for settings management * Functions for settings management
* *
* To create a synthesizer object you will have to specify its * To create a synthesizer object you will have to specify its
* settings. These settings are stored in a fluid_settings_t object. * settings. These settings are stored in a fluid_settings_t object.
@ -49,6 +49,8 @@ extern "C" {
* } * }
* @endcode * @endcode
* @sa @ref CreatingSettings * @sa @ref CreatingSettings
*
* @{
*/ */
/** /**
@ -97,9 +99,10 @@ enum fluid_types_enum
FLUID_SET_TYPE /**< Set of values */ FLUID_SET_TYPE /**< Set of values */
}; };
/** @startlifecycle{Settings} */
FLUIDSYNTH_API fluid_settings_t *new_fluid_settings(void); FLUIDSYNTH_API fluid_settings_t *new_fluid_settings(void);
FLUIDSYNTH_API void delete_fluid_settings(fluid_settings_t *settings); FLUIDSYNTH_API void delete_fluid_settings(fluid_settings_t *settings);
/** @endlifecycle */
FLUIDSYNTH_API FLUIDSYNTH_API
int fluid_settings_get_type(fluid_settings_t *settings, const char *name); int fluid_settings_get_type(fluid_settings_t *settings, const char *name);
@ -153,6 +156,7 @@ int fluid_settings_getint_range(fluid_settings_t *settings, const char *name,
/** /**
* Callback function type used with fluid_settings_foreach_option() * Callback function type used with fluid_settings_foreach_option()
*
* @param data User defined data pointer * @param data User defined data pointer
* @param name Setting name * @param name Setting name
* @param option A string option for this setting (iterates through the list) * @param option A string option for this setting (iterates through the list)
@ -171,6 +175,7 @@ FLUIDSYNTH_API char *fluid_settings_option_concat(fluid_settings_t *settings,
/** /**
* Callback function type used with fluid_settings_foreach() * Callback function type used with fluid_settings_foreach()
*
* @param data User defined data pointer * @param data User defined data pointer
* @param name Setting name * @param name Setting name
* @param type Setting type (#fluid_types_enum) * @param type Setting type (#fluid_types_enum)
@ -180,6 +185,7 @@ typedef void (*fluid_settings_foreach_t)(void *data, const char *name, int type)
FLUIDSYNTH_API FLUIDSYNTH_API
void fluid_settings_foreach(fluid_settings_t *settings, void *data, void fluid_settings_foreach(fluid_settings_t *settings, void *data,
fluid_settings_foreach_t func); fluid_settings_foreach_t func);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -25,10 +25,21 @@
extern "C" { extern "C" {
#endif #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.
*/
/** /**
* @file sfont.h * @defgroup soundfont_loader SoundFont Loader
* @brief SoundFont plugins * @ingroup soundfonts
*
* Create custom SoundFont loaders
* *
* It is possible to add new SoundFont loaders to the * It is possible to add new SoundFont loaders to the
* synthesizer. This API allows for virtual SoundFont files to be loaded * synthesizer. This API allows for virtual SoundFont files to be loaded
@ -59,6 +70,8 @@ extern "C" {
* generator, use fluid_voice_gen_set() or fluid_voice_gen_incr(). When you are * generator, use fluid_voice_gen_set() or fluid_voice_gen_incr(). When you are
* finished initializing the voice call fluid_voice_start() to * finished initializing the voice call fluid_voice_start() to
* start playing the synthesis voice. * start playing the synthesis voice.
*
* @{
*/ */
/** /**
@ -68,11 +81,14 @@ enum
{ {
FLUID_PRESET_SELECTED, /**< Preset selected notify */ FLUID_PRESET_SELECTED, /**< Preset selected notify */
FLUID_PRESET_UNSELECTED, /**< Preset unselected notify */ FLUID_PRESET_UNSELECTED, /**< Preset unselected notify */
FLUID_SAMPLE_DONE /**< Sample no longer needed notify */ FLUID_SAMPLE_DONE, /**< Sample no longer needed notify */
FLUID_PRESET_PIN, /**< Request to pin preset samples to cache */
FLUID_PRESET_UNPIN /**< Request to unpin preset samples from cache */
}; };
/** /**
* Indicates the type of a sample used by the _fluid_sample_t::sampletype field. * 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. * 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. * One \c flag may be bit-wise OR-ed with one \c value.
*/ */
@ -90,6 +106,7 @@ enum fluid_sample_type
/** /**
* Method to load an instrument file (does not actually need to be a real file name, * 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). * could be another type of string identifier that the \a loader understands).
*
* @param loader SoundFont loader * @param loader SoundFont loader
* @param filename File name or other string identifier * @param filename File name or other string identifier
* @return The loaded instrument file (SoundFont) or NULL if an error occurred. * @return The loaded instrument file (SoundFont) or NULL if an error occurred.
@ -98,24 +115,31 @@ 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 * 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 * 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. * 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); typedef void (*fluid_sfloader_free_t)(fluid_sfloader_t *loader);
/** @startlifecycle{SoundFont Loader} */
FLUIDSYNTH_API fluid_sfloader_t *new_fluid_sfloader(fluid_sfloader_load_t load, fluid_sfloader_free_t free); FLUIDSYNTH_API fluid_sfloader_t *new_fluid_sfloader(fluid_sfloader_load_t load, fluid_sfloader_free_t free);
FLUIDSYNTH_API void delete_fluid_sfloader(fluid_sfloader_t *loader); FLUIDSYNTH_API void delete_fluid_sfloader(fluid_sfloader_t *loader);
FLUIDSYNTH_API fluid_sfloader_t *new_fluid_defsfloader(fluid_settings_t *settings); FLUIDSYNTH_API fluid_sfloader_t *new_fluid_defsfloader(fluid_settings_t *settings);
/** @endlifecycle */
/** /**
* Opens the file or memory indicated by \c filename in binary read mode. * 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 * @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); typedef void *(* fluid_sfloader_callback_open_t)(const char *filename);
@ -124,16 +148,15 @@ typedef void *(* fluid_sfloader_callback_open_t)(const char *filename);
* *
* @return returns #FLUID_OK if exactly \c count bytes were successfully read, else returns #FLUID_FAILED and leaves \a buf unmodified. * @return returns #FLUID_OK if exactly \c count bytes were successfully read, else returns #FLUID_FAILED and leaves \a buf unmodified.
*/ */
typedef int (* fluid_sfloader_callback_read_t)(void *buf, int count, void *handle); typedef int (* fluid_sfloader_callback_read_t)(void *buf, fluid_long_long_t count, void *handle);
/** /**
* Same purpose and behaviour as fseek. * Same purpose and behaviour as fseek.
* *
* @param origin either \c SEEK_SET, \c SEEK_CUR or \c SEEK_END * @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 * @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, long offset, int origin); typedef int (* fluid_sfloader_callback_seek_t)(void *handle, fluid_long_long_t offset, int origin);
/** /**
* Closes the handle returned by #fluid_sfloader_callback_open_t and frees used resources. * Closes the handle returned by #fluid_sfloader_callback_open_t and frees used resources.
@ -143,7 +166,7 @@ typedef int (* fluid_sfloader_callback_seek_t)(void *handle, long offset, int or
typedef int (* fluid_sfloader_callback_close_t)(void *handle); typedef int (* fluid_sfloader_callback_close_t)(void *handle);
/** @return returns current file offset or #FLUID_FAILED on error */ /** @return returns current file offset or #FLUID_FAILED on error */
typedef long (* fluid_sfloader_callback_tell_t)(void *handle); typedef fluid_long_long_t (* fluid_sfloader_callback_tell_t)(void *handle);
FLUIDSYNTH_API int fluid_sfloader_set_callbacks(fluid_sfloader_t *loader, FLUIDSYNTH_API int fluid_sfloader_set_callbacks(fluid_sfloader_t *loader,
@ -160,6 +183,7 @@ FLUIDSYNTH_API void *fluid_sfloader_get_data(fluid_sfloader_t *loader);
/** /**
* Method to return the name of a virtual SoundFont. * Method to return the name of a virtual SoundFont.
*
* @param sfont Virtual SoundFont * @param sfont Virtual SoundFont
* @return The name of the virtual SoundFont. * @return The name of the virtual SoundFont.
*/ */
@ -167,6 +191,7 @@ typedef const char *(*fluid_sfont_get_name_t)(fluid_sfont_t *sfont);
/** /**
* Get a virtual SoundFont preset by bank and program numbers. * Get a virtual SoundFont preset by bank and program numbers.
*
* @param sfont Virtual SoundFont * @param sfont Virtual SoundFont
* @param bank MIDI bank number (0-16383) * @param bank MIDI bank number (0-16383)
* @param prenum MIDI preset number (0-127) * @param prenum MIDI preset number (0-127)
@ -177,6 +202,7 @@ typedef fluid_preset_t *(*fluid_sfont_get_preset_t)(fluid_sfont_t *sfont, int ba
/** /**
* Start virtual SoundFont preset iteration method. * Start virtual SoundFont preset iteration method.
*
* @param sfont Virtual SoundFont * @param sfont Virtual SoundFont
* *
* Starts/re-starts virtual preset iteration in a SoundFont. * Starts/re-starts virtual preset iteration in a SoundFont.
@ -185,6 +211,7 @@ typedef void (*fluid_sfont_iteration_start_t)(fluid_sfont_t *sfont);
/** /**
* Virtual SoundFont preset iteration function. * Virtual SoundFont preset iteration function.
*
* @param sfont Virtual SoundFont * @param sfont Virtual SoundFont
* @return NULL when no more presets are available, otherwise the a pointer to the current preset * @return NULL when no more presets are available, otherwise the a pointer to the current preset
* *
@ -194,17 +221,21 @@ typedef void (*fluid_sfont_iteration_start_t)(fluid_sfont_t *sfont);
typedef fluid_preset_t *(*fluid_sfont_iteration_next_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 * Method to free a virtual SoundFont bank.
* 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.
* @param sfont Virtual SoundFont to free. * @param sfont Virtual SoundFont to free.
* @return Should return 0 when it was able to free all resources or non-zero * @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, * 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. * 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); typedef int (*fluid_sfont_free_t)(fluid_sfont_t *sfont);
/** @startlifecycle{SoundFont} */
FLUIDSYNTH_API fluid_sfont_t *new_fluid_sfont(fluid_sfont_get_name_t get_name, FLUIDSYNTH_API fluid_sfont_t *new_fluid_sfont(fluid_sfont_get_name_t get_name,
fluid_sfont_get_preset_t get_preset, fluid_sfont_get_preset_t get_preset,
fluid_sfont_iteration_start_t iter_start, fluid_sfont_iteration_start_t iter_start,
@ -212,6 +243,7 @@ FLUIDSYNTH_API fluid_sfont_t *new_fluid_sfont(fluid_sfont_get_name_t get_name,
fluid_sfont_free_t free); fluid_sfont_free_t free);
FLUIDSYNTH_API int delete_fluid_sfont(fluid_sfont_t *sfont); FLUIDSYNTH_API int delete_fluid_sfont(fluid_sfont_t *sfont);
/** @endlifecycle */
FLUIDSYNTH_API int fluid_sfont_set_data(fluid_sfont_t *sfont, void *data); 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 void *fluid_sfont_get_data(fluid_sfont_t *sfont);
@ -224,6 +256,7 @@ FLUIDSYNTH_API fluid_preset_t *fluid_sfont_iteration_next(fluid_sfont_t *sfont);
/** /**
* Method to get a virtual SoundFont preset name. * Method to get a virtual SoundFont preset name.
*
* @param preset Virtual SoundFont preset * @param preset Virtual SoundFont preset
* @return Should return the name of the preset. The returned string must be * @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 * valid for the duration of the virtual preset (or the duration of the
@ -233,6 +266,7 @@ typedef const char *(*fluid_preset_get_name_t)(fluid_preset_t *preset);
/** /**
* Method to get a virtual SoundFont preset MIDI bank number. * Method to get a virtual SoundFont preset MIDI bank number.
*
* @param preset Virtual SoundFont preset * @param preset Virtual SoundFont preset
* @param return The bank number of the preset * @param return The bank number of the preset
*/ */
@ -240,6 +274,7 @@ typedef int (*fluid_preset_get_banknum_t)(fluid_preset_t *preset);
/** /**
* Method to get a virtual SoundFont preset MIDI program number. * Method to get a virtual SoundFont preset MIDI program number.
*
* @param preset Virtual SoundFont preset * @param preset Virtual SoundFont preset
* @param return The program number of the preset * @param return The program number of the preset
*/ */
@ -247,6 +282,7 @@ typedef int (*fluid_preset_get_num_t)(fluid_preset_t *preset);
/** /**
* Method to handle a noteon event (synthesize the instrument). * Method to handle a noteon event (synthesize the instrument).
*
* @param preset Virtual SoundFont preset * @param preset Virtual SoundFont preset
* @param synth Synthesizer instance * @param synth Synthesizer instance
* @param chan MIDI channel number of the note on event * @param chan MIDI channel number of the note on event
@ -270,14 +306,18 @@ 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); 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 * Method to free a virtual SoundFont preset.
* 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.
* @param preset Virtual SoundFont preset * @param preset Virtual SoundFont preset
* @return Should return 0 * @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); typedef void (*fluid_preset_free_t)(fluid_preset_t *preset);
/** @startlifecycle{Preset} */
FLUIDSYNTH_API fluid_preset_t *new_fluid_preset(fluid_sfont_t *parent_sfont, FLUIDSYNTH_API fluid_preset_t *new_fluid_preset(fluid_sfont_t *parent_sfont,
fluid_preset_get_name_t get_name, fluid_preset_get_name_t get_name,
fluid_preset_get_banknum_t get_bank, fluid_preset_get_banknum_t get_bank,
@ -285,6 +325,7 @@ FLUIDSYNTH_API fluid_preset_t *new_fluid_preset(fluid_sfont_t *parent_sfont,
fluid_preset_noteon_t noteon, fluid_preset_noteon_t noteon,
fluid_preset_free_t free); fluid_preset_free_t free);
FLUIDSYNTH_API void delete_fluid_preset(fluid_preset_t *preset); FLUIDSYNTH_API void delete_fluid_preset(fluid_preset_t *preset);
/** @endlifecycle */
FLUIDSYNTH_API int fluid_preset_set_data(fluid_preset_t *preset, void *data); FLUIDSYNTH_API int fluid_preset_set_data(fluid_preset_t *preset, void *data);
FLUIDSYNTH_API void *fluid_preset_get_data(fluid_preset_t *preset); FLUIDSYNTH_API void *fluid_preset_get_data(fluid_preset_t *preset);
@ -294,8 +335,11 @@ FLUIDSYNTH_API int fluid_preset_get_banknum(fluid_preset_t *preset);
FLUIDSYNTH_API int fluid_preset_get_num(fluid_preset_t *preset); FLUIDSYNTH_API int fluid_preset_get_num(fluid_preset_t *preset);
FLUIDSYNTH_API fluid_sfont_t *fluid_preset_get_sfont(fluid_preset_t *preset); FLUIDSYNTH_API fluid_sfont_t *fluid_preset_get_sfont(fluid_preset_t *preset);
/** @startlifecycle{Sample} */
FLUIDSYNTH_API fluid_sample_t *new_fluid_sample(void); FLUIDSYNTH_API fluid_sample_t *new_fluid_sample(void);
FLUIDSYNTH_API void delete_fluid_sample(fluid_sample_t *sample); FLUIDSYNTH_API void delete_fluid_sample(fluid_sample_t *sample);
/** @endlifecycle */
FLUIDSYNTH_API size_t fluid_sample_sizeof(void); FLUIDSYNTH_API size_t fluid_sample_sizeof(void);
FLUIDSYNTH_API int fluid_sample_set_name(fluid_sample_t *sample, const char *name); FLUIDSYNTH_API int fluid_sample_set_name(fluid_sample_t *sample, const char *name);
@ -309,6 +353,8 @@ FLUIDSYNTH_API int fluid_sample_set_sound_data(fluid_sample_t *sample,
FLUIDSYNTH_API int fluid_sample_set_loop(fluid_sample_t *sample, unsigned int loop_start, unsigned int loop_end); FLUIDSYNTH_API int fluid_sample_set_loop(fluid_sample_t *sample, unsigned int loop_start, unsigned int loop_end);
FLUIDSYNTH_API int fluid_sample_set_pitch(fluid_sample_t *sample, int root_key, int fine_tune); FLUIDSYNTH_API int fluid_sample_set_pitch(fluid_sample_t *sample, int root_key, int fine_tune);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -28,67 +28,120 @@ extern "C" {
/** /**
* @file shell.h * @defgroup command_interface Command Interface
* @brief Command shell interface
* *
* The shell interface allows you to send simple textual commands to * Control and configuration interface
*
* The command interface allows you to send textual commands to
* the synthesizer, to parse a command file, or to read commands * the synthesizer, to parse a command file, or to read commands
* from the stdin or other input streams. * from the stdin or other input streams (like a TCP socket).
*
* For a full list of available commands, type \c help in the
* \ref command_shell or send the same command via a command handler.
* Further documentation can be found at
* https://github.com/FluidSynth/fluidsynth/wiki/UserManual#shell-commands
*
* @{
*/ */
FLUIDSYNTH_API fluid_istream_t fluid_get_stdin(void); FLUIDSYNTH_API fluid_istream_t fluid_get_stdin(void);
FLUIDSYNTH_API fluid_ostream_t fluid_get_stdout(void); FLUIDSYNTH_API fluid_ostream_t fluid_get_stdout(void);
FLUIDSYNTH_API char *fluid_get_userconf(char *buf, int len); FLUIDSYNTH_API char *fluid_get_userconf(char *buf, int len);
FLUIDSYNTH_API char *fluid_get_sysconf(char *buf, int len); FLUIDSYNTH_API char *fluid_get_sysconf(char *buf, int len);
/* @} */
/* The command handler */ /**
* @defgroup command_handler Command Handler
* @ingroup command_interface
* @brief Handles text commands and reading of configuration files
*
* @{
*/
/** @startlifecycle{Command Handler} */
FLUIDSYNTH_API FLUIDSYNTH_API
fluid_cmd_handler_t *new_fluid_cmd_handler(fluid_synth_t *synth, fluid_midi_router_t *router); fluid_cmd_handler_t *new_fluid_cmd_handler(fluid_synth_t *synth, fluid_midi_router_t *router);
FLUIDSYNTH_API
fluid_cmd_handler_t *new_fluid_cmd_handler2(fluid_settings_t *settings, fluid_synth_t *synth,
fluid_midi_router_t *router, fluid_player_t *player);
FLUIDSYNTH_API FLUIDSYNTH_API
void delete_fluid_cmd_handler(fluid_cmd_handler_t *handler); void delete_fluid_cmd_handler(fluid_cmd_handler_t *handler);
/** @endlifecycle */
FLUIDSYNTH_API FLUIDSYNTH_API
void fluid_cmd_handler_set_synth(fluid_cmd_handler_t *handler, fluid_synth_t *synth); void fluid_cmd_handler_set_synth(fluid_cmd_handler_t *handler, fluid_synth_t *synth);
/* Command function */
FLUIDSYNTH_API FLUIDSYNTH_API
int fluid_command(fluid_cmd_handler_t *handler, const char *cmd, fluid_ostream_t out); int fluid_command(fluid_cmd_handler_t *handler, const char *cmd, fluid_ostream_t out);
FLUIDSYNTH_API FLUIDSYNTH_API
int fluid_source(fluid_cmd_handler_t *handler, const char *filename); int fluid_source(fluid_cmd_handler_t *handler, const char *filename);
/* @} */
FLUIDSYNTH_API
void fluid_usershell(fluid_settings_t *settings, fluid_cmd_handler_t *handler);
/* Shell */ /**
* @defgroup command_shell Command Shell
* @ingroup command_interface
*
* Interactive shell to control and configure a synthesizer instance.
*
* If you need a platform independent way to get the standard input
* and output streams, use fluid_get_stdin() and fluid_get_stdout().
*
* For a full list of available commands, type \c help in the shell.
*
* @{
*/
/** @startlifecycle{Command Shell} */
FLUIDSYNTH_API FLUIDSYNTH_API
fluid_shell_t *new_fluid_shell(fluid_settings_t *settings, fluid_cmd_handler_t *handler, fluid_shell_t *new_fluid_shell(fluid_settings_t *settings, fluid_cmd_handler_t *handler,
fluid_istream_t in, fluid_ostream_t out, int thread); fluid_istream_t in, fluid_ostream_t out, int thread);
FLUIDSYNTH_API
void fluid_usershell(fluid_settings_t *settings, fluid_cmd_handler_t *handler);
FLUIDSYNTH_API void delete_fluid_shell(fluid_shell_t *shell); FLUIDSYNTH_API void delete_fluid_shell(fluid_shell_t *shell);
/** @endlifecycle */
/* @} */
/**
* @defgroup command_server Command Server
* @ingroup command_interface
*
* TCP socket server for a command handler.
*
* The socket server will open the TCP port set by \ref settings_shell_port
* (default 9800) and starts a new thread and \ref command_handler for each
* incoming connection.
*
* @note The server is only available if libfluidsynth has been compiled
* with network support (enable-network). Without network support, all related
* functions will return FLUID_FAILED or NULL.
*
* @{
*/
/* TCP/IP server */ /** @startlifecycle{Command Server} */
FLUIDSYNTH_API FLUIDSYNTH_API
fluid_server_t *new_fluid_server(fluid_settings_t *settings, fluid_server_t *new_fluid_server(fluid_settings_t *settings,
fluid_synth_t *synth, fluid_midi_router_t *router); fluid_synth_t *synth, fluid_midi_router_t *router);
FLUIDSYNTH_API
fluid_server_t *new_fluid_server2(fluid_settings_t *settings,
fluid_synth_t *synth, fluid_midi_router_t *router,
fluid_player_t *player);
FLUIDSYNTH_API void delete_fluid_server(fluid_server_t *server); FLUIDSYNTH_API void delete_fluid_server(fluid_server_t *server);
FLUIDSYNTH_API int fluid_server_join(fluid_server_t *server); FLUIDSYNTH_API int fluid_server_join(fluid_server_t *server);
/** @endlifecycle */
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -28,8 +28,9 @@ extern "C" {
/** /**
* @file synth.h * @defgroup synth Synthesizer
* @brief Embeddable SoundFont synthesizer *
* SoundFont synthesizer
* *
* You create a new synthesizer with new_fluid_synth() and you destroy * You create a new synthesizer with new_fluid_synth() and you destroy
* it with delete_fluid_synth(). Use the fluid_settings_t structure to specify * it with delete_fluid_synth(). Use the fluid_settings_t structure to specify
@ -43,15 +44,29 @@ extern "C" {
* *
* The API for sending MIDI events is probably what you expect: * The API for sending MIDI events is probably what you expect:
* fluid_synth_noteon(), fluid_synth_noteoff(), ... * fluid_synth_noteon(), fluid_synth_noteoff(), ...
*
* @{
*/ */
/** @startlifecycle{Synthesizer} */
FLUIDSYNTH_API fluid_synth_t *new_fluid_synth(fluid_settings_t *settings); FLUIDSYNTH_API fluid_synth_t *new_fluid_synth(fluid_settings_t *settings);
FLUIDSYNTH_API void delete_fluid_synth(fluid_synth_t *synth); FLUIDSYNTH_API void delete_fluid_synth(fluid_synth_t *synth);
FLUIDSYNTH_API fluid_settings_t *fluid_synth_get_settings(fluid_synth_t *synth); /** @endlifecycle */
/* MIDI channel messages */ FLUIDSYNTH_API double fluid_synth_get_cpu_load(fluid_synth_t *synth);
FLUID_DEPRECATED FLUIDSYNTH_API const char *fluid_synth_error(fluid_synth_t *synth);
/* @} */
/**
* @defgroup midi_messages MIDI Channel Messages
* @ingroup synth
*
* The MIDI channel message functions are mostly directly named after their
* counterpart MIDI messages. They are a high-level interface to controlling
* the synthesizer, playing notes and changing note and channel parameters.
*
* @{
*/
FLUIDSYNTH_API int fluid_synth_noteon(fluid_synth_t *synth, int chan, int key, int vel); FLUIDSYNTH_API int fluid_synth_noteon(fluid_synth_t *synth, int chan, int key, int vel);
FLUIDSYNTH_API int fluid_synth_noteoff(fluid_synth_t *synth, int chan, int key); FLUIDSYNTH_API int fluid_synth_noteoff(fluid_synth_t *synth, int chan, int key);
FLUIDSYNTH_API int fluid_synth_cc(fluid_synth_t *synth, int chan, int ctrl, int val); FLUIDSYNTH_API int fluid_synth_cc(fluid_synth_t *synth, int chan, int ctrl, int val);
@ -84,28 +99,42 @@ FLUIDSYNTH_API int fluid_synth_system_reset(fluid_synth_t *synth);
FLUIDSYNTH_API int fluid_synth_all_notes_off(fluid_synth_t *synth, int chan); FLUIDSYNTH_API int fluid_synth_all_notes_off(fluid_synth_t *synth, int chan);
FLUIDSYNTH_API int fluid_synth_all_sounds_off(fluid_synth_t *synth, int chan); FLUIDSYNTH_API int fluid_synth_all_sounds_off(fluid_synth_t *synth, int chan);
FLUIDSYNTH_API int fluid_synth_set_gen(fluid_synth_t *synth, int chan,
int param, float value);
FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t *synth, int chan, int param);
/* @} MIDI Channel Messages */
/** /**
* The midi channel type used by fluid_synth_set_channel_type() * @defgroup voice_control Synthesis Voice Control
* @ingroup synth
*
* Low-level access to synthesis voices.
*
* @{
*/ */
enum fluid_midi_channel_type
{
CHANNEL_TYPE_MELODIC = 0, /**< Melodic midi channel */
CHANNEL_TYPE_DRUM = 1 /**< Drum midi channel */
};
FLUIDSYNTH_API int fluid_synth_set_channel_type(fluid_synth_t *synth, int chan, int type);
/* Low level access */
FLUIDSYNTH_API fluid_preset_t *fluid_synth_get_channel_preset(fluid_synth_t *synth, int chan);
FLUIDSYNTH_API int fluid_synth_start(fluid_synth_t *synth, unsigned int id, FLUIDSYNTH_API int fluid_synth_start(fluid_synth_t *synth, unsigned int id,
fluid_preset_t *preset, int audio_chan, fluid_preset_t *preset, int audio_chan,
int midi_chan, int key, int vel); int midi_chan, int key, int vel);
FLUIDSYNTH_API int fluid_synth_stop(fluid_synth_t *synth, unsigned int id); FLUIDSYNTH_API int fluid_synth_stop(fluid_synth_t *synth, unsigned int id);
FLUIDSYNTH_API fluid_voice_t *fluid_synth_alloc_voice(fluid_synth_t *synth,
fluid_sample_t *sample,
int channum, int key, int vel);
FLUIDSYNTH_API void fluid_synth_start_voice(fluid_synth_t *synth, fluid_voice_t *voice);
FLUIDSYNTH_API void fluid_synth_get_voicelist(fluid_synth_t *synth,
fluid_voice_t *buf[], int bufsize, int ID);
/* @} Voice Control */
/* SoundFont management */
/**
* @defgroup soundfont_management SoundFont Management
* @ingroup synth
*
* Functions to load and unload SoundFonts.
*
* @{
*/
FLUIDSYNTH_API FLUIDSYNTH_API
int fluid_synth_sfload(fluid_synth_t *synth, const char *filename, int reset_presets); int fluid_synth_sfload(fluid_synth_t *synth, const char *filename, int reset_presets);
FLUIDSYNTH_API int fluid_synth_sfreload(fluid_synth_t *synth, int id); FLUIDSYNTH_API int fluid_synth_sfreload(fluid_synth_t *synth, int id);
@ -119,26 +148,52 @@ FLUIDSYNTH_API fluid_sfont_t *fluid_synth_get_sfont_by_name(fluid_synth_t *synth
const char *name); const char *name);
FLUIDSYNTH_API int fluid_synth_set_bank_offset(fluid_synth_t *synth, int sfont_id, int offset); FLUIDSYNTH_API int fluid_synth_set_bank_offset(fluid_synth_t *synth, int sfont_id, int offset);
FLUIDSYNTH_API int fluid_synth_get_bank_offset(fluid_synth_t *synth, int sfont_id); FLUIDSYNTH_API int fluid_synth_get_bank_offset(fluid_synth_t *synth, int sfont_id);
/* @} Soundfont Management */
/* Reverb */ /**
* @defgroup reverb_effect Effect - Reverb
* @ingroup synth
*
* Functions for configuring the built-in reverb effect
*
* @{
*/
FLUID_DEPRECATED FLUIDSYNTH_API void fluid_synth_set_reverb_on(fluid_synth_t *synth, int on);
FLUIDSYNTH_API int fluid_synth_reverb_on(fluid_synth_t *synth, int fx_group, int on);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_reverb(fluid_synth_t *synth, double roomsize,
double damping, double width, double level);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_reverb_roomsize(fluid_synth_t *synth, double roomsize);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_reverb_damp(fluid_synth_t *synth, double damping);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_reverb_width(fluid_synth_t *synth, double width);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_reverb_level(fluid_synth_t *synth, double level);
FLUID_DEPRECATED FLUIDSYNTH_API double fluid_synth_get_reverb_roomsize(fluid_synth_t *synth);
FLUID_DEPRECATED FLUIDSYNTH_API double fluid_synth_get_reverb_damp(fluid_synth_t *synth);
FLUID_DEPRECATED FLUIDSYNTH_API double fluid_synth_get_reverb_level(fluid_synth_t *synth);
FLUID_DEPRECATED FLUIDSYNTH_API double fluid_synth_get_reverb_width(fluid_synth_t *synth);
FLUIDSYNTH_API int fluid_synth_set_reverb_group_roomsize(fluid_synth_t *synth, int fx_group, double roomsize);
FLUIDSYNTH_API int fluid_synth_set_reverb_group_damp(fluid_synth_t *synth, int fx_group, double damping);
FLUIDSYNTH_API int fluid_synth_set_reverb_group_width(fluid_synth_t *synth, int fx_group, double width);
FLUIDSYNTH_API int fluid_synth_set_reverb_group_level(fluid_synth_t *synth, int fx_group, double level);
FLUIDSYNTH_API int fluid_synth_get_reverb_group_roomsize(fluid_synth_t *synth, int fx_group, double *roomsize);
FLUIDSYNTH_API int fluid_synth_get_reverb_group_damp(fluid_synth_t *synth, int fx_group, double *damping);
FLUIDSYNTH_API int fluid_synth_get_reverb_group_width(fluid_synth_t *synth, int fx_group, double *width);
FLUIDSYNTH_API int fluid_synth_get_reverb_group_level(fluid_synth_t *synth, int fx_group, double *level);
/* @} Reverb */
FLUIDSYNTH_API int fluid_synth_set_reverb(fluid_synth_t *synth, double roomsize, /**
double damping, double width, double level); * @defgroup chorus_effect Effect - Chorus
FLUIDSYNTH_API int fluid_synth_set_reverb_roomsize(fluid_synth_t *synth, double roomsize); * @ingroup synth
FLUIDSYNTH_API int fluid_synth_set_reverb_damp(fluid_synth_t *synth, double damping); *
FLUIDSYNTH_API int fluid_synth_set_reverb_width(fluid_synth_t *synth, double width); * Functions for configuring the built-in chorus effect
FLUIDSYNTH_API int fluid_synth_set_reverb_level(fluid_synth_t *synth, double level); *
* @{
FLUIDSYNTH_API void fluid_synth_set_reverb_on(fluid_synth_t *synth, int on); */
FLUIDSYNTH_API double fluid_synth_get_reverb_roomsize(fluid_synth_t *synth);
FLUIDSYNTH_API double fluid_synth_get_reverb_damp(fluid_synth_t *synth);
FLUIDSYNTH_API double fluid_synth_get_reverb_level(fluid_synth_t *synth);
FLUIDSYNTH_API double fluid_synth_get_reverb_width(fluid_synth_t *synth);
/* Chorus */
/** /**
* Chorus modulation waveform type. * Chorus modulation waveform type.
@ -149,33 +204,52 @@ enum fluid_chorus_mod
FLUID_CHORUS_MOD_TRIANGLE = 1 /**< Triangle wave chorus modulation */ FLUID_CHORUS_MOD_TRIANGLE = 1 /**< Triangle wave chorus modulation */
}; };
FLUIDSYNTH_API int fluid_synth_set_chorus(fluid_synth_t *synth, int nr, double level,
double speed, double depth_ms, int type);
FLUIDSYNTH_API int fluid_synth_set_chorus_nr(fluid_synth_t *synth, int nr);
FLUIDSYNTH_API int fluid_synth_set_chorus_level(fluid_synth_t *synth, double level);
FLUIDSYNTH_API int fluid_synth_set_chorus_speed(fluid_synth_t *synth, double speed);
FLUIDSYNTH_API int fluid_synth_set_chorus_depth(fluid_synth_t *synth, double depth_ms);
FLUIDSYNTH_API int fluid_synth_set_chorus_type(fluid_synth_t *synth, int type);
FLUIDSYNTH_API void fluid_synth_set_chorus_on(fluid_synth_t *synth, int on); FLUID_DEPRECATED FLUIDSYNTH_API void fluid_synth_set_chorus_on(fluid_synth_t *synth, int on);
FLUIDSYNTH_API int fluid_synth_get_chorus_nr(fluid_synth_t *synth); FLUIDSYNTH_API int fluid_synth_chorus_on(fluid_synth_t *synth, int fx_group, int on);
FLUIDSYNTH_API double fluid_synth_get_chorus_level(fluid_synth_t *synth);
FLUIDSYNTH_API double fluid_synth_get_chorus_speed(fluid_synth_t *synth);
FLUIDSYNTH_API double fluid_synth_get_chorus_depth(fluid_synth_t *synth);
FLUIDSYNTH_API int fluid_synth_get_chorus_type(fluid_synth_t *synth); /* see fluid_chorus_mod */
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_chorus(fluid_synth_t *synth, int nr, double level,
double speed, double depth_ms, int type);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_chorus_nr(fluid_synth_t *synth, int nr);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_chorus_level(fluid_synth_t *synth, double level);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_chorus_speed(fluid_synth_t *synth, double speed);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_chorus_depth(fluid_synth_t *synth, double depth_ms);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_set_chorus_type(fluid_synth_t *synth, int type);
/* Audio and MIDI channels */ FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_get_chorus_nr(fluid_synth_t *synth);
FLUID_DEPRECATED FLUIDSYNTH_API double fluid_synth_get_chorus_level(fluid_synth_t *synth);
FLUID_DEPRECATED FLUIDSYNTH_API double fluid_synth_get_chorus_speed(fluid_synth_t *synth);
FLUID_DEPRECATED FLUIDSYNTH_API double fluid_synth_get_chorus_depth(fluid_synth_t *synth);
FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_get_chorus_type(fluid_synth_t *synth); /* see fluid_chorus_mod */
FLUIDSYNTH_API int fluid_synth_set_chorus_group_nr(fluid_synth_t *synth, int fx_group, int nr);
FLUIDSYNTH_API int fluid_synth_set_chorus_group_level(fluid_synth_t *synth, int fx_group, double level);
FLUIDSYNTH_API int fluid_synth_set_chorus_group_speed(fluid_synth_t *synth, int fx_group, double speed);
FLUIDSYNTH_API int fluid_synth_set_chorus_group_depth(fluid_synth_t *synth, int fx_group, double depth_ms);
FLUIDSYNTH_API int fluid_synth_set_chorus_group_type(fluid_synth_t *synth, int fx_group, int type);
FLUIDSYNTH_API int fluid_synth_get_chorus_group_nr(fluid_synth_t *synth, int fx_group, int *nr);
FLUIDSYNTH_API int fluid_synth_get_chorus_group_level(fluid_synth_t *synth, int fx_group, double *level);
FLUIDSYNTH_API int fluid_synth_get_chorus_group_speed(fluid_synth_t *synth, int fx_group, double *speed);
FLUIDSYNTH_API int fluid_synth_get_chorus_group_depth(fluid_synth_t *synth, int fx_group, double *depth_ms);
FLUIDSYNTH_API int fluid_synth_get_chorus_group_type(fluid_synth_t *synth, int fx_group, int *type);
/* @} Chorus */
/**
* @defgroup synthesis_params Synthesis Parameters
* @ingroup synth
*
* Functions to control and query synthesis parameters like gain and
* polyphony count.
*
* @{
*/
FLUIDSYNTH_API int fluid_synth_count_midi_channels(fluid_synth_t *synth); FLUIDSYNTH_API int fluid_synth_count_midi_channels(fluid_synth_t *synth);
FLUIDSYNTH_API int fluid_synth_count_audio_channels(fluid_synth_t *synth); FLUIDSYNTH_API int fluid_synth_count_audio_channels(fluid_synth_t *synth);
FLUIDSYNTH_API int fluid_synth_count_audio_groups(fluid_synth_t *synth); FLUIDSYNTH_API int fluid_synth_count_audio_groups(fluid_synth_t *synth);
FLUIDSYNTH_API int fluid_synth_count_effects_channels(fluid_synth_t *synth); FLUIDSYNTH_API int fluid_synth_count_effects_channels(fluid_synth_t *synth);
FLUIDSYNTH_API int fluid_synth_count_effects_groups(fluid_synth_t *synth); FLUIDSYNTH_API int fluid_synth_count_effects_groups(fluid_synth_t *synth);
/* Synthesis parameters */
FLUID_DEPRECATED FLUIDSYNTH_API void fluid_synth_set_sample_rate(fluid_synth_t *synth, float sample_rate); FLUID_DEPRECATED FLUIDSYNTH_API void fluid_synth_set_sample_rate(fluid_synth_t *synth, float sample_rate);
FLUIDSYNTH_API void fluid_synth_set_gain(fluid_synth_t *synth, float gain); FLUIDSYNTH_API void fluid_synth_set_gain(fluid_synth_t *synth, float gain);
FLUIDSYNTH_API float fluid_synth_get_gain(fluid_synth_t *synth); FLUIDSYNTH_API float fluid_synth_get_gain(fluid_synth_t *synth);
@ -201,15 +275,28 @@ enum fluid_interp
FLUID_INTERP_HIGHEST = FLUID_INTERP_7THORDER, /**< Highest interpolation method */ FLUID_INTERP_HIGHEST = FLUID_INTERP_7THORDER, /**< Highest interpolation method */
}; };
/* Generator interface */ /**
* Enum used with fluid_synth_add_default_mod() to specify how to handle duplicate modulators.
*/
enum fluid_synth_add_mod
{
FLUID_SYNTH_OVERWRITE, /**< Overwrite any existing matching modulator */
FLUID_SYNTH_ADD, /**< Sum up modulator amounts */
};
FLUIDSYNTH_API int fluid_synth_set_gen(fluid_synth_t *synth, int chan, FLUIDSYNTH_API int fluid_synth_add_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod, int mode);
int param, float value); FLUIDSYNTH_API int fluid_synth_remove_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod);
FLUIDSYNTH_API float fluid_synth_get_gen(fluid_synth_t *synth, int chan, int param); /* @} Synthesis Parameters */
/* Tuning */ /**
* @defgroup tuning MIDI Tuning
* @ingroup synth
*
* The functions in this section implement the MIDI Tuning Standard interface.
*
* @{
*/
FLUIDSYNTH_API FLUIDSYNTH_API
int fluid_synth_activate_key_tuning(fluid_synth_t *synth, int bank, int prog, int fluid_synth_activate_key_tuning(fluid_synth_t *synth, int bank, int prog,
const char *name, const double *pitch, int apply); const char *name, const double *pitch, int apply);
@ -229,36 +316,23 @@ FLUIDSYNTH_API
int fluid_synth_tuning_iteration_next(fluid_synth_t *synth, int *bank, int *prog); int fluid_synth_tuning_iteration_next(fluid_synth_t *synth, int *bank, int *prog);
FLUIDSYNTH_API int fluid_synth_tuning_dump(fluid_synth_t *synth, int bank, int prog, FLUIDSYNTH_API int fluid_synth_tuning_dump(fluid_synth_t *synth, int bank, int prog,
char *name, int len, double *pitch); char *name, int len, double *pitch);
/* @} MIDI Tuning */
/* Misc */
FLUIDSYNTH_API double fluid_synth_get_cpu_load(fluid_synth_t *synth);
FLUID_DEPRECATED FLUIDSYNTH_API const char *fluid_synth_error(fluid_synth_t *synth);
/* Default modulators */
/** /**
* Enum used with fluid_synth_add_default_mod() to specify how to handle duplicate modulators. * @defgroup audio_rendering Audio Rendering
*/ * @ingroup synth
enum fluid_synth_add_mod
{
FLUID_SYNTH_OVERWRITE, /**< Overwrite any existing matching modulator */
FLUID_SYNTH_ADD, /**< Sum up modulator amounts */
};
FLUIDSYNTH_API int fluid_synth_add_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod, int mode);
FLUIDSYNTH_API int fluid_synth_remove_default_mod(fluid_synth_t *synth, const fluid_mod_t *mod);
/*
* Synthesizer plugin
* *
* To create a synthesizer plugin, create the synthesizer as * The functions in this section can be used to render audio directly to
* explained above. Once the synthesizer is created you can call * memory buffers. They are used internally by the \ref audio_driver and \ref file_renderer,
* any of the functions below to get the audio. * but can also be used manually for custom processing of the rendered audio.
*
* @note Please note that all following functions block during rendering. If your goal is to
* render real-time audio, ensure that you call these functions from a high-priority
* thread with little to no other duties other than calling the rendering functions.
*
* @{
*/ */
FLUIDSYNTH_API int fluid_synth_write_s16(fluid_synth_t *synth, int len, FLUIDSYNTH_API int fluid_synth_write_s16(fluid_synth_t *synth, int len,
void *lout, int loff, int lincr, void *lout, int loff, int lincr,
void *rout, int roff, int rincr); void *rout, int roff, int rincr);
@ -271,18 +345,17 @@ FLUID_DEPRECATED FLUIDSYNTH_API int fluid_synth_nwrite_float(fluid_synth_t *synt
FLUIDSYNTH_API int fluid_synth_process(fluid_synth_t *synth, int len, FLUIDSYNTH_API int fluid_synth_process(fluid_synth_t *synth, int len,
int nfx, float *fx[], int nfx, float *fx[],
int nout, float *out[]); int nout, float *out[]);
/* @} Audio Rendering */
/* Synthesizer's interface to handle SoundFont loaders */ /**
* @defgroup iir_filter Effect - IIR Filter
FLUIDSYNTH_API void fluid_synth_add_sfloader(fluid_synth_t *synth, fluid_sfloader_t *loader); * @ingroup synth
FLUIDSYNTH_API fluid_voice_t *fluid_synth_alloc_voice(fluid_synth_t *synth, *
fluid_sample_t *sample, * Functions for configuring the built-in IIR filter effect
int channum, int key, int vel); *
FLUIDSYNTH_API void fluid_synth_start_voice(fluid_synth_t *synth, fluid_voice_t *voice); * @{
FLUIDSYNTH_API void fluid_synth_get_voicelist(fluid_synth_t *synth, */
fluid_voice_t *buf[], int bufsize, int ID);
FLUIDSYNTH_API int fluid_synth_handle_midi_event(void *data, fluid_midi_event_t *event);
/** /**
* Specifies the type of filter to use for the custom IIR filter * Specifies the type of filter to use for the custom IIR filter
@ -306,17 +379,43 @@ enum fluid_iir_filter_flags
}; };
FLUIDSYNTH_API int fluid_synth_set_custom_filter(fluid_synth_t *, int type, int flags); FLUIDSYNTH_API int fluid_synth_set_custom_filter(fluid_synth_t *, int type, int flags);
/* @} IIR Filter */
/* LADSPA */
FLUIDSYNTH_API fluid_ladspa_fx_t *fluid_synth_get_ladspa_fx(fluid_synth_t *synth);
/* API: Poly mono mode */ /**
* @defgroup channel_setup MIDI Channel Setup
/** Interface to poly/mono mode variables * @ingroup synth
* *
* The functions in this section provide interfaces to change the channel type
* and to configure basic channels, legato and portamento setups.
*
* @{
*/
/** @name Channel Type
* @{
*/
/**
* The midi channel type used by fluid_synth_set_channel_type()
*/
enum fluid_midi_channel_type
{
CHANNEL_TYPE_MELODIC = 0, /**< Melodic midi channel */
CHANNEL_TYPE_DRUM = 1 /**< Drum midi channel */
};
FLUIDSYNTH_API int fluid_synth_set_channel_type(fluid_synth_t *synth, int chan, int type);
/** @} Channel Type */
/** @name Basic Channel Mode
* @{
*/
/**
* Channel mode bits OR-ed together so that it matches with the midi spec: poly omnion (0), mono omnion (1), poly omnioff (2), mono omnioff (3) * Channel mode bits OR-ed together so that it matches with the midi spec: poly omnion (0), mono omnion (1), poly omnioff (2), mono omnioff (3)
*/ */
enum fluid_channel_mode_flags enum fluid_channel_mode_flags
@ -325,15 +424,9 @@ enum fluid_channel_mode_flags
FLUID_CHANNEL_OMNI_OFF = 0x02, /**< if flag is set, the basic channel is in omni off state, if not set omni is on */ FLUID_CHANNEL_OMNI_OFF = 0x02, /**< if flag is set, the basic channel is in omni off state, if not set omni is on */
}; };
/** Indicates the breath mode a channel is set to */ /**
enum fluid_channel_breath_flags * Indicates the mode a basic channel is set to
{ */
FLUID_CHANNEL_BREATH_POLY = 0x10, /**< when channel is poly, this flag indicates that the default velocity to initial attenuation modulator is replaced by a breath to initial attenuation modulator */
FLUID_CHANNEL_BREATH_MONO = 0x20, /**< when channel is mono, this flag indicates that the default velocity to initial attenuation modulator is replaced by a breath modulator */
FLUID_CHANNEL_BREATH_SYNC = 0x40, /**< when channel is mono, this flag indicates that the breath controller(MSB)triggers noteon/noteoff on the running note */
};
/** Indicates the mode a basic channel is set to */
enum fluid_basic_channel_modes enum fluid_basic_channel_modes
{ {
FLUID_CHANNEL_MODE_MASK = (FLUID_CHANNEL_OMNI_OFF | FLUID_CHANNEL_POLY_OFF), /**< Mask Poly and Omni bits of #fluid_channel_mode_flags, usually only used internally */ FLUID_CHANNEL_MODE_MASK = (FLUID_CHANNEL_OMNI_OFF | FLUID_CHANNEL_POLY_OFF), /**< Mask Poly and Omni bits of #fluid_channel_mode_flags, usually only used internally */
@ -352,8 +445,13 @@ FLUIDSYNTH_API int fluid_synth_get_basic_channel(fluid_synth_t *synth, int chan
int *basic_val_out); int *basic_val_out);
FLUIDSYNTH_API int fluid_synth_set_basic_channel(fluid_synth_t *synth, int chan, int mode, int val); FLUIDSYNTH_API int fluid_synth_set_basic_channel(fluid_synth_t *synth, int chan, int mode, int val);
/** Interface to mono legato mode /** @} Basic Channel Mode */
*
/** @name Legato Mode
* @{
*/
/**
* Indicates the legato mode a channel is set to * Indicates the legato mode a channel is set to
* n1,n2,n3,.. is a legato passage. n1 is the first note, and n2,n3,n4 are played legato with previous note. */ * n1,n2,n3,.. is a legato passage. n1 is the first note, and n2,n3,n4 are played legato with previous note. */
enum fluid_channel_legato_mode enum fluid_channel_legato_mode
@ -365,9 +463,13 @@ enum fluid_channel_legato_mode
FLUIDSYNTH_API int fluid_synth_set_legato_mode(fluid_synth_t *synth, int chan, int legatomode); FLUIDSYNTH_API int fluid_synth_set_legato_mode(fluid_synth_t *synth, int chan, int legatomode);
FLUIDSYNTH_API int fluid_synth_get_legato_mode(fluid_synth_t *synth, int chan, int *legatomode); FLUIDSYNTH_API int fluid_synth_get_legato_mode(fluid_synth_t *synth, int chan, int *legatomode);
/** @} Legato Mode */
/** Interface to portamento mode /** @name Portamento Mode
* * @{
*/
/**
* Indicates the portamento mode a channel is set to * Indicates the portamento mode a channel is set to
*/ */
enum fluid_channel_portamento_mode enum fluid_channel_portamento_mode
@ -375,21 +477,62 @@ enum fluid_channel_portamento_mode
FLUID_CHANNEL_PORTAMENTO_MODE_EACH_NOTE, /**< Mode 0 - Portamento on each note (staccato or legato) */ FLUID_CHANNEL_PORTAMENTO_MODE_EACH_NOTE, /**< Mode 0 - Portamento on each note (staccato or legato) */
FLUID_CHANNEL_PORTAMENTO_MODE_LEGATO_ONLY, /**< Mode 1 - Portamento only on legato note */ FLUID_CHANNEL_PORTAMENTO_MODE_LEGATO_ONLY, /**< Mode 1 - Portamento only on legato note */
FLUID_CHANNEL_PORTAMENTO_MODE_STACCATO_ONLY, /**< Mode 2 - Portamento only on staccato note */ FLUID_CHANNEL_PORTAMENTO_MODE_STACCATO_ONLY, /**< Mode 2 - Portamento only on staccato note */
FLUID_CHANNEL_PORTAMENTO_MODE_LAST /**< @internal Value defines the count of portamento modes (#fluid_channel_portamento_mode) @warning This symbol is not part of the public API and ABI stability guarantee and may change at any time! */ FLUID_CHANNEL_PORTAMENTO_MODE_LAST /**< @internal Value defines the count of portamento modes
@warning This symbol is not part of the public API and ABI
stability guarantee and may change at any time! */
}; };
FLUIDSYNTH_API int fluid_synth_set_portamento_mode(fluid_synth_t *synth, FLUIDSYNTH_API int fluid_synth_set_portamento_mode(fluid_synth_t *synth,
int chan, int portamentomode); int chan, int portamentomode);
FLUIDSYNTH_API int fluid_synth_get_portamento_mode(fluid_synth_t *synth, FLUIDSYNTH_API int fluid_synth_get_portamento_mode(fluid_synth_t *synth,
int chan, int *portamentomode); int chan, int *portamentomode);
/** @} Portamento Mode */
/**@name Breath Mode
* @{
*/
/**
* Indicates the breath mode a channel is set to
*/
enum fluid_channel_breath_flags
{
FLUID_CHANNEL_BREATH_POLY = 0x10, /**< when channel is poly, this flag indicates that the default velocity to initial attenuation modulator is replaced by a breath to initial attenuation modulator */
FLUID_CHANNEL_BREATH_MONO = 0x20, /**< when channel is mono, this flag indicates that the default velocity to initial attenuation modulator is replaced by a breath modulator */
FLUID_CHANNEL_BREATH_SYNC = 0x40, /**< when channel is mono, this flag indicates that the breath controller(MSB)triggers noteon/noteoff on the running note */
};
/* Interface to breath mode */
FLUIDSYNTH_API int fluid_synth_set_breath_mode(fluid_synth_t *synth, FLUIDSYNTH_API int fluid_synth_set_breath_mode(fluid_synth_t *synth,
int chan, int breathmode); int chan, int breathmode);
FLUIDSYNTH_API int fluid_synth_get_breath_mode(fluid_synth_t *synth, FLUIDSYNTH_API int fluid_synth_get_breath_mode(fluid_synth_t *synth,
int chan, int *breathmode); int chan, int *breathmode);
/** @} Breath Mode */
/* @} MIDI Channel Setup */
/** @ingroup settings */
FLUIDSYNTH_API fluid_settings_t *fluid_synth_get_settings(fluid_synth_t *synth);
/** @ingroup soundfont_loader */
FLUIDSYNTH_API void fluid_synth_add_sfloader(fluid_synth_t *synth, fluid_sfloader_t *loader);
/** @ingroup soundfont_loader */
FLUIDSYNTH_API fluid_preset_t *fluid_synth_get_channel_preset(fluid_synth_t *synth, int chan);
/** @ingroup midi_input */
FLUIDSYNTH_API int fluid_synth_handle_midi_event(void *data, fluid_midi_event_t *event);
/** @ingroup soundfonts */
FLUIDSYNTH_API
int fluid_synth_pin_preset(fluid_synth_t *synth, int sfont_id, int bank_num, int preset_num);
/** @ingroup soundfonts */
FLUIDSYNTH_API
int fluid_synth_unpin_preset(fluid_synth_t *synth, int sfont_id, int bank_num, int preset_num);
/** @ingroup ladspa */
FLUIDSYNTH_API fluid_ladspa_fx_t *fluid_synth_get_ladspa_fx(fluid_synth_t *synth);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -29,8 +29,10 @@ extern "C" {
/** /**
* @file types.h * @defgroup Types Types
* @brief Type declarations * @brief Type declarations
*
* @{
*/ */
typedef struct _fluid_hashtable_t fluid_settings_t; /**< Configuration settings instance */ typedef struct _fluid_hashtable_t fluid_settings_t; /**< Configuration settings instance */
@ -64,6 +66,18 @@ typedef int fluid_ostream_t; /**< Output stream descriptor */
typedef short fluid_seq_id_t; /**< Unique client IDs used by the sequencer and #fluid_event_t, obtained by fluid_sequencer_register_client() and fluid_sequencer_register_fluidsynth() */ typedef short fluid_seq_id_t; /**< Unique client IDs used by the sequencer and #fluid_event_t, obtained by fluid_sequencer_register_client() and fluid_sequencer_register_fluidsynth() */
#if defined(_MSC_VER) && (_MSC_VER < 1800)
typedef __int64 fluid_long_long_t; // even on 32bit windows
#else
/**
* A typedef for C99's type long long, which is at least 64-bit wide, as guaranteed by the C99.
* @p __int64 will be used as replacement for VisualStudio 2010 and older.
*/
typedef long long fluid_long_long_t;
#endif
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -27,18 +27,18 @@ extern "C" {
#endif #endif
/** /**
* @file version.h * @addtogroup misc
* @brief Library version functions and defines *
* @{
*/ */
#define FLUIDSYNTH_VERSION "2.2.0" /**< String constant of libfluidsynth version. */
#define FLUIDSYNTH_VERSION "2.1.8" /**< String constant of libfluidsynth version. */
#define FLUIDSYNTH_VERSION_MAJOR 2 /**< libfluidsynth major version integer constant. */ #define FLUIDSYNTH_VERSION_MAJOR 2 /**< libfluidsynth major version integer constant. */
#define FLUIDSYNTH_VERSION_MINOR 1 /**< libfluidsynth minor version integer constant. */ #define FLUIDSYNTH_VERSION_MINOR 2 /**< libfluidsynth minor version integer constant. */
#define FLUIDSYNTH_VERSION_MICRO 8 /**< libfluidsynth micro version integer constant. */ #define FLUIDSYNTH_VERSION_MICRO 0 /**< libfluidsynth micro version integer constant. */
FLUIDSYNTH_API void fluid_version(int *major, int *minor, int *micro); FLUIDSYNTH_API void fluid_version(int *major, int *minor, int *micro);
FLUIDSYNTH_API char* fluid_version_str(void); FLUIDSYNTH_API char* fluid_version_str(void);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -26,16 +26,21 @@ extern "C" {
#endif #endif
/** /**
* @file voice.h * @defgroup voices Voice Manipulation
* @brief Synthesis voice manipulation functions. * @ingroup soundfonts
*
* Synthesis voice manipulation functions.
* *
* The interface to the synthesizer's voices. * 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, * Most of these functions should only be called from within synthesis context,
* such as the SoundFont loader's noteon method. * such as the SoundFont loader's noteon method.
*
* @{
*/ */
/** /**
* Enum used with fluid_voice_add_mod() to specify how to handle duplicate modulators. * Enum used with fluid_voice_add_mod() to specify how to handle duplicate modulators.
*/ */
@ -63,7 +68,7 @@ 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_is_sostenuto(const fluid_voice_t *voice);
FLUIDSYNTH_API int fluid_voice_optimize_sample(fluid_sample_t *s); FLUIDSYNTH_API int fluid_voice_optimize_sample(fluid_sample_t *s);
FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t *voice, int gen); FLUIDSYNTH_API void fluid_voice_update_param(fluid_voice_t *voice, int gen);
/* @} */
#ifdef __cplusplus #ifdef __cplusplus
} }

Binary file not shown.

View file

@ -5,7 +5,7 @@ includedir=${prefix}/include
Name: FluidSynth Name: FluidSynth
Description: Software SoundFont synth Description: Software SoundFont synth
Version: 2.1.8 Version: 2.2.0
Requires.private: libinstpatch-1.0 Requires.private: libinstpatch-1.0
Libs: -L${libdir} -lfluidsynth Libs: -L${libdir} -lfluidsynth
Libs.private: -framework AudioUnit -framework CoreAudio -framework CoreMIDI Libs.private: -framework AudioUnit -framework CoreAudio -framework CoreMIDI