Assume MIDI input port = 64:0, application port = 128:0, and queue for timestamp = 1 with real-time stamp. The application port must have capabilty SND_SEQ_PORT_CAP_WRITE.
void capture_keyboard(snd_seq_t *seq)
{
snd_seq_port_subscribe_t subs;
memset(&subs, 0, sizeof(subs));
subs.sender.client = 64;
subs.sender.port = 0;
subs.dest.client = 128;
subs.dest.port = 0;
subs.queue = 1;
subs.convert_time = 1;
subs.realtime = 1;
snd_seq_subscribe_port(seq, &subs);
}Assume MIDI output port = 65:1 and application port = 128:0. The application port must have capabilty SND_SEQ_PORT_CAP_READ.
void subscribe_output(snd_seq_t *seq)
{
snd_seq_port_subscribe_t subs;
memset(&subs, 0, sizeof(subs));
subs.sender.client = 128;
subs.sender.port = 0;
subs.dest.client = 65;
subs.dest.port = 1;
snd_seq_subscribe_port(seq, &subs);
}
This example can be simplified by using snd_seq_connect_to.
void subscribe_output(snd_seq_t *seq)
{
snd_seq_connect_to(seq, 0, 65, 1);
}Assume connection from application 128:0 to 129:0, and that subscription is done by the third application (130:0). The sender must have capabilities both SND_SEQ_PORT_CAP_READ and SND_SEQ_PORT_READ_SUBS, and the receiver SND_SEQ_PORT_CAP_WRITE and SND_SEQ_PORT_CAP_WRITE_SUBS, respectively.
// ..in the third application (130:0) ..
void coupling(snd_seq_t *seq)
{
snd_seq_port_subscribe_t subs;
memset(&subs, 0, sizeof(subs));
subs.sender.client = 128;
subs.sender.port = 0;
subs.dest.client = 129;
subs.dest.port = 0;
snd_seq_subscribe_port(seq, &subs);
}