ALSA project - the C library reference

Loading...
Searching...
No Matches
seqmid.h
Go to the documentation of this file.
1
11/*
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as
14 * published by the Free Software Foundation; either version 2.1 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 *
26 */
27
28#if !defined(__ASOUNDLIB_H) && !defined(ALSA_LIBRARY_BUILD)
29/* don't use ALSA_LIBRARY_BUILD define in sources outside alsa-lib */
30#warning "use #include <alsa/asoundlib.h>, <alsa/seqmid.h> should not be used directly"
31#include <alsa/asoundlib.h>
32#endif
33
34#ifndef __ALSA_SEQMID_H
35#define __ALSA_SEQMID_H
37#ifdef __cplusplus
38 extern "C" {
39#endif
40
54 static inline void snd_seq_ev_clear(snd_seq_event_t *ev)
55{
56 memset(ev, 0, sizeof(*ev));
57}
58
65 static inline void snd_seq_ump_ev_clear(snd_seq_ump_event_t *ev)
66{
67 memset(ev, 0, sizeof(*ev));
68}
69
77#define snd_seq_ev_set_tag(ev,t) \
78 ((ev)->tag = (t))
79
90#define snd_seq_ev_set_dest(ev,c,p) \
91 ((ev)->dest.client = (c), (ev)->dest.port = (p))
92
101#define snd_seq_ev_set_subs(ev) \
102 ((ev)->dest.client = SND_SEQ_ADDRESS_SUBSCRIBERS,\
103 (ev)->dest.port = SND_SEQ_ADDRESS_UNKNOWN)
104
113#define snd_seq_ev_set_broadcast(ev) \
114 ((ev)->dest.client = SND_SEQ_ADDRESS_BROADCAST,\
115 (ev)->dest.port = SND_SEQ_ADDRESS_BROADCAST)
116
124#define snd_seq_ev_set_source(ev,p) \
125 ((ev)->source.port = (p))
126
136#define snd_seq_ev_set_direct(ev) \
137 ((ev)->queue = SND_SEQ_QUEUE_DIRECT)
138
151#define snd_seq_ev_schedule_tick(ev, q, relative, ttick) \
152 ((ev)->flags &= ~(SND_SEQ_TIME_STAMP_MASK | SND_SEQ_TIME_MODE_MASK),\
153 (ev)->flags |= SND_SEQ_TIME_STAMP_TICK,\
154 (ev)->flags |= (relative) ? SND_SEQ_TIME_MODE_REL : SND_SEQ_TIME_MODE_ABS,\
155 (ev)->time.tick = (ttick),\
156 (ev)->queue = (q))
157
170#define snd_seq_ev_schedule_real(ev, q, relative, rtime) \
171 ((ev)->flags &= ~(SND_SEQ_TIME_STAMP_MASK | SND_SEQ_TIME_MODE_MASK),\
172 (ev)->flags |= SND_SEQ_TIME_STAMP_REAL,\
173 (ev)->flags |= (relative) ? SND_SEQ_TIME_MODE_REL : SND_SEQ_TIME_MODE_ABS,\
174 (ev)->time.time = *(rtime),\
175 (ev)->queue = (q))
176
182#define snd_seq_ev_set_priority(ev, high_prior) \
183 ((ev)->flags &= ~SND_SEQ_PRIORITY_MASK,\
184 (ev)->flags |= (high_prior) ? SND_SEQ_PRIORITY_HIGH : SND_SEQ_PRIORITY_NORMAL)
185
194#define snd_seq_ev_set_fixed(ev) \
195 ((ev)->flags &= ~SND_SEQ_EVENT_LENGTH_MASK,\
196 (ev)->flags |= SND_SEQ_EVENT_LENGTH_FIXED)
197
208#define snd_seq_ev_set_variable(ev, datalen, dataptr) \
209 ((ev)->flags &= ~SND_SEQ_EVENT_LENGTH_MASK,\
210 (ev)->flags |= SND_SEQ_EVENT_LENGTH_VARIABLE,\
211 (ev)->data.ext.len = (datalen),\
212 (ev)->data.ext.ptr = (dataptr))
213
224#define snd_seq_ev_set_varusr(ev, datalen, dataptr) \
225 ((ev)->flags &= ~SND_SEQ_EVENT_LENGTH_MASK,\
226 (ev)->flags |= SND_SEQ_EVENT_LENGTH_VARUSR,\
227 (ev)->data.ext.len = (datalen),\
228 (ev)->data.ext.ptr = (dataptr))
229
237#define snd_seq_ev_set_queue_control(ev, typ, q, val) \
238 ((ev)->type = (typ),\
239 snd_seq_ev_set_dest(ev, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER),\
240 (ev)->data.queue.queue = (q),\
241 (ev)->data.queue.param.value = (val))
242
250#define snd_seq_ev_set_queue_start(ev, q) \
251 snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_START, q, 0)
252
260#define snd_seq_ev_set_queue_stop(ev, q) \
261 snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_STOP, q, 0)
262
270#define snd_seq_ev_set_queue_continue(ev, q) \
271 snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_CONTINUE, q, 0)
272
279#define snd_seq_ev_set_queue_tempo(ev, q, val) \
280 snd_seq_ev_set_queue_control(ev, SND_SEQ_EVENT_TEMPO, q, val)
281
288#define snd_seq_ev_set_queue_pos_real(ev, q, rtime) \
289 ((ev)->type = SND_SEQ_EVENT_SETPOS_TIME,\
290 snd_seq_ev_set_dest(ev, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER),\
291 (ev)->data.queue.queue = (q),\
292 (ev)->data.queue.param.time.time = *(rtime))
293
300#define snd_seq_ev_set_queue_pos_tick(ev, q, ttime) \
301 ((ev)->type = SND_SEQ_EVENT_SETPOS_TICK,\
302 snd_seq_ev_set_dest(ev, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_TIMER),\
303 (ev)->data.queue.queue = (q),\
304 (ev)->data.queue.param.time.tick = (ttime))
305
310 static inline void snd_seq_ev_set_ump(snd_seq_ump_event_t *ev)
311{
312 ev->flags |= SND_SEQ_EVENT_UMP;
313 ev->type = 0; /* unused for UMP */
314}
315
322 static inline int snd_seq_ev_set_ump_data(snd_seq_ump_event_t *ev, void *data, size_t bytes)
323{
324 if (bytes > 16)
325 return -EINVAL;
326 snd_seq_ev_set_ump(ev);
327 memcpy(ev->ump, data, bytes);
328 return 0;
329}
330
331/* set and send a queue control event */
332 int snd_seq_control_queue(snd_seq_t *seq, int q, int type, int value, snd_seq_event_t *ev);
333
340#define snd_seq_start_queue(seq, q, ev) \
341 snd_seq_control_queue(seq, q, SND_SEQ_EVENT_START, 0, ev)
342
349#define snd_seq_stop_queue(seq, q, ev) \
350 snd_seq_control_queue(seq, q, SND_SEQ_EVENT_STOP, 0, ev)
351
358#define snd_seq_continue_queue(seq, q, ev) \
359 snd_seq_control_queue(seq, q, SND_SEQ_EVENT_CONTINUE, 0, ev)
360
368#define snd_seq_change_queue_tempo(seq, q, tempo, ev) \
369 snd_seq_control_queue(seq, q, SND_SEQ_EVENT_TEMPO, tempo, ev)
370
371/* create a port - simple version - return the port number */
372 int snd_seq_create_simple_port(snd_seq_t *seq, const char *name,
373 unsigned int caps, unsigned int type);
374/* delete the port */
375 int snd_seq_delete_simple_port(snd_seq_t *seq, int port);
376
377/* simple subscription between this port and another port
378 (w/o exclusive & time conversion)
379 */
380 int snd_seq_connect_from(snd_seq_t *seq, int my_port, int src_client, int src_port);
381 int snd_seq_connect_to(snd_seq_t *seq, int my_port, int dest_client, int dest_port);
382 int snd_seq_disconnect_from(snd_seq_t *seq, int my_port, int src_client, int src_port);
383 int snd_seq_disconnect_to(snd_seq_t *seq, int my_port, int dest_client, int dest_port);
384
385/*
386 * set client information
387 */
388 int snd_seq_set_client_name(snd_seq_t *seq, const char *name);
389 int snd_seq_set_client_event_filter(snd_seq_t *seq, int event_type);
390 int snd_seq_set_client_midi_version(snd_seq_t *seq, int midi_version);
391 int snd_seq_set_client_ump_conversion(snd_seq_t *seq, int enable);
392 int snd_seq_set_client_pool_output(snd_seq_t *seq, size_t size);
393 int snd_seq_set_client_pool_output_room(snd_seq_t *seq, size_t size);
394 int snd_seq_set_client_pool_input(snd_seq_t *seq, size_t size);
395/* sync output queue */
396 int snd_seq_sync_output_queue(snd_seq_t *seq);
397
398/*
399 * parse the given string and get the sequencer address
400 */
401 int snd_seq_parse_address(snd_seq_t *seq, snd_seq_addr_t *addr, const char *str);
402
403/*
404 * reset client input/output pool
405 */
406 int snd_seq_reset_pool_output(snd_seq_t *seq);
407 int snd_seq_reset_pool_input(snd_seq_t *seq);
408
417#define snd_seq_ev_set_note(ev, ch, key, vel, dur) \
418 ((ev)->type = SND_SEQ_EVENT_NOTE,\
419 snd_seq_ev_set_fixed(ev),\
420 (ev)->data.note.channel = (ch),\
421 (ev)->data.note.note = (key),\
422 (ev)->data.note.velocity = (vel),\
423 (ev)->data.note.duration = (dur))
424
432#define snd_seq_ev_set_noteon(ev, ch, key, vel) \
433 ((ev)->type = SND_SEQ_EVENT_NOTEON,\
434 snd_seq_ev_set_fixed(ev),\
435 (ev)->data.note.channel = (ch),\
436 (ev)->data.note.note = (key),\
437 (ev)->data.note.velocity = (vel))
438
446#define snd_seq_ev_set_noteoff(ev, ch, key, vel) \
447 ((ev)->type = SND_SEQ_EVENT_NOTEOFF,\
448 snd_seq_ev_set_fixed(ev),\
449 (ev)->data.note.channel = (ch),\
450 (ev)->data.note.note = (key),\
451 (ev)->data.note.velocity = (vel))
452
460#define snd_seq_ev_set_keypress(ev,ch,key,vel) \
461 ((ev)->type = SND_SEQ_EVENT_KEYPRESS,\
462 snd_seq_ev_set_fixed(ev),\
463 (ev)->data.note.channel = (ch),\
464 (ev)->data.note.note = (key),\
465 (ev)->data.note.velocity = (vel))
466
474#define snd_seq_ev_set_controller(ev,ch,cc,val) \
475 ((ev)->type = SND_SEQ_EVENT_CONTROLLER,\
476 snd_seq_ev_set_fixed(ev),\
477 (ev)->data.control.channel = (ch),\
478 (ev)->data.control.param = (cc),\
479 (ev)->data.control.value = (val))
480
487#define snd_seq_ev_set_pgmchange(ev,ch,val) \
488 ((ev)->type = SND_SEQ_EVENT_PGMCHANGE,\
489 snd_seq_ev_set_fixed(ev),\
490 (ev)->data.control.channel = (ch),\
491 (ev)->data.control.value = (val))
492
499#define snd_seq_ev_set_pitchbend(ev,ch,val) \
500 ((ev)->type = SND_SEQ_EVENT_PITCHBEND,\
501 snd_seq_ev_set_fixed(ev),\
502 (ev)->data.control.channel = (ch),\
503 (ev)->data.control.value = (val))
504
511#define snd_seq_ev_set_chanpress(ev,ch,val) \
512 ((ev)->type = SND_SEQ_EVENT_CHANPRESS,\
513 snd_seq_ev_set_fixed(ev),\
514 (ev)->data.control.channel = (ch),\
515 (ev)->data.control.value = (val))
516
525#define snd_seq_ev_set_sysex(ev,datalen,dataptr) \
526 ((ev)->type = SND_SEQ_EVENT_SYSEX,\
527 snd_seq_ev_set_variable(ev, datalen, dataptr))
528
529/* Helper API functions for UMP endpoint and block creations */
530 int snd_seq_create_ump_endpoint(snd_seq_t *seq,
531 const snd_ump_endpoint_info_t *info,
532 unsigned int num_groups);
533 int snd_seq_create_ump_block(snd_seq_t *seq, int blkid,
534 const snd_ump_block_info_t *info);
535
538#ifdef __cplusplus
539}
540#endif
541
542#endif /* __ALSA_SEQMID_H */
543
snd_ump_block_info_t
struct snd_ump_block_info snd_ump_block_info_t
Definition ump.h:33
snd_ump_endpoint_info_t
struct snd_ump_endpoint_info snd_ump_endpoint_info_t
Definition ump.h:31
SND_SEQ_EVENT_UMP
#define SND_SEQ_EVENT_UMP
Definition seq_event.h:239
snd_seq_set_client_pool_input
int snd_seq_set_client_pool_input(snd_seq_t *seq, size_t size)
change the input pool size of the given client
Definition seqmid.c:340
snd_seq_connect_from
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)
Definition seqmid.c:119
snd_seq_control_queue
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
Definition seqmid.c:46
snd_seq_set_client_pool_output
int snd_seq_set_client_pool_output(snd_seq_t *seq, size_t size)
change the output pool size of the given client
Definition seqmid.c:302
snd_seq_reset_pool_output
int snd_seq_reset_pool_output(snd_seq_t *seq)
reset client output pool
Definition seqmid.c:358
snd_seq_set_client_pool_output_room
int snd_seq_set_client_pool_output_room(snd_seq_t *seq, size_t size)
change the output room size of the given client
Definition seqmid.c:321
snd_seq_parse_address
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
Definition seqmid.c:425
snd_seq_sync_output_queue
int snd_seq_sync_output_queue(snd_seq_t *seq)
wait until all events are processed
Definition seqmid.c:384
snd_seq_set_client_event_filter
int snd_seq_set_client_event_filter(snd_seq_t *seq, int event_type)
add client event filter
Definition seqmid.c:245
snd_seq_delete_simple_port
int snd_seq_delete_simple_port(snd_seq_t *seq, int port)
delete the port
Definition seqmid.c:101
snd_seq_disconnect_from
int snd_seq_disconnect_from(snd_seq_t *seq, int my_port, int src_client, int src_port)
simple disconnection
Definition seqmid.c:173
snd_seq_create_simple_port
int snd_seq_create_simple_port(snd_seq_t *seq, const char *name, unsigned int caps, unsigned int type)
create a port - simple version
Definition seqmid.c:71
snd_seq_connect_to
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)
Definition seqmid.c:146
snd_seq_set_client_midi_version
int snd_seq_set_client_midi_version(snd_seq_t *seq, int midi_version)
set client MIDI protocol version
Definition seqmid.c:264
snd_seq_set_client_ump_conversion
int snd_seq_set_client_ump_conversion(snd_seq_t *seq, int enable)
enable/disable client's automatic conversion of UMP/legacy events
Definition seqmid.c:283
snd_seq_create_ump_endpoint
int snd_seq_create_ump_endpoint(snd_seq_t *seq, const snd_ump_endpoint_info_t *info, unsigned int num_groups)
create a UMP Endpoint for the given sequencer client
Definition seqmid.c:515
snd_seq_reset_pool_input
int snd_seq_reset_pool_input(snd_seq_t *seq)
reset client input pool
Definition seqmid.c:370
snd_seq_set_client_name
int snd_seq_set_client_name(snd_seq_t *seq, const char *name)
set client name
Definition seqmid.c:226
snd_seq_create_ump_block
int snd_seq_create_ump_block(snd_seq_t *seq, int blkid, const snd_ump_block_info_t *info)
create a UMP block for the given sequencer client
Definition seqmid.c:702
snd_seq_disconnect_to
int snd_seq_disconnect_to(snd_seq_t *seq, int my_port, int dest_client, int dest_port)
simple disconnection
Definition seqmid.c:200
snd_seq_t
struct _snd_seq snd_seq_t
Definition seq.h:53
snd_seq_addr_t
Definition seq_event.h:189
snd_seq_event_t
Definition seq_event.h:328
snd_seq_ump_event_t
Definition seq_event.h:343
snd_seq_ump_event_t::flags
unsigned char flags
Definition seq_event.h:345
snd_seq_ump_event_t::ump
unsigned int ump[4]
Definition seq_event.h:354
snd_seq_ump_event_t::type
snd_seq_event_type_t type
Definition seq_event.h:344
data
uint8_t data
Definition ump_msg.h:6
type
uint8_t type
Definition ump_msg.h:1