libfluidsynth  1.1.11
Typedefs | Enumerations | Functions
midi.h File Reference

Functions for MIDI events, drivers and MIDI file playback. More...

Typedefs

typedef int(* handle_midi_event_func_t) (void *data, fluid_midi_event_t *event)
 Generic callback function for MIDI events. More...
 

Enumerations

enum  fluid_midi_router_rule_type {
  FLUID_MIDI_ROUTER_RULE_NOTE, FLUID_MIDI_ROUTER_RULE_CC, FLUID_MIDI_ROUTER_RULE_PROG_CHANGE, FLUID_MIDI_ROUTER_RULE_PITCH_BEND,
  FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE, FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE, FLUID_MIDI_ROUTER_RULE_COUNT
}
 MIDI router rule type. More...
 
enum  fluid_player_status { FLUID_PLAYER_READY, FLUID_PLAYER_PLAYING, FLUID_PLAYER_DONE }
 MIDI player status enum. More...
 

Functions

FLUIDSYNTH_API fluid_midi_event_tnew_fluid_midi_event (void)
 Create a MIDI event structure. More...
 
FLUIDSYNTH_API int delete_fluid_midi_event (fluid_midi_event_t *event)
 Delete MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_set_type (fluid_midi_event_t *evt, int type)
 Set the event type field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_get_type (fluid_midi_event_t *evt)
 Get the event type field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_set_channel (fluid_midi_event_t *evt, int chan)
 Set the channel field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_get_channel (fluid_midi_event_t *evt)
 Get the channel field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_get_key (fluid_midi_event_t *evt)
 Get the key field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_set_key (fluid_midi_event_t *evt, int key)
 Set the key field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_get_velocity (fluid_midi_event_t *evt)
 Get the velocity field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_set_velocity (fluid_midi_event_t *evt, int vel)
 Set the velocity field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_get_control (fluid_midi_event_t *evt)
 Get the control number of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_set_control (fluid_midi_event_t *evt, int ctrl)
 Set the control field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_get_value (fluid_midi_event_t *evt)
 Get the value field from a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_set_value (fluid_midi_event_t *evt, int val)
 Set the value field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_get_program (fluid_midi_event_t *evt)
 Get the program field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_set_program (fluid_midi_event_t *evt, int val)
 Set the program field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_get_pitch (fluid_midi_event_t *evt)
 Get the pitch field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_set_pitch (fluid_midi_event_t *evt, int val)
 Set the pitch field of a MIDI event structure. More...
 
FLUIDSYNTH_API int fluid_midi_event_set_sysex (fluid_midi_event_t *evt, void *data, int size, int dynamic)
 Assign sysex data to a MIDI event structure. More...
 
FLUIDSYNTH_API fluid_midi_router_tnew_fluid_midi_router (fluid_settings_t *settings, handle_midi_event_func_t handler, void *event_handler_data)
 Create a new midi router. More...
 
FLUIDSYNTH_API int delete_fluid_midi_router (fluid_midi_router_t *handler)
 Delete a MIDI router instance. More...
 
FLUIDSYNTH_API int fluid_midi_router_set_default_rules (fluid_midi_router_t *router)
 Set a MIDI router to use default "unity" rules. More...
 
FLUIDSYNTH_API int fluid_midi_router_clear_rules (fluid_midi_router_t *router)
 Clear all rules in a MIDI router. More...
 
FLUIDSYNTH_API int fluid_midi_router_add_rule (fluid_midi_router_t *router, fluid_midi_router_rule_t *rule, int type)
 Add a rule to a MIDI router. More...
 
FLUIDSYNTH_API fluid_midi_router_rule_tnew_fluid_midi_router_rule (void)
 Create a new MIDI router rule. More...
 
FLUIDSYNTH_API void delete_fluid_midi_router_rule (fluid_midi_router_rule_t *rule)
 Free a MIDI router rule. More...
 
FLUIDSYNTH_API void fluid_midi_router_rule_set_chan (fluid_midi_router_rule_t *rule, int min, int max, float mul, int add)
 Set the channel portion of a rule. More...
 
FLUIDSYNTH_API void fluid_midi_router_rule_set_param1 (fluid_midi_router_rule_t *rule, int min, int max, float mul, int add)
 Set the first parameter portion of a rule. More...
 
FLUIDSYNTH_API void fluid_midi_router_rule_set_param2 (fluid_midi_router_rule_t *rule, int min, int max, float mul, int add)
 Set the second parameter portion of a rule. More...
 
FLUIDSYNTH_API int fluid_midi_router_handle_midi_event (void *data, fluid_midi_event_t *event)
 Handle a MIDI event through a MIDI router instance. More...
 
FLUIDSYNTH_API int fluid_midi_dump_prerouter (void *data, fluid_midi_event_t *event)
 MIDI event callback function to display event information to stdout. More...
 
FLUIDSYNTH_API int fluid_midi_dump_postrouter (void *data, fluid_midi_event_t *event)
 MIDI event callback function to display event information to stdout. More...
 
FLUIDSYNTH_API fluid_midi_driver_tnew_fluid_midi_driver (fluid_settings_t *settings, handle_midi_event_func_t handler, void *event_handler_data)
 Create a new MIDI driver instance. More...
 
FLUIDSYNTH_API void delete_fluid_midi_driver (fluid_midi_driver_t *driver)
 Delete a MIDI driver instance. More...
 
FLUIDSYNTH_API fluid_player_tnew_fluid_player (fluid_synth_t *synth)
 Create a new MIDI player. More...
 
FLUIDSYNTH_API int delete_fluid_player (fluid_player_t *player)
 Delete a MIDI player instance. More...
 
FLUIDSYNTH_API int fluid_player_add (fluid_player_t *player, const char *midifile)
 Add a MIDI file to a player queue. More...
 
FLUIDSYNTH_API int fluid_player_add_mem (fluid_player_t *player, const void *buffer, size_t len)
 Add a MIDI file to a player queue, from a buffer in memory. More...
 
FLUIDSYNTH_API int fluid_player_play (fluid_player_t *player)
 Activates play mode for a MIDI player if not already playing. More...
 
FLUIDSYNTH_API int fluid_player_stop (fluid_player_t *player)
 Stops a MIDI player. More...
 
FLUIDSYNTH_API int fluid_player_join (fluid_player_t *player)
 Wait for a MIDI player to terminate (when done playing). More...
 
FLUIDSYNTH_API int fluid_player_set_loop (fluid_player_t *player, int loop)
 Enable looping of a MIDI player. More...
 
FLUIDSYNTH_API int fluid_player_set_midi_tempo (fluid_player_t *player, int tempo)
 Set the tempo of a MIDI player. More...
 
FLUIDSYNTH_API int fluid_player_set_bpm (fluid_player_t *player, int bpm)
 Set the tempo of a MIDI player in beats per minute. More...
 
FLUIDSYNTH_API int fluid_player_set_playback_callback (fluid_player_t *player, handle_midi_event_func_t handler, void *handler_data)
 Change the MIDI callback function. More...
 
FLUIDSYNTH_API int fluid_player_get_status (fluid_player_t *player)
 Get MIDI player status. More...
 
FLUIDSYNTH_API int fluid_player_get_current_tick (fluid_player_t *player)
 Get the number of tempo ticks passed. More...
 
FLUIDSYNTH_API int fluid_player_get_total_ticks (fluid_player_t *player)
 Looks through all available MIDI tracks and gets the absolute tick of the very last event to play. More...
 
FLUIDSYNTH_API int fluid_player_get_bpm (fluid_player_t *player)
 Get the tempo of a MIDI player in beats per minute. More...
 
FLUIDSYNTH_API int fluid_player_get_midi_tempo (fluid_player_t *player)
 Get the tempo of a MIDI player. More...
 

Detailed Description

Functions for MIDI events, drivers and MIDI file playback.

Typedef Documentation

◆ handle_midi_event_func_t

typedef int(* handle_midi_event_func_t) (void *data, fluid_midi_event_t *event)

Generic callback function for MIDI events.

Parameters
dataUser defined data pointer
eventThe MIDI event
Returns
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...

Enumeration Type Documentation

◆ fluid_midi_router_rule_type

MIDI router rule type.

Since
1.1.0
Enumerator
FLUID_MIDI_ROUTER_RULE_NOTE 

MIDI note rule.

FLUID_MIDI_ROUTER_RULE_CC 

MIDI controller rule.

FLUID_MIDI_ROUTER_RULE_PROG_CHANGE 

MIDI program change 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_KEY_PRESSURE 

MIDI key pressure rule.

FLUID_MIDI_ROUTER_RULE_COUNT 

Total count of rule types.

◆ fluid_player_status

MIDI player status enum.

Since
1.1.0
Enumerator
FLUID_PLAYER_READY 

Player is ready.

FLUID_PLAYER_PLAYING 

Player is currently playing.

FLUID_PLAYER_DONE 

Player is finished playing.

Function Documentation

◆ new_fluid_midi_event()

FLUIDSYNTH_API fluid_midi_event_t* new_fluid_midi_event ( void  )

Create a MIDI event structure.

Returns
New MIDI event structure or NULL when out of memory.

References FLUID_ERR.

◆ delete_fluid_midi_event()

FLUIDSYNTH_API int delete_fluid_midi_event ( fluid_midi_event_t evt)

Delete MIDI event structure.

Parameters
evtMIDI event structure
Returns
Always returns FLUID_OK

References FLUID_OK.

Referenced by fluid_midi_event_set_sysex().

◆ fluid_midi_event_set_type()

FLUIDSYNTH_API int fluid_midi_event_set_type ( fluid_midi_event_t evt,
int  type 
)

Set the event type field of a MIDI event structure.

Parameters
evtMIDI event structure
typeEvent type field (MIDI status byte without channel)
Returns
Always returns FLUID_OK

References FLUID_OK.

Referenced by fluid_midi_router_handle_midi_event().

◆ fluid_midi_event_get_type()

FLUIDSYNTH_API int fluid_midi_event_get_type ( fluid_midi_event_t evt)

Get the event type field of a MIDI event structure.

Parameters
evtMIDI event structure
Returns
Event type field (MIDI status byte without channel)

Referenced by fluid_sequencer_add_midi_event_to_buffer(), and fluid_synth_handle_midi_event().

◆ fluid_midi_event_set_channel()

FLUIDSYNTH_API int fluid_midi_event_set_channel ( fluid_midi_event_t evt,
int  chan 
)

Set the channel field of a MIDI event structure.

Parameters
evtMIDI event structure
chanMIDI channel field
Returns
Always returns FLUID_OK

References FLUID_OK.

Referenced by fluid_midi_router_handle_midi_event().

◆ fluid_midi_event_get_channel()

FLUIDSYNTH_API int fluid_midi_event_get_channel ( fluid_midi_event_t evt)

Get the channel field of a MIDI event structure.

Parameters
evtMIDI event structure
Returns
Channel field

Referenced by fluid_sequencer_add_midi_event_to_buffer(), and fluid_synth_handle_midi_event().

◆ fluid_midi_event_get_key()

FLUIDSYNTH_API int fluid_midi_event_get_key ( fluid_midi_event_t evt)

Get the key field of a MIDI event structure.

Parameters
evtMIDI event structure
Returns
MIDI note number (0-127)

Referenced by fluid_sequencer_add_midi_event_to_buffer(), and fluid_synth_handle_midi_event().

◆ fluid_midi_event_set_key()

FLUIDSYNTH_API int fluid_midi_event_set_key ( fluid_midi_event_t evt,
int  v 
)

Set the key field of a MIDI event structure.

Parameters
evtMIDI event structure
vMIDI note number (0-127)
Returns
Always returns FLUID_OK

References FLUID_OK.

◆ fluid_midi_event_get_velocity()

FLUIDSYNTH_API int fluid_midi_event_get_velocity ( fluid_midi_event_t evt)

Get the velocity field of a MIDI event structure.

Parameters
evtMIDI event structure
Returns
MIDI velocity number (0-127)

Referenced by fluid_sequencer_add_midi_event_to_buffer(), and fluid_synth_handle_midi_event().

◆ fluid_midi_event_set_velocity()

FLUIDSYNTH_API int fluid_midi_event_set_velocity ( fluid_midi_event_t evt,
int  v 
)

Set the velocity field of a MIDI event structure.

Parameters
evtMIDI event structure
vMIDI velocity value
Returns
Always returns FLUID_OK

References FLUID_OK.

◆ fluid_midi_event_get_control()

FLUIDSYNTH_API int fluid_midi_event_get_control ( fluid_midi_event_t evt)

Get the control number of a MIDI event structure.

Parameters
evtMIDI event structure
Returns
MIDI control number

Referenced by fluid_sequencer_add_midi_event_to_buffer(), and fluid_synth_handle_midi_event().

◆ fluid_midi_event_set_control()

FLUIDSYNTH_API int fluid_midi_event_set_control ( fluid_midi_event_t evt,
int  v 
)

Set the control field of a MIDI event structure.

Parameters
evtMIDI event structure
vMIDI control number
Returns
Always returns FLUID_OK

References FLUID_OK.

◆ fluid_midi_event_get_value()

FLUIDSYNTH_API int fluid_midi_event_get_value ( fluid_midi_event_t evt)

Get the value field from a MIDI event structure.

Parameters
evtMIDI event structure
Returns
Value field

Referenced by fluid_sequencer_add_midi_event_to_buffer(), and fluid_synth_handle_midi_event().

◆ fluid_midi_event_set_value()

FLUIDSYNTH_API int fluid_midi_event_set_value ( fluid_midi_event_t evt,
int  v 
)

Set the value field of a MIDI event structure.

Parameters
evtMIDI event structure
vValue to assign
Returns
Always returns FLUID_OK

References FLUID_OK.

◆ fluid_midi_event_get_program()

FLUIDSYNTH_API int fluid_midi_event_get_program ( fluid_midi_event_t evt)

Get the program field of a MIDI event structure.

Parameters
evtMIDI event structure
Returns
MIDI program number (0-127)

Referenced by fluid_sequencer_add_midi_event_to_buffer(), and fluid_synth_handle_midi_event().

◆ fluid_midi_event_set_program()

FLUIDSYNTH_API int fluid_midi_event_set_program ( fluid_midi_event_t evt,
int  val 
)

Set the program field of a MIDI event structure.

Parameters
evtMIDI event structure
valMIDI program number (0-127)
Returns
Always returns FLUID_OK

References FLUID_OK.

◆ fluid_midi_event_get_pitch()

FLUIDSYNTH_API int fluid_midi_event_get_pitch ( fluid_midi_event_t evt)

Get the pitch field of a MIDI event structure.

Parameters
evtMIDI event structure
Returns
Pitch value (14 bit value, 0-16383, 8192 is center)

Referenced by fluid_sequencer_add_midi_event_to_buffer(), and fluid_synth_handle_midi_event().

◆ fluid_midi_event_set_pitch()

FLUIDSYNTH_API int fluid_midi_event_set_pitch ( fluid_midi_event_t evt,
int  val 
)

Set the pitch field of a MIDI event structure.

Parameters
evtMIDI event structure
valPitch value (14 bit value, 0-16383, 8192 is center)
Returns
Always returns FLUID_OK

References FLUID_OK.

◆ fluid_midi_event_set_sysex()

FLUIDSYNTH_API int fluid_midi_event_set_sysex ( fluid_midi_event_t evt,
void *  data,
int  size,
int  dynamic 
)

Assign sysex data to a MIDI event structure.

Parameters
evtMIDI event structure
dataPointer to SYSEX data
sizeSize of SYSEX data
dynamicTRUE if the SYSEX data has been dynamically allocated and should be freed when the event is freed (only applies if event gets destroyed with delete_fluid_midi_event())
Returns
Always returns FLUID_OK
Note
Unlike the other event assignment functions, this one sets evt->type.

References delete_fluid_midi_event(), FLUID_ERR, FLUID_FAILED, FLUID_OK, and fluid_player_set_midi_tempo().

Referenced by fluid_player_get_midi_tempo().

◆ new_fluid_midi_router()

FLUIDSYNTH_API fluid_midi_router_t* new_fluid_midi_router ( fluid_settings_t settings,
handle_midi_event_func_t  handler,
void *  event_handler_data 
)

Create a new midi router.

The default rules will pass all events unmodified.

Parameters
settingsSettings used to configure MIDI router
handlerMIDI event callback.
event_handler_dataCaller defined data pointer which gets passed to 'handler'
Returns
New MIDI router instance or NULL on error

The MIDI handler callback should process the possibly filtered/modified MIDI events from the MIDI router and forward them on to a synthesizer for example. The function fluid_synth_handle_midi_event() can be used for handle and a fluid_synth_t passed as the event_handler_data parameter for this purpose.

References delete_fluid_midi_router(), FLUID_ERR, FLUID_MIDI_ROUTER_RULE_COUNT, fluid_settings_getint(), and new_fluid_midi_router_rule().

◆ delete_fluid_midi_router()

FLUIDSYNTH_API int delete_fluid_midi_router ( fluid_midi_router_t router)

Delete a MIDI router instance.

Parameters
routerMIDI router to delete
Returns
Returns FLUID_OK on success, FLUID_FAILED otherwise (only if NULL router passed really)

References FLUID_FAILED, FLUID_MIDI_ROUTER_RULE_COUNT, and FLUID_OK.

Referenced by new_fluid_midi_router().

◆ fluid_midi_router_set_default_rules()

FLUIDSYNTH_API int fluid_midi_router_set_default_rules ( fluid_midi_router_t router)

Set a MIDI router to use default "unity" rules.

Such a router will pass all events unmodified.

Parameters
routerRouter to set to default rules.
Returns
FLUID_OK on success, FLUID_FAILED otherwise
Since
1.1.0

References delete_fluid_midi_router_rule(), FLUID_FAILED, FLUID_MIDI_ROUTER_RULE_COUNT, FLUID_OK, and new_fluid_midi_router_rule().

Referenced by fluid_midi_router_handle_midi_event().

◆ fluid_midi_router_clear_rules()

FLUIDSYNTH_API int fluid_midi_router_clear_rules ( fluid_midi_router_t router)

Clear all rules in a MIDI router.

Such a router will drop all events until rules are added.

Parameters
routerRouter to clear all rules from
Returns
FLUID_OK on success, FLUID_FAILED otherwise
Since
1.1.0

References FLUID_FAILED, FLUID_MIDI_ROUTER_RULE_COUNT, and FLUID_OK.

Referenced by fluid_midi_router_handle_midi_event().

◆ fluid_midi_router_add_rule()

FLUIDSYNTH_API int fluid_midi_router_add_rule ( fluid_midi_router_t router,
fluid_midi_router_rule_t rule,
int  type 
)

Add a rule to a MIDI router.

Parameters
routerMIDI router
ruleRule to add (used directly and should not be accessed again following a successful call to this function).
typeThe type of rule to add (fluid_midi_router_rule_type)
Returns
FLUID_OK on success, FLUID_FAILED otherwise (invalid rule for example)
Since
1.1.0

References FLUID_FAILED, FLUID_MIDI_ROUTER_RULE_COUNT, and FLUID_OK.

Referenced by fluid_midi_router_handle_midi_event().

◆ new_fluid_midi_router_rule()

FLUIDSYNTH_API fluid_midi_router_rule_t* new_fluid_midi_router_rule ( void  )

Create a new MIDI router rule.

Returns
Newly allocated router rule or NULL if out of memory.
Since
1.1.0

The new rule is a "unity" rule which will accept any values and wont modify them.

References FLUID_ERR.

Referenced by fluid_midi_router_handle_midi_event(), fluid_midi_router_set_default_rules(), and new_fluid_midi_router().

◆ delete_fluid_midi_router_rule()

FLUIDSYNTH_API void delete_fluid_midi_router_rule ( fluid_midi_router_rule_t rule)

Free a MIDI router rule.

Parameters
ruleRouter rule to free
Since
1.1.0

Note that rules which have been added to a router are managed by the router, so this function should seldom be needed.

Referenced by fluid_midi_router_handle_midi_event(), and fluid_midi_router_set_default_rules().

◆ fluid_midi_router_rule_set_chan()

FLUIDSYNTH_API void fluid_midi_router_rule_set_chan ( fluid_midi_router_rule_t rule,
int  min,
int  max,
float  mul,
int  add 
)

Set the channel portion of a rule.

Parameters
ruleMIDI router rule
minMinimum value for rule match
maxMaximum value for rule match
mulValue which is multiplied by matching event's channel value (1.0 to not modify)
addValue which is added to matching event's channel value (0 to not modify)
Since
1.1.0

The min and max parameters define a channel range window to match incoming events to. If min is less than or equal to max then an event is matched if its channel is within the defined range (including min and max). If min is greater than max then rule is inverted and matches everything except in between the defined range (so min and max would match).

The mul and add values are used to modify event channel values prior to sending the event, if the rule matches.

Referenced by fluid_midi_router_handle_midi_event().

◆ fluid_midi_router_rule_set_param1()

FLUIDSYNTH_API void fluid_midi_router_rule_set_param1 ( fluid_midi_router_rule_t rule,
int  min,
int  max,
float  mul,
int  add 
)

Set the first parameter portion of a rule.

Parameters
ruleMIDI router rule
minMinimum value for rule match
maxMaximum value for rule match
mulValue which is multiplied by matching event's 1st parameter value (1.0 to not modify)
addValue which is added to matching event's 1st parameter value (0 to not modify)
Since
1.1.0

The 1st parameter of an event depends on the type of event. For note events its the MIDI note #, for CC events its the MIDI control number, for program change events its the MIDI program #, for pitch bend events its the bend value, for channel pressure its the channel pressure value and for key pressure its the MIDI note number.

Pitch bend values have a maximum value of 16383 (8192 is pitch bend center) and all other events have a max of 127. All events have a minimum value of 0.

The min and max parameters define a parameter range window to match incoming events to. If min is less than or equal to max then an event is matched if its 1st parameter is within the defined range (including min and max). If min is greater than max then rule is inverted and matches everything except in between the defined range (so min and max would match).

The mul and add values are used to modify event 1st parameter values prior to sending the event, if the rule matches.

Referenced by fluid_midi_router_handle_midi_event().

◆ fluid_midi_router_rule_set_param2()

FLUIDSYNTH_API void fluid_midi_router_rule_set_param2 ( fluid_midi_router_rule_t rule,
int  min,
int  max,
float  mul,
int  add 
)

Set the second parameter portion of a rule.

Parameters
ruleMIDI router rule
minMinimum value for rule match
maxMaximum value for rule match
mulValue which is multiplied by matching event's 2nd parameter value (1.0 to not modify)
addValue which is added to matching event's 2nd parameter value (0 to not modify)
Since
1.1.0

The 2nd parameter of an event depends on the type of event. For note events its the MIDI velocity, for CC events its the control value and for key pressure events its the key pressure value. All other types lack a 2nd parameter.

All applicable 2nd parameters have the range 0-127.

The min and max parameters define a parameter range window to match incoming events to. If min is less than or equal to max then an event is matched if its 2nd parameter is within the defined range (including min and max). If min is greater than max then rule is inverted and matches everything except in between the defined range (so min and max would match).

The mul and add values are used to modify event 2nd parameter values prior to sending the event, if the rule matches.

Referenced by fluid_midi_router_handle_midi_event().

◆ fluid_midi_router_handle_midi_event()

FLUIDSYNTH_API int fluid_midi_router_handle_midi_event ( void *  data,
fluid_midi_event_t event 
)

Handle a MIDI event through a MIDI router instance.

Parameters
dataMIDI router instance fluid_midi_router_t, its a void * so that this function can be used as a callback for other subsystems (new_fluid_midi_driver() for example).
eventMIDI event to handle
Returns
FLUID_OK on success, FLUID_FAILED otherwise

Purpose: The midi router is called for each event, that is received via the 'physical' midi input. Each event can trigger an arbitrary number of generated events (one for each rule that matches).

In default mode, a noteon event is just forwarded to the synth's 'noteon' function, a 'CC' event to the synth's 'CC' function and so on.

The router can be used to:

  • filter messages (for example: Pass sustain pedal CCs only to selected channels)
  • split the keyboard (noteon with notenr < x: to ch 1, >x to ch 2)
  • layer sounds (for each noteon received on ch 1, create a noteon on ch1, ch2, ch3,...)
  • velocity scaling (for each noteon event, scale the velocity by 1.27 to give DX7 users a chance)
  • velocity switching ("v <=100: Angel Choir; V > 100: Hell's Bells")
  • get rid of aftertouch
  • ...

References delete_fluid_midi_router_rule(), FLUID_FAILED, fluid_midi_event_set_channel(), fluid_midi_event_set_type(), fluid_midi_router_add_rule(), fluid_midi_router_clear_rules(), FLUID_MIDI_ROUTER_RULE_CC, FLUID_MIDI_ROUTER_RULE_CHANNEL_PRESSURE, FLUID_MIDI_ROUTER_RULE_KEY_PRESSURE, FLUID_MIDI_ROUTER_RULE_NOTE, FLUID_MIDI_ROUTER_RULE_PITCH_BEND, FLUID_MIDI_ROUTER_RULE_PROG_CHANGE, fluid_midi_router_rule_set_chan(), fluid_midi_router_rule_set_param1(), fluid_midi_router_rule_set_param2(), fluid_midi_router_set_default_rules(), FLUID_OK, and new_fluid_midi_router_rule().

Referenced by fluid_midi_dump_prerouter().

◆ fluid_midi_dump_prerouter()

FLUIDSYNTH_API int fluid_midi_dump_prerouter ( void *  data,
fluid_midi_event_t event 
)

MIDI event callback function to display event information to stdout.

Parameters
dataMIDI router instance
eventMIDI event data
Returns
FLUID_OK on success, FLUID_FAILED otherwise

An implementation of the handle_midi_event_func_t function type, used for displaying MIDI event information between the MIDI driver and router to stdout. Useful for adding into a MIDI router chain for debugging MIDI events.

References fluid_midi_router_handle_midi_event().

◆ fluid_midi_dump_postrouter()

FLUIDSYNTH_API int fluid_midi_dump_postrouter ( void *  data,
fluid_midi_event_t event 
)

MIDI event callback function to display event information to stdout.

Parameters
dataMIDI router instance
eventMIDI event data
Returns
FLUID_OK on success, FLUID_FAILED otherwise

An implementation of the handle_midi_event_func_t function type, used for displaying MIDI event information between the MIDI driver and router to stdout. Useful for adding into a MIDI router chain for debugging MIDI events.

References fluid_synth_handle_midi_event().

◆ new_fluid_midi_driver()

FLUIDSYNTH_API fluid_midi_driver_t* new_fluid_midi_driver ( fluid_settings_t settings,
handle_midi_event_func_t  handler,
void *  event_handler_data 
)

Create a new MIDI driver instance.

Parameters
settingsSettings used to configure new MIDI driver.
handlerMIDI handler callback (for example: fluid_midi_router_handle_midi_event() for MIDI router)
event_handler_dataCaller defined data to pass to 'handler'
Returns
New MIDI driver instance or NULL on error

References FLUID_DBG, FLUID_ERR, fluid_settings_option_concat(), and fluid_settings_str_equal().

◆ delete_fluid_midi_driver()

FLUIDSYNTH_API void delete_fluid_midi_driver ( fluid_midi_driver_t driver)

Delete a MIDI driver instance.

Parameters
driverMIDI driver to delete

◆ new_fluid_player()

FLUIDSYNTH_API fluid_player_t* new_fluid_player ( fluid_synth_t synth)

Create a new MIDI player.

Parameters
synthFluid synthesizer instance to create player for
Returns
New MIDI player instance or NULL on error (out of memory)

References FLUID_ERR, FLUID_PLAYER_READY, fluid_player_set_playback_callback(), fluid_settings_getint(), fluid_settings_str_equal(), and fluid_synth_handle_midi_event().

◆ delete_fluid_player()

FLUIDSYNTH_API int delete_fluid_player ( fluid_player_t player)

Delete a MIDI player instance.

Parameters
playerMIDI player instance
Returns
Always returns FLUID_OK

References FLUID_FAILED, FLUID_HINT_TOGGLED, FLUID_OK, and fluid_player_stop().

◆ fluid_player_add()

FLUIDSYNTH_API int fluid_player_add ( fluid_player_t player,
const char *  midifile 
)

Add a MIDI file to a player queue.

Parameters
playerMIDI player instance
midifileFile name of the MIDI file to add
Returns
FLUID_OK or FLUID_FAILED

References FLUID_FAILED, FLUID_OK, and FLUID_PANIC.

◆ fluid_player_add_mem()

FLUIDSYNTH_API int fluid_player_add_mem ( fluid_player_t player,
const void *  buffer,
size_t  len 
)

Add a MIDI file to a player queue, from a buffer in memory.

Parameters
playerMIDI player instance
bufferPointer to memory containing the bytes of a complete MIDI file. The data is copied, so the caller may free or modify it immediately without affecting the playlist.
lenLength of the buffer, in bytes.
Returns
FLUID_OK or FLUID_FAILED

References FLUID_DBG, FLUID_ERR, FLUID_FAILED, FLUID_OK, FLUID_PANIC, FLUID_PLAYER_DONE, FLUID_PLAYER_PLAYING, fluid_player_set_midi_tempo(), and fluid_synth_system_reset().

◆ fluid_player_play()

FLUIDSYNTH_API int fluid_player_play ( fluid_player_t player)

Activates play mode for a MIDI player if not already playing.

Parameters
playerMIDI player instance
Returns
FLUID_OK on success, FLUID_FAILED otherwise

References FLUID_FAILED, FLUID_OK, and FLUID_PLAYER_PLAYING.

◆ fluid_player_stop()

FLUIDSYNTH_API int fluid_player_stop ( fluid_player_t player)

Stops a MIDI player.

Parameters
playerMIDI player instance
Returns
Always returns FLUID_OK

References FLUID_OK, and FLUID_PLAYER_DONE.

Referenced by delete_fluid_player().

◆ fluid_player_join()

FLUIDSYNTH_API int fluid_player_join ( fluid_player_t player)

Wait for a MIDI player to terminate (when done playing).

Parameters
playerMIDI player instance
Returns
FLUID_OK on success, FLUID_FAILED otherwise

References FLUID_OK, and FLUID_PLAYER_DONE.

◆ fluid_player_set_loop()

FLUIDSYNTH_API int fluid_player_set_loop ( fluid_player_t player,
int  loop 
)

Enable looping of a MIDI player.

Parameters
playerMIDI player instance
loopTimes left to loop the playlist. -1 means loop infinitely.
Returns
Always returns FLUID_OK
Since
1.1.0

For example, if you want to loop the playlist twice, set loop to 2 and call this function before you start the player.

References FLUID_OK.

◆ fluid_player_set_midi_tempo()

FLUIDSYNTH_API int fluid_player_set_midi_tempo ( fluid_player_t player,
int  tempo 
)

Set the tempo of a MIDI player.

Parameters
playerMIDI player instance
tempoTempo to set playback speed to (in microseconds per quarter note, as per MIDI file spec)
Returns
Always returns FLUID_OK

References FLUID_DBG, and FLUID_OK.

Referenced by fluid_midi_event_set_sysex(), fluid_player_add_mem(), and fluid_player_set_bpm().

◆ fluid_player_set_bpm()

FLUIDSYNTH_API int fluid_player_set_bpm ( fluid_player_t player,
int  bpm 
)

Set the tempo of a MIDI player in beats per minute.

Parameters
playerMIDI player instance
bpmTempo in beats per minute
Returns
Always returns FLUID_OK

References fluid_player_set_midi_tempo().

◆ fluid_player_set_playback_callback()

FLUIDSYNTH_API int fluid_player_set_playback_callback ( fluid_player_t player,
handle_midi_event_func_t  handler,
void *  handler_data 
)

Change the MIDI callback function.

This is usually set to fluid_synth_handle_midi_event, but can optionally be changed to a user-defined function instead, for intercepting all MIDI messages sent to the synth. You can also use a midi router as the callback function to modify the MIDI messages before sending them to the synth.

Parameters
playerMIDI player instance
handlerPointer to callback function
handler_dataParameter sent to the callback function
Returns
FLUID_OK
Since
1.1.4

References FLUID_OK.

Referenced by new_fluid_player().

◆ fluid_player_get_status()

FLUIDSYNTH_API int fluid_player_get_status ( fluid_player_t player)

Get MIDI player status.

Parameters
playerMIDI player instance
Returns
Player status (fluid_player_status)
Since
1.1.0

◆ fluid_player_get_current_tick()

FLUIDSYNTH_API int fluid_player_get_current_tick ( fluid_player_t player)

Get the number of tempo ticks passed.

Parameters
playerMIDI player instance
Returns
The number of tempo ticks passed
Since
1.1.7

◆ fluid_player_get_total_ticks()

FLUIDSYNTH_API int fluid_player_get_total_ticks ( fluid_player_t player)

Looks through all available MIDI tracks and gets the absolute tick of the very last event to play.

Parameters
playerMIDI player instance
Returns
Total tick count of the sequence
Since
1.1.7

◆ fluid_player_get_bpm()

FLUIDSYNTH_API int fluid_player_get_bpm ( fluid_player_t player)

Get the tempo of a MIDI player in beats per minute.

Parameters
playerMIDI player instance
Returns
MIDI player tempo in BPM
Since
1.1.7

◆ fluid_player_get_midi_tempo()

FLUIDSYNTH_API int fluid_player_get_midi_tempo ( fluid_player_t player)

Get the tempo of a MIDI player.

Parameters
playerMIDI player instance
Returns
Tempo of the MIDI player (in microseconds per quarter note, as per MIDI file spec)
Since
1.1.7

References FLUID_ERR, fluid_midi_event_set_sysex(), and FLUID_OK.