To send some events at a specific time:
- open the sequencer;
- create your own (source) port;
- construct and send some events.
To open the sequencer, call snd_seq_open
.
(You can get your client number with snd_seq_client_id
.)
snd_seq_t seq;
snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, 0);
To create a port, allocate a port info object with
snd_seq_port_info_alloca
, set port parameters with
snd_seq_port_info_set_
xxx, and call snd_seq_create_port
.
Or simply call snd_seq_create_simple_port
.
int port;
port = snd_seq_create_simple_port(seq, "my port",
SND_SEQ_PORT_CAP_READ | SND_SEQ_POR_CAP_WRITE,
SND_SEQ_PORT_TYPE_APPLICATION);
To send an event, allocate an event structure (just
for a change, you can use a local snd_seq_event_t
variable),
and call various snd_seq_ev_
xxx functions to set its properties.
Then call snd_seq_event_output
, and snd_seq_drain_output
after you've sent all
events.
snd_seq_event_t ev;
snd_seq_ev_clear(&ev);
snd_seq_ev_set_direct(&ev);
/* either */
snd_seq_ev_set_dest(&ev, 64, 0); /* send to 64:0 */
/* or */
snd_seq_ev_set_subs(&ev); /* send to subscribers of source port */
snd_seq_ev_set_noteon(&ev, 0, 60, 127);
snd_seq_event_output(seq, &ev);
snd_seq_ev_set_noteon(&ev, 0, 67, 127);
snd_seq_event_output(seq, &ev);
snd_seq_drain_output(seq);