Chapter 7. Events

Table of Contents
Structure of an event
Scheduling queue
Time stamp
Source and destination addresses
Data storage type
Scheduling priority
Event flags

Messaging between clients is performed by sending events from one client to another. These events contain high-level MIDI oriented messages or sequencer specific messages.

All the sequencer events are stored in a sequencer event record, snd_seq_event_t. Application can send and receive these event records to/from other clients via sequencer.

An event has several stroage types according to its usage. For example, a SYSEX message is stored on the variable length event, and a large synth sample data is delivered using a user-space data pointer.

Structure of an event

An event consists of the following items:

The actual implementation looks like below:

typedef struct snd_seq_event snd_seq_event_t;
struct snd_seq_event {
	snd_seq_event_type type;	/* event type */
	unsigned char flags;		/* event flags */
	char tag;			/* arbitrary tag */
	
	unsigned char queue;		/* schedule queue */
	snd_seq_timestamp_t time;	/* schedule time */


	snd_seq_addr_t source;		/* source address */
	snd_seq_addr_t dest;		/* destination address */

	union {				/* event data... */
		snd_seq_ev_note note;
		snd_seq_ev_ctrl control;
		snd_seq_ev_raw8 raw8;
		snd_seq_ev_raw32 raw32;
		snd_seq_ev_ext ext;
		snd_seq_ev_ipcshm ipcshm;
		snd_seq_ev_queue_control_t queue;
		snd_seq_timestamp_t time;
		snd_seq_addr_t addr;
		snd_seq_result_t result;
		snd_seq_ev_instr_begin_t instr_begin;
		snd_seq_ev_sample_control_t sample;
		snd_seq_ev_quote_t quote;
	} data;
};

The record has 56 byte length. The type field contains the type of the event (1 byte). The flags field consists of bit flags which describe several contains conditions of the event (1 byte). It includes the time-stamp mode, data storage type, and scheduling prority. The tag field is an arbitrary tag. This tag can used for removing a distinct event from the event queue via snd_seq_remove_events. The queue field is the queue id for scheduling. The source and dest fields are source and destination addresses. The data field is a union of event data.