libfluidsynth  1.1.11
Typedefs | Functions
seq.h File Reference

MIDI event sequencer. More...

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...
 

Functions

FLUIDSYNTH_API fluid_sequencer_tnew_fluid_sequencer (void)
 Create a new sequencer object which uses the system timer. More...
 
FLUIDSYNTH_API fluid_sequencer_tnew_fluid_sequencer2 (int use_system_timer)
 Create a new sequencer object. More...
 
FLUIDSYNTH_API void delete_fluid_sequencer (fluid_sequencer_t *seq)
 Free a sequencer object. More...
 
FLUIDSYNTH_API int fluid_sequencer_get_use_system_timer (fluid_sequencer_t *seq)
 Check if a sequencer is using the system timer or not. More...
 
FLUIDSYNTH_API 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...
 
FLUIDSYNTH_API void fluid_sequencer_unregister_client (fluid_sequencer_t *seq, fluid_seq_id_t id)
 Unregister a previously registered client. More...
 
FLUIDSYNTH_API int fluid_sequencer_count_clients (fluid_sequencer_t *seq)
 Count a sequencers registered clients. More...
 
FLUIDSYNTH_API 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...
 
FLUIDSYNTH_API char * fluid_sequencer_get_client_name (fluid_sequencer_t *seq, int id)
 Get the name of a registered client. More...
 
FLUIDSYNTH_API int fluid_sequencer_client_is_dest (fluid_sequencer_t *seq, int id)
 Check if a client is a destination client. More...
 
FLUIDSYNTH_API void fluid_sequencer_process (fluid_sequencer_t *seq, unsigned int msec)
 Advance a sequencer that isn't using the system timer. More...
 
FLUIDSYNTH_API void fluid_sequencer_send_now (fluid_sequencer_t *seq, fluid_event_t *evt)
 Send an event immediately. More...
 
FLUIDSYNTH_API 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...
 
FLUIDSYNTH_API 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...
 
FLUIDSYNTH_API unsigned int fluid_sequencer_get_tick (fluid_sequencer_t *seq)
 Get the current tick of a sequencer. More...
 
FLUIDSYNTH_API void fluid_sequencer_set_time_scale (fluid_sequencer_t *seq, double scale)
 Set the time scale of a sequencer. More...
 
FLUIDSYNTH_API double fluid_sequencer_get_time_scale (fluid_sequencer_t *seq)
 Get a sequencer's time scale. More...
 

Detailed Description

MIDI event sequencer.

Typedef Documentation

◆ fluid_event_callback_t

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.

Parameters
timeCurrent sequencer tick value (see fluid_sequencer_get_tick()).
eventThe event being received
seqThe sequencer instance
dataUser defined data registered with the client

Function Documentation

◆ new_fluid_sequencer()

FLUIDSYNTH_API 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.

Returns
New sequencer instance
Examples:
fluidsynth_arpeggio.c, and fluidsynth_metronome.c.

References new_fluid_sequencer2().

◆ new_fluid_sequencer2()

FLUIDSYNTH_API fluid_sequencer_t* new_fluid_sequencer2 ( int  use_system_timer)

Create a new sequencer object.

Parameters
use_system_timerIf TRUE, sequencer will advance at the rate of the system clock. If FALSE, call fluid_sequencer_process() to advance the sequencer.
Returns
New sequencer instance
Since
1.1.0

References fluid_log(), and FLUID_PANIC.

Referenced by new_fluid_sequencer().

◆ delete_fluid_sequencer()

FLUIDSYNTH_API void delete_fluid_sequencer ( fluid_sequencer_t seq)

Free a sequencer object.

Parameters
seqSequencer to delete
Examples:
fluidsynth_arpeggio.c, and fluidsynth_metronome.c.

References fluid_sequencer_unregister_client().

◆ fluid_sequencer_get_use_system_timer()

FLUIDSYNTH_API int fluid_sequencer_get_use_system_timer ( fluid_sequencer_t seq)

Check if a sequencer is using the system timer or not.

Parameters
seqSequencer object
Returns
TRUE if system timer is being used, FALSE otherwise.
Since
1.1.0

Referenced by fluid_sequencer_register_fluidsynth().

◆ fluid_sequencer_register_client()

FLUIDSYNTH_API 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.

Parameters
seqSequencer object
nameName of sequencer client
callbackSequencer client callback or NULL for a source client.
dataUser data to pass to the callback
Returns
Unique sequencer ID or FLUID_FAILED on error

Clients can be sources or destinations of events. Sources don't need to register a callback.

Examples:
fluidsynth_arpeggio.c, and fluidsynth_metronome.c.

References FLUID_FAILED, fluid_log(), and FLUID_PANIC.

Referenced by fluid_sequencer_register_fluidsynth().

◆ fluid_sequencer_unregister_client()

FLUIDSYNTH_API void fluid_sequencer_unregister_client ( fluid_sequencer_t seq,
fluid_seq_id_t  id 
)

Unregister a previously registered client.

Parameters
seqSequencer object
idClient ID as returned by fluid_sequencer_register_client().

References delete_fluid_event(), fluid_event_set_dest(), fluid_event_unregistering(), fluid_sequencer_get_tick(), and new_fluid_event().

Referenced by delete_fluid_sequencer().

◆ fluid_sequencer_count_clients()

FLUIDSYNTH_API int fluid_sequencer_count_clients ( fluid_sequencer_t seq)

Count a sequencers registered clients.

Parameters
seqSequencer object
Returns
Count of sequencer clients.

Referenced by fluid_sequencer_register_fluidsynth().

◆ fluid_sequencer_get_client_id()

FLUIDSYNTH_API 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).

Parameters
seqSequencer object
indexIndex of register client
Returns
Client ID or FLUID_FAILED if not found

References FLUID_FAILED.

Referenced by fluid_sequencer_register_fluidsynth().

◆ fluid_sequencer_get_client_name()

FLUIDSYNTH_API char* fluid_sequencer_get_client_name ( fluid_sequencer_t seq,
int  id 
)

Get the name of a registered client.

Parameters
seqSequencer object
idClient ID
Returns
Client name or NULL if not found. String is internal and should not be modified or freed.

Referenced by fluid_sequencer_register_fluidsynth().

◆ fluid_sequencer_client_is_dest()

FLUIDSYNTH_API int fluid_sequencer_client_is_dest ( fluid_sequencer_t seq,
int  id 
)

Check if a client is a destination client.

Parameters
seqSequencer object
idClient ID
Returns
TRUE if client is a destination client, FALSE otherwise or if not found

◆ fluid_sequencer_process()

FLUIDSYNTH_API void fluid_sequencer_process ( fluid_sequencer_t seq,
unsigned int  msec 
)

◆ fluid_sequencer_send_now()

FLUIDSYNTH_API void fluid_sequencer_send_now ( fluid_sequencer_t seq,
fluid_event_t evt 
)

Send an event immediately.

Parameters
seqSequencer object
evtEvent to send (copied)

References fluid_event_get_dest(), and fluid_sequencer_get_tick().

Referenced by fluid_sequencer_process().

◆ fluid_sequencer_send_at()

FLUIDSYNTH_API 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.

Parameters
seqSequencer object
evtEvent to send
timeTime value in ticks (in milliseconds with the default time scale of 1000).
absoluteTRUE if time is absolute sequencer time (time since sequencer creation), FALSE if relative to current time.
Returns
FLUID_OK on success, FLUID_FAILED otherwise
Examples:
fluidsynth_arpeggio.c, and fluidsynth_metronome.c.

References fluid_sequencer_get_tick().

Referenced by fluid_sequencer_add_midi_event_to_buffer(), and fluid_sequencer_register_fluidsynth().

◆ fluid_sequencer_remove_events()

FLUIDSYNTH_API 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.

Parameters
seqSequencer object
sourceSource client ID to match or -1 for wildcard
destDestination client ID to match or -1 for wildcard
typeEvent type to match or -1 for wildcard (fluid_seq_event_type)

◆ fluid_sequencer_get_tick()

FLUIDSYNTH_API unsigned int fluid_sequencer_get_tick ( fluid_sequencer_t seq)

◆ fluid_sequencer_set_time_scale()

FLUIDSYNTH_API void fluid_sequencer_set_time_scale ( fluid_sequencer_t seq,
double  scale 
)

Set the time scale of a sequencer.

Parameters
seqSequencer object
scaleSequencer scale value in ticks per second (default is 1000 for 1 tick per millisecond, max is 1000.0)

If there are already scheduled events in the sequencer and the scale is changed the events are adjusted accordingly.

References fluid_log(), and FLUID_WARN.

◆ fluid_sequencer_get_time_scale()

FLUIDSYNTH_API double fluid_sequencer_get_time_scale ( fluid_sequencer_t seq)

Get a sequencer's time scale.

Parameters
seqSequencer object.
Returns
Time scale value in ticks per second.

References fluid_event_set_dest(), fluid_event_set_source(), fluid_log(), FLUID_PANIC, fluid_sequencer_get_tick(), and fluid_sequencer_process().