libfluidsynth
2.4.5
|
Parse standard MIDI files and emit MIDI events. More...
Enumerations | |
enum | fluid_player_set_tempo_type { FLUID_PLAYER_TEMPO_INTERNAL , FLUID_PLAYER_TEMPO_EXTERNAL_BPM , FLUID_PLAYER_TEMPO_EXTERNAL_MIDI , FLUID_PLAYER_TEMPO_NBR } |
MIDI File Player tempo enum. More... | |
enum | fluid_player_status { FLUID_PLAYER_READY , FLUID_PLAYER_PLAYING , FLUID_PLAYER_STOPPING , FLUID_PLAYER_DONE } |
MIDI File Player status enum. More... | |
Lifecycle Functions for MIDI File Player_linebr@{ | |
fluid_player_t * | new_fluid_player (fluid_synth_t *synth) |
Create a new MIDI player. More... | |
void | delete_fluid_player (fluid_player_t *player) |
Delete a MIDI player instance. More... | |
Functions | |
int | fluid_player_add (fluid_player_t *player, const char *midifile) |
Add a MIDI file to a player queue. More... | |
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... | |
int | fluid_player_get_bpm (fluid_player_t *player) |
Get the tempo currently used by a MIDI player. More... | |
int | fluid_player_get_current_tick (fluid_player_t *player) |
Get the number of tempo ticks passed. More... | |
int | fluid_player_get_division (fluid_player_t *player) |
Get the division currently used by a MIDI player. More... | |
int | fluid_player_get_midi_tempo (fluid_player_t *player) |
Get the tempo currently used by a MIDI player. More... | |
int | fluid_player_get_status (fluid_player_t *player) |
Get MIDI player status. More... | |
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... | |
int | fluid_player_join (fluid_player_t *player) |
Wait for a MIDI player until the playback has been stopped. More... | |
int | fluid_player_play (fluid_player_t *player) |
Activates play mode for a MIDI player if not already playing. More... | |
int | fluid_player_seek (fluid_player_t *player, int ticks) |
Seek in the currently playing file. More... | |
int | fluid_player_set_bpm (fluid_player_t *player, int bpm) |
Set the tempo of a MIDI player in beats per minute. More... | |
int | fluid_player_set_loop (fluid_player_t *player, int loop) |
Enable looping of a MIDI player. More... | |
int | fluid_player_set_midi_tempo (fluid_player_t *player, int tempo) |
Set the tempo of a MIDI player. More... | |
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... | |
int | fluid_player_set_tempo (fluid_player_t *player, int tempo_type, double tempo) |
Set the tempo of a MIDI player. More... | |
int | fluid_player_set_tick_callback (fluid_player_t *player, handle_midi_tick_func_t handler, void *handler_data) |
Add a listener function for every MIDI tick change. More... | |
int | fluid_player_stop (fluid_player_t *player) |
Pauses the MIDI playback. More... | |
Parse standard MIDI files and emit MIDI events.
MIDI File Player tempo enum.
enum fluid_player_status |
void delete_fluid_player | ( | fluid_player_t * | player | ) |
Delete a MIDI player instance.
player | MIDI player instance |
player
renders audio, i.e. an audio driver is running or any other synthesizer thread concurrently calls fluid_synth_process() or fluid_synth_nwrite_float() or fluid_synth_write_*() ! int fluid_player_add | ( | fluid_player_t * | player, |
const char * | midifile | ||
) |
Add a MIDI file to a player queue.
player | MIDI player instance |
midifile | File name of the MIDI file to add |
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.
player | MIDI player instance |
buffer | Pointer 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. |
len | Length of the buffer, in bytes. |
int fluid_player_get_bpm | ( | fluid_player_t * | player | ) |
Get the tempo currently used by a MIDI player.
The player can be controlled by internal tempo coming from MIDI file tempo change or controlled by external tempo see fluid_player_set_tempo().
player | MIDI player instance. Must be a valid pointer. |
int fluid_player_get_current_tick | ( | fluid_player_t * | player | ) |
Get the number of tempo ticks passed.
player | MIDI player instance |
int fluid_player_get_division | ( | fluid_player_t * | player | ) |
Get the division currently used by a MIDI player.
The player can be controlled by internal tempo coming from MIDI file tempo change or controlled by external tempo see fluid_player_set_tempo().
player | MIDI player instance. Must be a valid pointer. |
int fluid_player_get_midi_tempo | ( | fluid_player_t * | player | ) |
Get the tempo currently used by a MIDI player.
The player can be controlled by internal tempo coming from MIDI file tempo change or controlled by external tempo see fluid_player_set_tempo().
player | MIDI player instance. Must be a valid pointer. |
int fluid_player_get_status | ( | fluid_player_t * | player | ) |
Get MIDI player status.
player | MIDI player instance |
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.
player | MIDI player instance |
int fluid_player_join | ( | fluid_player_t * | player | ) |
Wait for a MIDI player until the playback has been stopped.
player | MIDI player instance |
int fluid_player_play | ( | fluid_player_t * | player | ) |
Activates play mode for a MIDI player if not already playing.
player | MIDI player instance |
If the list of files added to the player has completed its requested number of loops, the playlist will be restarted from the beginning with a loop count of 1.
int fluid_player_seek | ( | fluid_player_t * | player, |
int | ticks | ||
) |
Seek in the currently playing file.
player | MIDI player instance |
ticks | the position to seek to in the current file |
The actual seek will be performed when the synth calls back the player (i.e. a few levels above the player's callback set with fluid_player_set_playback_callback()). If the player's status is FLUID_PLAYER_PLAYING and a previous seek operation has not been completed yet, FLUID_FAILED is returned.
int fluid_player_set_bpm | ( | fluid_player_t * | player, |
int | bpm | ||
) |
Set the tempo of a MIDI player in beats per minute.
player | MIDI player instance |
bpm | Tempo in beats per minute |
int fluid_player_set_loop | ( | fluid_player_t * | player, |
int | loop | ||
) |
Enable looping of a MIDI player.
player | MIDI player instance |
loop | Times left to loop the playlist. -1 means loop infinitely. |
For example, if you want to loop the playlist twice, set loop to 2 and call this function before you start the player.
int fluid_player_set_midi_tempo | ( | fluid_player_t * | player, |
int | tempo | ||
) |
Set the tempo of a MIDI player.
player | MIDI player instance |
tempo | Tempo to set playback speed to (in microseconds per quarter note, as per MIDI file spec) |
int fluid_player_set_playback_callback | ( | fluid_player_t * | player, |
handle_midi_event_func_t | handler, | ||
void * | handler_data | ||
) |
Change the MIDI callback function.
player | MIDI player instance |
handler | Pointer to callback function |
handler_data | Parameter sent to the 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.
int fluid_player_set_tempo | ( | fluid_player_t * | player, |
int | tempo_type, | ||
double | tempo | ||
) |
Set the tempo of a MIDI player.
The player can be controlled by internal tempo coming from MIDI file tempo change or controlled by external tempo expressed in BPM or in micro seconds per quarter note.
player | MIDI player instance. Must be a valid pointer. |
tempo_type | Must a be value of fluid_player_set_tempo_type and indicates the meaning of tempo value and how the player will be controlled, see below. |
tempo | Tempo value or multiplier. |
FLUID_PLAYER_TEMPO_INTERNAL, the player will be controlled by internal MIDI file tempo changes. If there are no tempo change in the MIDI file a default value of 120 bpm is used. The tempo
parameter is used as a multiplier factor that must be in the range (0.001 to 1000). For example, if the current MIDI file tempo is 120 bpm and the multiplier value is 0.5 then this tempo will be slowed down to 60 bpm. At creation, the player is set to be controlled by internal tempo with a multiplier factor set to 1.0.
FLUID_PLAYER_TEMPO_EXTERNAL_BPM, the player will be controlled by the external tempo value provided by the tempo parameter in bpm (i.e in quarter notes per minute) which must be in the range (1 to 60000000).
FLUID_PLAYER_TEMPO_EXTERNAL_MIDI, similar as FLUID_PLAYER_TEMPO_EXTERNAL_BPM, but the tempo parameter value is in micro seconds per quarter note which must be in the range (1 to 60000000). Using micro seconds per quarter note is convenient when the tempo value is derived from MIDI clock realtime messages.
int fluid_player_set_tick_callback | ( | fluid_player_t * | player, |
handle_midi_tick_func_t | handler, | ||
void * | handler_data | ||
) |
Add a listener function for every MIDI tick change.
player | MIDI player instance |
handler | Pointer to callback function |
handler_data | Opaque parameter to be sent to the callback function |
This callback is not set by default, but can optionally be changed to a user-defined function for intercepting all MIDI tick changes and react to them with precision.
int fluid_player_stop | ( | fluid_player_t * | player | ) |
Pauses the MIDI playback.
player | MIDI player instance |
It will not rewind to the beginning of the file, use fluid_player_seek() for this purpose.
fluid_player_t* new_fluid_player | ( | fluid_synth_t * | synth | ) |
Create a new MIDI player.
synth | Fluid synthesizer instance to create player for |