Sequencer Middle Level Interface

Overview

Sequencer Middle Level Interface More…

// global functions

int
snd_seq_control_queue(
    snd_seq_t* seq,
    int q,
    int type,
    int value,
    snd_seq_event_t* ev
);

int
snd_seq_create_simple_port(
    snd_seq_t* seq,
    const char* name,
    unsigned int caps,
    unsigned int type
);

int
snd_seq_delete_simple_port(
    snd_seq_t* seq,
    int port
);

int
snd_seq_connect_from(
    snd_seq_t* seq,
    int my_port,
    int src_client,
    int src_port
);

int
snd_seq_connect_to(
    snd_seq_t* seq,
    int my_port,
    int dest_client,
    int dest_port
);

int
snd_seq_disconnect_from(
    snd_seq_t* seq,
    int my_port,
    int src_client,
    int src_port
);

int
snd_seq_disconnect_to(
    snd_seq_t* seq,
    int my_port,
    int dest_client,
    int dest_port
);

int
snd_seq_set_client_name(
    snd_seq_t* seq,
    const char* name
);

int
snd_seq_set_client_event_filter(
    snd_seq_t* seq,
    int event_type
);

int
snd_seq_set_client_pool_output(
    snd_seq_t* seq,
    size_t size
);

int
snd_seq_set_client_pool_output_room(
    snd_seq_t* seq,
    size_t size
);

int
snd_seq_set_client_pool_input(
    snd_seq_t* seq,
    size_t size
);

int
snd_seq_sync_output_queue(snd_seq_t* seq);

int
snd_seq_parse_address(
    snd_seq_t* seq,
    snd_seq_addr_t* addr,
    const char* str
);

int
snd_seq_reset_pool_output(snd_seq_t* seq);

int
snd_seq_reset_pool_input(snd_seq_t* seq);

// macros

#define snd_seq_change_queue_tempo( \
    seq, \
    q, \
    tempo, \
    ev \
)

#define snd_seq_continue_queue( \
    seq, \
    q, \
    ev \
)

#define snd_seq_ev_clear(ev)

#define snd_seq_ev_schedule_real( \
    ev, \
    q, \
    relative, \
    rtime \
)

#define snd_seq_ev_schedule_tick( \
    ev, \
    q, \
    relative, \
    ttick \
)

#define snd_seq_ev_set_broadcast(ev)

#define snd_seq_ev_set_chanpress( \
    ev, \
    ch, \
    val \
)

#define snd_seq_ev_set_controller( \
    ev, \
    ch, \
    cc, \
    val \
)

#define snd_seq_ev_set_dest( \
    ev, \
    c, \
    p \
)

#define snd_seq_ev_set_direct(ev)
#define snd_seq_ev_set_fixed(ev)

#define snd_seq_ev_set_keypress( \
    ev, \
    ch, \
    key, \
    vel \
)

#define snd_seq_ev_set_note( \
    ev, \
    ch, \
    key, \
    vel, \
    dur \
)

#define snd_seq_ev_set_noteoff( \
    ev, \
    ch, \
    key, \
    vel \
)

#define snd_seq_ev_set_noteon( \
    ev, \
    ch, \
    key, \
    vel \
)

#define snd_seq_ev_set_pgmchange( \
    ev, \
    ch, \
    val \
)

#define snd_seq_ev_set_pitchbend( \
    ev, \
    ch, \
    val \
)

#define snd_seq_ev_set_priority( \
    ev, \
    high_prior \
)

#define snd_seq_ev_set_queue_continue( \
    ev, \
    q \
)

#define snd_seq_ev_set_queue_control( \
    ev, \
    typ, \
    q, \
    val \
)

#define snd_seq_ev_set_queue_pos_real( \
    ev, \
    q, \
    rtime \
)

#define snd_seq_ev_set_queue_pos_tick( \
    ev, \
    q, \
    ttime \
)

#define snd_seq_ev_set_queue_start( \
    ev, \
    q \
)

#define snd_seq_ev_set_queue_stop( \
    ev, \
    q \
)

#define snd_seq_ev_set_queue_tempo( \
    ev, \
    q, \
    val \
)

#define snd_seq_ev_set_source( \
    ev, \
    p \
)

#define snd_seq_ev_set_subs(ev)

#define snd_seq_ev_set_sysex( \
    ev, \
    datalen, \
    dataptr \
)

#define snd_seq_ev_set_tag( \
    ev, \
    t \
)

#define snd_seq_ev_set_variable( \
    ev, \
    datalen, \
    dataptr \
)

#define snd_seq_ev_set_varusr( \
    ev, \
    datalen, \
    dataptr \
)

#define snd_seq_start_queue( \
    seq, \
    q, \
    ev \
)

#define snd_seq_stop_queue( \
    seq, \
    q, \
    ev \
)

Detailed Documentation

Sequencer Middle Level Interface

Global Functions

int
snd_seq_control_queue(
    snd_seq_t* seq,
    int q,
    int type,
    int value,
    snd_seq_event_t* ev
)

queue controls - start/stop/continue

This function sets up general queue control event and sends it. To send at scheduled time, set the schedule in ev. If ev is NULL, the event is composed locally and sent immediately to the specified queue. In any cases, you need to call snd_seq_drain_output() appropriately to feed the event.

Parameters:

seq sequencer handle
q queue id to control
type event type
value event value
ev event instance

See also:

snd_seq_alloc_queue()

int
snd_seq_create_simple_port(
    snd_seq_t* seq,
    const char* name,
    unsigned int caps,
    unsigned int type
)

create a port - simple version

Creates a port with the given capability and type bits.

Parameters:

seq sequencer handle
name the name of the port
caps capability bits
type type bits

Returns:

the created port number or negative error code

See also:

snd_seq_create_port(), snd_seq_delete_simple_port()

int
snd_seq_delete_simple_port(
    snd_seq_t* seq,
    int port
)

delete the port

Parameters:

seq sequencer handle
port port id

Returns:

0 on success or negative error code

See also:

snd_seq_delete_port(), snd_seq_create_simple_port()

int
snd_seq_connect_from(
    snd_seq_t* seq,
    int my_port,
    int src_client,
    int src_port
)

simple subscription (w/o exclusive & time conversion)

Connect from the given sender client:port to the given destination port in the current client.

Parameters:

seq sequencer handle
myport the port id as receiver
src_client sender client id
src_port sender port id

Returns:

0 on success or negative error code

See also:

snd_seq_subscribe_port(), snd_seq_disconnect_from()

int
snd_seq_connect_to(
    snd_seq_t* seq,
    int my_port,
    int dest_client,
    int dest_port
)

simple subscription (w/o exclusive & time conversion)

Connect from the given receiver port in the current client to the given destination client:port.

Parameters:

seq sequencer handle
myport the port id as sender
dest_client destination client id
dest_port destination port id

Returns:

0 on success or negative error code

See also:

snd_seq_subscribe_port(), snd_seq_disconnect_to()

int
snd_seq_disconnect_from(
    snd_seq_t* seq,
    int my_port,
    int src_client,
    int src_port
)

simple disconnection

Remove connection from the given sender client:port to the given destination port in the current client.

Parameters:

seq sequencer handle
myport the port id as receiver
src_client sender client id
src_port sender port id

Returns:

0 on success or negative error code

See also:

snd_seq_unsubscribe_port(), snd_seq_connect_from()

int
snd_seq_disconnect_to(
    snd_seq_t* seq,
    int my_port,
    int dest_client,
    int dest_port
)

simple disconnection

Remove connection from the given sender client:port to the given destination port in the current client.

Parameters:

seq sequencer handle
myport the port id as sender
dest_client destination client id
dest_port destination port id

Returns:

0 on success or negative error code

See also:

snd_seq_unsubscribe_port(), snd_seq_connect_to()

int
snd_seq_set_client_name(
    snd_seq_t* seq,
    const char* name
)

set client name

Parameters:

seq sequencer handle
name name string

Returns:

0 on success or negative error code

See also:

snd_seq_set_client_info()

int
snd_seq_set_client_event_filter(
    snd_seq_t* seq,
    int event_type
)

add client event filter

Parameters:

seq sequencer handle
event_type event type to be added

Returns:

0 on success or negative error code

See also:

snd_seq_set_client_info()

int
snd_seq_set_client_pool_output(
    snd_seq_t* seq,
    size_t size
)

change the output pool size of the given client

Parameters:

seq sequencer handle
size output pool size

Returns:

0 on success or negative error code

See also:

snd_seq_set_client_pool()

int
snd_seq_set_client_pool_output_room(
    snd_seq_t* seq,
    size_t size
)

change the output room size of the given client

Parameters:

seq sequencer handle
size output room size

Returns:

0 on success or negative error code

See also:

snd_seq_set_client_pool()

int
snd_seq_set_client_pool_input(
    snd_seq_t* seq,
    size_t size
)

change the input pool size of the given client

Parameters:

seq sequencer handle
size input pool size

Returns:

0 on success or negative error code

See also:

snd_seq_set_client_pool()

int
snd_seq_sync_output_queue(snd_seq_t* seq)

wait until all events are processed

This function waits until all events of this client are processed.

Parameters:

seq sequencer handle

Returns:

0 on success or negative error code

See also:

snd_seq_drain_output()

int
snd_seq_parse_address(
    snd_seq_t* seq,
    snd_seq_addr_t* addr,
    const char* str
)

parse the given string and get the sequencer address

This function parses the sequencer client and port numbers from the given string. The client and port tokens are separated by either colon or period, e.g. 128:1. When seq is not NULL, the function accepts also a client name not only digit numbers. Actually arg need to be only a prefix of the wanted client. That is, if a client named “Foobar XXL Master 2012” with number 128 is available, then parsing “Foobar” will return the address 128:0 if no other client is an exact match.

Parameters:

seq sequencer handle
addr the address pointer to be returned
arg the string to be parsed

Returns:

0 on success or negative error code

int
snd_seq_reset_pool_output(snd_seq_t* seq)

reset client output pool

So far, this works identically like snd_seq_drop_output().

Parameters:

seq sequencer handle

Returns:

0 on success or negative error code

int
snd_seq_reset_pool_input(snd_seq_t* seq)

reset client input pool

So far, this works identically like snd_seq_drop_input().

Parameters:

seq sequencer handle

Returns:

0 on success or negative error code

Macros

#define snd_seq_change_queue_tempo( \
    seq, \
    q, \
    tempo, \
    ev \
)

change the tempo of the specified queue

Parameters:

seq sequencer handle
q queue id
tempo the new tempo value
ev optional event record (see snd_seq_control_queue)
#define snd_seq_continue_queue( \
    seq, \
    q, \
    ev \
)

continue the specified queue

Parameters:

seq sequencer handle
q queue id to continue
ev optional event record (see snd_seq_control_queue)
#define snd_seq_ev_clear(ev)

initialize event record

This macro clears the given event record pointer to the default status.

Parameters:

ev event record pointer
#define snd_seq_ev_schedule_real( \
    ev, \
    q, \
    relative, \
    rtime \
)

set real-time-scheduling mode on queue

This macro sets the scheduling of the event in the realtime mode.

Parameters:

ev event instance
q queue id to schedule
relative relative time-stamp if non-zero
rtime time-stamp to be delivered

See also:

snd_seq_ev_schedule_tick(), snd_seq_ev_set_direct()

#define snd_seq_ev_schedule_tick( \
    ev, \
    q, \
    relative, \
    ttick \
)

set tick-scheduling mode on queue

This macro sets the scheduling of the event in the MIDI tick mode.

Parameters:

ev event instance
q queue id to schedule
relative relative time-stamp if non-zero
ttick tick time-stamp to be delivered

See also:

snd_seq_ev_schedule_real(), snd_seq_ev_set_direct()

#define snd_seq_ev_set_broadcast(ev)

set broadcasting to all clients/ports

This macro sets the destination as the broadcasting.

Parameters:

ev event record

See also:

snd_seq_ev_set_dest()

#define snd_seq_ev_set_chanpress( \
    ev, \
    ch, \
    val \
)

set channel pressure event

Parameters:

ev event record
ch channel number
val channel pressure value
#define snd_seq_ev_set_controller( \
    ev, \
    ch, \
    cc, \
    val \
)

set MIDI controller event

Parameters:

ev event record
ch channel number
cc controller number
val control value
#define snd_seq_ev_set_dest( \
    ev, \
    c, \
    p \
)

set the explicit destination

This macro sets the client and port id numbers to the given event record.

Parameters:

ev event record
c destination client id
p destination port id

See also:

snd_seq_ev_set_subs()

#define snd_seq_ev_set_direct(ev)

set direct passing mode (without queued)

This macro sets the event to the direct passing mode to be delivered immediately without queueing.

Parameters:

ev event instance

See also:

snd_seq_ev_schedule_tick(), snd_seq_ev_schedule_real()

#define snd_seq_ev_set_fixed(ev)

set fixed data

Sets the event length mode as fixed size.

Parameters:

ev event instance

See also:

snd_seq_ev_set_variable(), snd_seq_ev_set_varusr()

#define snd_seq_ev_set_keypress( \
    ev, \
    ch, \
    key, \
    vel \
)

set key-pressure event

Parameters:

ev event record
ch channel number
key note key
vel velocity
#define snd_seq_ev_set_note( \
    ev, \
    ch, \
    key, \
    vel, \
    dur \
)

set note event

Parameters:

ev event record
ch channel number
key note key
vel velocity
dur duration (in tick or msec)
#define snd_seq_ev_set_noteoff( \
    ev, \
    ch, \
    key, \
    vel \
)

set note-off event

Parameters:

ev event record
ch channel number
key note key
vel velocity
#define snd_seq_ev_set_noteon( \
    ev, \
    ch, \
    key, \
    vel \
)

set note-on event

Parameters:

ev event record
ch channel number
key note key
vel velocity
#define snd_seq_ev_set_pgmchange( \
    ev, \
    ch, \
    val \
)

set program change event

Parameters:

ev event record
ch channel number
val program number
#define snd_seq_ev_set_pitchbend( \
    ev, \
    ch, \
    val \
)

set pitch-bend event

Parameters:

ev event record
ch channel number
val pitch bend; zero centered from -8192 to 8191
#define snd_seq_ev_set_priority( \
    ev, \
    high_prior \
)

set event priority

Parameters:

ev event instance
high_prior 1 for high priority mode
#define snd_seq_ev_set_queue_continue( \
    ev, \
    q \
)

set the stop queue event

Parameters:

ev event record
q queue id to continue

See also:

snd_seq_ev_set_queue_start(), snd_seq_ev_set_queue_stop()

#define snd_seq_ev_set_queue_control( \
    ev, \
    typ, \
    q, \
    val \
)

set queue controls

Parameters:

ev event record
typ event type
q queue id
val control value
#define snd_seq_ev_set_queue_pos_real( \
    ev, \
    q, \
    rtime \
)

set the real-time position of a queue

Parameters:

ev event record
q queue id to change tempo
rtime the new real-time pointer
#define snd_seq_ev_set_queue_pos_tick( \
    ev, \
    q, \
    ttime \
)

set the tick-time position of a queue

Parameters:

ev event record
q queue id to change tempo
ttime the new tick-time
#define snd_seq_ev_set_queue_start( \
    ev, \
    q \
)

set the start queue event

Parameters:

ev event record
q queue id to start

See also:

snd_seq_ev_set_queue_stop(), snd_seq_ev_set_queue_continue()

#define snd_seq_ev_set_queue_stop( \
    ev, \
    q \
)

set the stop queue event

Parameters:

ev event record
q queue id to stop

See also:

snd_seq_ev_set_queue_start(), snd_seq_ev_set_queue_continue()

#define snd_seq_ev_set_queue_tempo( \
    ev, \
    q, \
    val \
)

set the stop queue event

Parameters:

ev event record
q queue id to change tempo
val the new tempo value
#define snd_seq_ev_set_source( \
    ev, \
    p \
)

set the source port

This macro sets the source port id number.

Parameters:

ev event record
p source port id
#define snd_seq_ev_set_subs(ev)

set broadcasting to subscribers

This macro sets the destination as the subscribers.

Parameters:

ev event record

See also:

snd_seq_ev_set_dest()

#define snd_seq_ev_set_sysex( \
    ev, \
    datalen, \
    dataptr \
)

set sysex event

the sysex data must contain the start byte 0xf0 and the end byte 0xf7.

Parameters:

ev event record
datalen length of sysex data
dataptr sysex data pointer
#define snd_seq_ev_set_tag( \
    ev, \
    t \
)

set the tag for given event

This macro sets the tag to the given event record.

Parameters:

ev event record
t event tag
#define snd_seq_ev_set_variable( \
    ev, \
    datalen, \
    dataptr \
)

set variable data

Sets the event length mode as variable length and stores the data.

Parameters:

ev event instance
datalen length of the external data
dataptr pointer of the external data

See also:

snd_seq_ev_set_fixed(), snd_seq_ev_set_varusr()

#define snd_seq_ev_set_varusr( \
    ev, \
    datalen, \
    dataptr \
)

set varusr data

Sets the event length mode as variable user-space data and stores the data.

Parameters:

ev event instance
datalen length of the external data
dataptr pointer of the external data

See also:

snd_seq_ev_set_fixed(), snd_seq_ev_set_variable()

#define snd_seq_start_queue( \
    seq, \
    q, \
    ev \
)

start the specified queue

Parameters:

seq sequencer handle
q queue id to start
ev optional event record (see snd_seq_control_queue)
#define snd_seq_stop_queue( \
    seq, \
    q, \
    ev \
)

stop the specified queue

Parameters:

seq sequencer handle
q queue id to stop
ev optional event record (see snd_seq_control_queue)