libfluidsynth
2.4.5
|
MIDI event sequencer. More...
Modules | |
Sequencer Events | |
Create, modify, query and destroy sequencer events. | |
Typedefs | |
typedef void(* | fluid_event_callback_t) (unsigned int time, fluid_event_t *event, fluid_sequencer_t *seq, void *data) |
Event callback prototype for destination clients. More... | |
Lifecycle Functions for MIDI Sequencer_linebr@{ | |
fluid_sequencer_t * | new_fluid_sequencer (void) |
Create a new sequencer object which uses the system timer. More... | |
fluid_sequencer_t * | new_fluid_sequencer2 (int use_system_timer) |
Create a new sequencer object. More... | |
void | delete_fluid_sequencer (fluid_sequencer_t *seq) |
Free a sequencer object. More... | |
Functions | |
int | fluid_sequencer_add_midi_event_to_buffer (void *data, fluid_midi_event_t *event) |
Transforms an incoming MIDI event (from a MIDI driver or MIDI router) to a sequencer event and adds it to the sequencer queue for sending as soon as possible. More... | |
int | fluid_sequencer_client_is_dest (fluid_sequencer_t *seq, fluid_seq_id_t id) |
Check if a client is a destination client. More... | |
int | fluid_sequencer_count_clients (fluid_sequencer_t *seq) |
Count a sequencers registered clients. More... | |
fluid_seq_id_t | fluid_sequencer_get_client_id (fluid_sequencer_t *seq, int index) |
Get a client ID from its index (order in which it was registered). More... | |
char * | fluid_sequencer_get_client_name (fluid_sequencer_t *seq, fluid_seq_id_t id) |
Get the name of a registered client. More... | |
unsigned int | fluid_sequencer_get_tick (fluid_sequencer_t *seq) |
Get the current tick of the sequencer scaled by the time scale currently set. More... | |
double | fluid_sequencer_get_time_scale (fluid_sequencer_t *seq) |
Get a sequencer's time scale. More... | |
int | fluid_sequencer_get_use_system_timer (fluid_sequencer_t *seq) |
Check if a sequencer is using the system timer or not. More... | |
void | fluid_sequencer_process (fluid_sequencer_t *seq, unsigned int msec) |
Advance a sequencer. More... | |
fluid_seq_id_t | fluid_sequencer_register_client (fluid_sequencer_t *seq, const char *name, fluid_event_callback_t callback, void *data) |
Register a sequencer client. More... | |
fluid_seq_id_t | fluid_sequencer_register_fluidsynth (fluid_sequencer_t *seq, fluid_synth_t *synth) |
Registers a synthesizer as a destination client of the given sequencer. More... | |
void | fluid_sequencer_remove_events (fluid_sequencer_t *seq, fluid_seq_id_t source, fluid_seq_id_t dest, int type) |
Remove events from the event queue. More... | |
int | fluid_sequencer_send_at (fluid_sequencer_t *seq, fluid_event_t *evt, unsigned int time, int absolute) |
Schedule an event for sending at a later time. More... | |
void | fluid_sequencer_send_now (fluid_sequencer_t *seq, fluid_event_t *evt) |
Send an event immediately. More... | |
void | fluid_sequencer_set_time_scale (fluid_sequencer_t *seq, double scale) |
Set the time scale of a sequencer. More... | |
void | fluid_sequencer_unregister_client (fluid_sequencer_t *seq, fluid_seq_id_t id) |
Unregister a previously registered client. More... | |
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.
typedef void(* fluid_event_callback_t) (unsigned int time, fluid_event_t *event, fluid_sequencer_t *seq, void *data) |
Event callback prototype for destination clients.
time | Current sequencer tick value (see fluid_sequencer_get_tick()). |
event | The event being received |
seq | The sequencer instance |
data | User defined data registered with the client |
time
may not be of the same tick value as the scheduled event! In fact, depending on the sequencer's scale and the synth's sample-rate, time
may be a few ticks too late. Although this itself is inaudible, it is important to consider, when you use this callback for enqueuing additional events over and over again with fluid_sequencer_send_at(): If you enqueue new events with a relative tick value you might introduce a timing error, which causes your sequence to sound e.g. slower than it's supposed to be. If this is your use-case, make sure to enqueue events with an absolute tick value. void delete_fluid_sequencer | ( | fluid_sequencer_t * | seq | ) |
Free a sequencer object.
seq | Sequencer to delete |
int fluid_sequencer_add_midi_event_to_buffer | ( | void * | data, |
fluid_midi_event_t * | event | ||
) |
Transforms an incoming MIDI event (from a MIDI driver or MIDI router) to a sequencer event and adds it to the sequencer queue for sending as soon as possible.
data | The sequencer, must be a valid fluid_sequencer_t |
event | MIDI event |
The signature of this function is of type handle_midi_event_func_t.
int fluid_sequencer_client_is_dest | ( | fluid_sequencer_t * | seq, |
fluid_seq_id_t | id | ||
) |
Check if a client is a destination client.
seq | Sequencer object |
id | Client ID |
int fluid_sequencer_count_clients | ( | fluid_sequencer_t * | seq | ) |
Count a sequencers registered clients.
seq | Sequencer object |
fluid_seq_id_t fluid_sequencer_get_client_id | ( | fluid_sequencer_t * | seq, |
int | index | ||
) |
Get a client ID from its index (order in which it was registered).
seq | Sequencer object |
index | Index of register client |
char* fluid_sequencer_get_client_name | ( | fluid_sequencer_t * | seq, |
fluid_seq_id_t | id | ||
) |
Get the name of a registered client.
seq | Sequencer object |
id | Client ID |
unsigned int fluid_sequencer_get_tick | ( | fluid_sequencer_t * | seq | ) |
Get the current tick of the sequencer scaled by the time scale currently set.
seq | Sequencer object |
double fluid_sequencer_get_time_scale | ( | fluid_sequencer_t * | seq | ) |
Get a sequencer's time scale.
seq | Sequencer object. |
int fluid_sequencer_get_use_system_timer | ( | fluid_sequencer_t * | seq | ) |
Check if a sequencer is using the system timer or not.
seq | Sequencer object |
void fluid_sequencer_process | ( | fluid_sequencer_t * | seq, |
unsigned int | msec | ||
) |
Advance a sequencer.
seq | Sequencer object |
msec | Time to advance sequencer to (absolute time since sequencer start). |
If you have registered the synthesizer as client (fluid_sequencer_register_fluidsynth()), the synth will take care of calling fluid_sequencer_process(). Otherwise it is up to the user to advance the sequencer manually.
fluid_seq_id_t fluid_sequencer_register_client | ( | fluid_sequencer_t * | seq, |
const char * | name, | ||
fluid_event_callback_t | callback, | ||
void * | data | ||
) |
Register a sequencer client.
seq | Sequencer object |
name | Name of sequencer client |
callback | Sequencer client callback or NULL for a source client. |
data | User data to pass to the callback |
Clients can be sources or destinations of events. Sources don't need to register a callback.
fluid_seq_id_t fluid_sequencer_register_fluidsynth | ( | fluid_sequencer_t * | seq, |
fluid_synth_t * | synth | ||
) |
Registers a synthesizer as a destination client of the given sequencer.
seq | Sequencer instance |
synth | Synthesizer instance |
A convenience wrapper function around fluid_sequencer_register_client(), that allows you to easily process and render enqueued sequencer events with fluidsynth's synthesizer. The client being registered will be named fluidsynth
.
void fluid_sequencer_remove_events | ( | fluid_sequencer_t * | seq, |
fluid_seq_id_t | source, | ||
fluid_seq_id_t | dest, | ||
int | type | ||
) |
Remove events from the event queue.
seq | Sequencer object |
source | Source client ID to match or -1 for wildcard |
dest | Destination client ID to match or -1 for wildcard |
type | Event type to match or -1 for wildcard (fluid_seq_event_type) |
int fluid_sequencer_send_at | ( | fluid_sequencer_t * | seq, |
fluid_event_t * | evt, | ||
unsigned int | time, | ||
int | absolute | ||
) |
Schedule an event for sending at a later time.
seq | Sequencer object |
evt | Event to send (will be copied into internal queue) |
time | Time value in ticks (in milliseconds with the default time scale of 1000). |
absolute | TRUE if time is absolute sequencer time (time since sequencer creation), FALSE if relative to current time. |
time
. For events that have the same timestamp, fluidsynth (as of version 2.2.0) uses the following order, according to which events will be dispatched to the client's callback function.void fluid_sequencer_send_now | ( | fluid_sequencer_t * | seq, |
fluid_event_t * | evt | ||
) |
Send an event immediately.
seq | Sequencer object |
evt | Event to send (not copied, used directly) |
void fluid_sequencer_set_time_scale | ( | fluid_sequencer_t * | seq, |
double | scale | ||
) |
Set the time scale of a sequencer.
seq | Sequencer object |
scale | Sequencer scale value in ticks per second (default is 1000 for 1 tick per millisecond) |
If there are already scheduled events in the sequencer and the scale is changed the events are adjusted accordingly.
void fluid_sequencer_unregister_client | ( | fluid_sequencer_t * | seq, |
fluid_seq_id_t | id | ||
) |
Unregister a previously registered client.
seq | Sequencer object |
id | Client ID as returned by fluid_sequencer_register_client(). |
The client's callback function will receive a FLUID_SEQ_UNREGISTERING event right before it is being unregistered.
fluid_sequencer_t* new_fluid_sequencer | ( | void | ) |
Create a new sequencer object which uses the system timer.
Use new_fluid_sequencer2() to specify whether the system timer or fluid_sequencer_process() is used to advance the sequencer.
fluid_sequencer_t* new_fluid_sequencer2 | ( | int | use_system_timer | ) |
Create a new sequencer object.
use_system_timer | If TRUE, sequencer will advance at the rate of the system clock. If FALSE, call fluid_sequencer_process() to advance the sequencer. |