ALSA project - the C library reference
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
seq.h
Go to the documentation of this file.
1 
9 /*
10  * Application interface library for the ALSA driver
11  *
12  *
13  * This library is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as
15  * published by the Free Software Foundation; either version 2.1 of
16  * the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  */
28 
29 #ifndef __ALSA_SEQ_H
30 #define __ALSA_SEQ_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
44 #define SND_SEQ_DLSYM_VERSION _dlsym_seq_001
45 
47 typedef struct _snd_seq snd_seq_t;
48 
52 #define SND_SEQ_OPEN_OUTPUT 1
53 #define SND_SEQ_OPEN_INPUT 2
54 #define SND_SEQ_OPEN_DUPLEX (SND_SEQ_OPEN_OUTPUT|SND_SEQ_OPEN_INPUT)
59 #define SND_SEQ_NONBLOCK 0x0001
62 typedef enum _snd_seq_type {
67 
69 #define SND_SEQ_ADDRESS_UNKNOWN 253
70 #define SND_SEQ_ADDRESS_SUBSCRIBERS 254
71 #define SND_SEQ_ADDRESS_BROADCAST 255
74 #define SND_SEQ_CLIENT_SYSTEM 0
76 /*
77  */
78 int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode);
79 int snd_seq_open_lconf(snd_seq_t **handle, const char *name, int streams, int mode, snd_config_t *lconf);
80 const char *snd_seq_name(snd_seq_t *seq);
82 int snd_seq_close(snd_seq_t *handle);
83 int snd_seq_poll_descriptors_count(snd_seq_t *handle, short events);
84 int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space, short events);
85 int snd_seq_poll_descriptors_revents(snd_seq_t *seq, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
86 int snd_seq_nonblock(snd_seq_t *handle, int nonblock);
87 int snd_seq_client_id(snd_seq_t *handle);
88 
91 int snd_seq_set_output_buffer_size(snd_seq_t *handle, size_t size);
92 int snd_seq_set_input_buffer_size(snd_seq_t *handle, size_t size);
93 
95 typedef struct _snd_seq_system_info snd_seq_system_info_t;
96 
97 size_t snd_seq_system_info_sizeof(void);
99 #define snd_seq_system_info_alloca(ptr) \
100  __snd_alloca(ptr, snd_seq_system_info)
104 
111 
113 
125 typedef struct _snd_seq_client_info snd_seq_client_info_t;
126 
128 typedef enum snd_seq_client_type {
132 
133 size_t snd_seq_client_info_sizeof(void);
135 #define snd_seq_client_info_alloca(ptr) \
136  __snd_alloca(ptr, snd_seq_client_info)
140 
146 const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_info_t *info);
149 
151 void snd_seq_client_info_set_name(snd_seq_client_info_t *info, const char *name);
154 void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned char *filter);
155 
160 
162 int snd_seq_get_any_client_info(snd_seq_t *handle, int client, snd_seq_client_info_t *info);
165 
166 /*
167  */
168 
170 typedef struct _snd_seq_client_pool snd_seq_client_pool_t;
171 
172 size_t snd_seq_client_pool_sizeof(void);
174 #define snd_seq_client_pool_alloca(ptr) \
175  __snd_alloca(ptr, snd_seq_client_pool)
179 
189 
192 
193 
205 typedef struct _snd_seq_port_info snd_seq_port_info_t;
206 
208 #define SND_SEQ_PORT_SYSTEM_TIMER 0
209 #define SND_SEQ_PORT_SYSTEM_ANNOUNCE 1
212 #define SND_SEQ_PORT_CAP_READ (1<<0)
213 #define SND_SEQ_PORT_CAP_WRITE (1<<1)
215 #define SND_SEQ_PORT_CAP_SYNC_READ (1<<2)
216 #define SND_SEQ_PORT_CAP_SYNC_WRITE (1<<3)
218 #define SND_SEQ_PORT_CAP_DUPLEX (1<<4)
220 #define SND_SEQ_PORT_CAP_SUBS_READ (1<<5)
221 #define SND_SEQ_PORT_CAP_SUBS_WRITE (1<<6)
222 #define SND_SEQ_PORT_CAP_NO_EXPORT (1<<7)
224 /* port type */
225 
226 #define SND_SEQ_PORT_TYPE_SPECIFIC (1<<0)
227 
228 #define SND_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1)
229 
230 #define SND_SEQ_PORT_TYPE_MIDI_GM (1<<2)
231 
232 #define SND_SEQ_PORT_TYPE_MIDI_GS (1<<3)
233 
234 #define SND_SEQ_PORT_TYPE_MIDI_XG (1<<4)
235 
236 #define SND_SEQ_PORT_TYPE_MIDI_MT32 (1<<5)
237 
238 #define SND_SEQ_PORT_TYPE_MIDI_GM2 (1<<6)
239 
241 #define SND_SEQ_PORT_TYPE_SYNTH (1<<10)
242 
244 #define SND_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11)
245 
247 #define SND_SEQ_PORT_TYPE_SAMPLE (1<<12)
248 
249 #define SND_SEQ_PORT_TYPE_HARDWARE (1<<16)
250 
251 #define SND_SEQ_PORT_TYPE_SOFTWARE (1<<17)
252 
253 #define SND_SEQ_PORT_TYPE_SYNTHESIZER (1<<18)
254 
256 #define SND_SEQ_PORT_TYPE_PORT (1<<19)
257 
258 #define SND_SEQ_PORT_TYPE_APPLICATION (1<<20)
259 
260 
261 size_t snd_seq_port_info_sizeof(void);
263 #define snd_seq_port_info_alloca(ptr) \
264  __snd_alloca(ptr, snd_seq_port_info)
268 
272 const char *snd_seq_port_info_get_name(const snd_seq_port_info_t *info);
273 unsigned int snd_seq_port_info_get_capability(const snd_seq_port_info_t *info);
274 unsigned int snd_seq_port_info_get_type(const snd_seq_port_info_t *info);
284 
285 void snd_seq_port_info_set_client(snd_seq_port_info_t *info, int client);
286 void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port);
288 void snd_seq_port_info_set_name(snd_seq_port_info_t *info, const char *name);
289 void snd_seq_port_info_set_capability(snd_seq_port_info_t *info, unsigned int capability);
290 void snd_seq_port_info_set_type(snd_seq_port_info_t *info, unsigned int type);
298 
300 int snd_seq_delete_port(snd_seq_t *handle, int port);
301 int snd_seq_get_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
302 int snd_seq_get_any_port_info(snd_seq_t *handle, int client, int port, snd_seq_port_info_t *info);
303 int snd_seq_set_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
305 
317 typedef struct _snd_seq_port_subscribe snd_seq_port_subscribe_t;
318 
319 size_t snd_seq_port_subscribe_sizeof(void);
321 #define snd_seq_port_subscribe_alloca(ptr) \
322  __snd_alloca(ptr, snd_seq_port_subscribe)
326 
333 
340 
344 
345 /*
346  */
347 
349 typedef struct _snd_seq_query_subscribe snd_seq_query_subscribe_t;
350 
352 typedef enum {
356 
357 size_t snd_seq_query_subscribe_sizeof(void);
359 #define snd_seq_query_subscribe_alloca(ptr) \
360  __snd_alloca(ptr, snd_seq_query_subscribe)
364 
376 
382 
384 
396 typedef struct _snd_seq_queue_info snd_seq_queue_info_t;
398 typedef struct _snd_seq_queue_status snd_seq_queue_status_t;
400 typedef struct _snd_seq_queue_tempo snd_seq_queue_tempo_t;
402 typedef struct _snd_seq_queue_timer snd_seq_queue_timer_t;
403 
405 #define SND_SEQ_QUEUE_DIRECT 253
407 size_t snd_seq_queue_info_sizeof(void);
408 
409 #define snd_seq_queue_info_alloca(ptr) \
410  __snd_alloca(ptr, snd_seq_queue_info)
414 
416 const char *snd_seq_queue_info_get_name(const snd_seq_queue_info_t *info);
419 unsigned int snd_seq_queue_info_get_flags(const snd_seq_queue_info_t *info);
420 
421 void snd_seq_queue_info_set_name(snd_seq_queue_info_t *info, const char *name);
424 void snd_seq_queue_info_set_flags(snd_seq_queue_info_t *info, unsigned int flags);
425 
427 int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name);
428 int snd_seq_alloc_queue(snd_seq_t *handle);
429 int snd_seq_free_queue(snd_seq_t *handle, int q);
432 int snd_seq_query_named_queue(snd_seq_t *seq, const char *name);
433 
434 int snd_seq_get_queue_usage(snd_seq_t *handle, int q);
435 int snd_seq_set_queue_usage(snd_seq_t *handle, int q, int used);
436 
437 /*
438  */
439 size_t snd_seq_queue_status_sizeof(void);
441 #define snd_seq_queue_status_alloca(ptr) \
442  __snd_alloca(ptr, snd_seq_queue_status)
446 
452 
453 int snd_seq_get_queue_status(snd_seq_t *handle, int q, snd_seq_queue_status_t *status);
454 
455 /*
456  */
457 size_t snd_seq_queue_tempo_sizeof(void);
459 #define snd_seq_queue_tempo_alloca(ptr) \
460  __snd_alloca(ptr, snd_seq_queue_tempo)
464 
466 unsigned int snd_seq_queue_tempo_get_tempo(const snd_seq_queue_tempo_t *info);
468 unsigned int snd_seq_queue_tempo_get_skew(const snd_seq_queue_tempo_t *info);
470 void snd_seq_queue_tempo_set_tempo(snd_seq_queue_tempo_t *info, unsigned int tempo);
472 void snd_seq_queue_tempo_set_skew(snd_seq_queue_tempo_t *info, unsigned int skew);
473 void snd_seq_queue_tempo_set_skew_base(snd_seq_queue_tempo_t *info, unsigned int base);
474 
475 int snd_seq_get_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
476 int snd_seq_set_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
477 
478 /*
479  */
480 
482 typedef enum {
483  SND_SEQ_TIMER_ALSA = 0, /* ALSA timer */
484  SND_SEQ_TIMER_MIDI_CLOCK = 1, /* Midi Clock (CLOCK event) */
485  SND_SEQ_TIMER_MIDI_TICK = 2 /* Midi Timer Tick (TICK event */
487 
488 size_t snd_seq_queue_timer_sizeof(void);
490 #define snd_seq_queue_timer_alloca(ptr) \
491  __snd_alloca(ptr, snd_seq_queue_timer)
495 
500 
503 void snd_seq_queue_timer_set_resolution(snd_seq_queue_timer_t *info, unsigned int resolution);
504 
505 int snd_seq_get_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
506 int snd_seq_set_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
507 
523 int snd_seq_event_input_pending(snd_seq_t *seq, int fetch_sequencer);
524 int snd_seq_drain_output(snd_seq_t *handle);
527 int snd_seq_drop_output(snd_seq_t *handle);
529 int snd_seq_drop_input(snd_seq_t *handle);
531 
533 typedef struct _snd_seq_remove_events snd_seq_remove_events_t;
534 
536 #define SND_SEQ_REMOVE_INPUT (1<<0)
537 #define SND_SEQ_REMOVE_OUTPUT (1<<1)
538 #define SND_SEQ_REMOVE_DEST (1<<2)
539 #define SND_SEQ_REMOVE_DEST_CHANNEL (1<<3)
540 #define SND_SEQ_REMOVE_TIME_BEFORE (1<<4)
541 #define SND_SEQ_REMOVE_TIME_AFTER (1<<5)
542 #define SND_SEQ_REMOVE_TIME_TICK (1<<6)
543 #define SND_SEQ_REMOVE_EVENT_TYPE (1<<7)
544 #define SND_SEQ_REMOVE_IGNORE_OFF (1<<8)
545 #define SND_SEQ_REMOVE_TAG_MATCH (1<<9)
547 size_t snd_seq_remove_events_sizeof(void);
548 
549 #define snd_seq_remove_events_alloca(ptr) \
550  __snd_alloca(ptr, snd_seq_remove_events)
554 
562 
563 void snd_seq_remove_events_set_condition(snd_seq_remove_events_t *info, unsigned int flags);
570 
572 
582 void snd_seq_set_bit(int nr, void *array);
583 void snd_seq_unset_bit(int nr, void *array);
584 int snd_seq_change_bit(int nr, void *array);
585 int snd_seq_get_bit(int nr, void *array);
586 
597 /* event type macros */
598 enum {
599  SND_SEQ_EVFLG_RESULT,
600  SND_SEQ_EVFLG_NOTE,
601  SND_SEQ_EVFLG_CONTROL,
602  SND_SEQ_EVFLG_QUEUE,
603  SND_SEQ_EVFLG_SYSTEM,
604  SND_SEQ_EVFLG_MESSAGE,
605  SND_SEQ_EVFLG_CONNECTION,
606  SND_SEQ_EVFLG_SAMPLE,
607  SND_SEQ_EVFLG_USERS,
608  SND_SEQ_EVFLG_INSTR,
609  SND_SEQ_EVFLG_QUOTE,
610  SND_SEQ_EVFLG_NONE,
611  SND_SEQ_EVFLG_RAW,
612  SND_SEQ_EVFLG_FIXED,
613  SND_SEQ_EVFLG_VARIABLE,
614  SND_SEQ_EVFLG_VARUSR
615 };
616 
617 enum {
618  SND_SEQ_EVFLG_NOTE_ONEARG,
619  SND_SEQ_EVFLG_NOTE_TWOARG
620 };
621 
622 enum {
623  SND_SEQ_EVFLG_QUEUE_NOARG,
624  SND_SEQ_EVFLG_QUEUE_TICK,
625  SND_SEQ_EVFLG_QUEUE_TIME,
626  SND_SEQ_EVFLG_QUEUE_VALUE
627 };
628 
634 extern const unsigned int snd_seq_event_types[];
635 
636 #define _SND_SEQ_TYPE(x) (1<<(x))
637 #define _SND_SEQ_TYPE_OPT(x) ((x)<<24)
640 #define snd_seq_type_check(ev,x) (snd_seq_event_types[(ev)->type] & _SND_SEQ_TYPE(x))
641 
643 #define snd_seq_ev_is_result_type(ev) \
644  snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT)
645 
646 #define snd_seq_ev_is_note_type(ev) \
647  snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE)
648 
649 #define snd_seq_ev_is_control_type(ev) \
650  snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL)
651 
652 #define snd_seq_ev_is_channel_type(ev) \
653  (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL)))
654 
656 #define snd_seq_ev_is_queue_type(ev) \
657  snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE)
658 
659 #define snd_seq_ev_is_message_type(ev) \
660  snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE)
661 
662 #define snd_seq_ev_is_subscribe_type(ev) \
663  snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION)
664 
665 #define snd_seq_ev_is_sample_type(ev) \
666  snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE)
667 
668 #define snd_seq_ev_is_user_type(ev) \
669  snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS)
670 
671 #define snd_seq_ev_is_instr_type(ev) \
672  snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR)
673 
674 #define snd_seq_ev_is_fixed_type(ev) \
675  snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED)
676 
677 #define snd_seq_ev_is_variable_type(ev) \
678  snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE)
679 
680 #define snd_seq_ev_is_varusr_type(ev) \
681  snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR)
682 
683 #define snd_seq_ev_is_reserved(ev) \
684  (! snd_seq_event_types[(ev)->type])
685 
690 #define snd_seq_ev_is_prior(ev) \
691  (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH)
692 
694 #define snd_seq_ev_length_type(ev) \
695  ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK)
696 
697 #define snd_seq_ev_is_fixed(ev) \
698  (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED)
699 
700 #define snd_seq_ev_is_variable(ev) \
701  (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE)
702 
703 #define snd_seq_ev_is_varusr(ev) \
704  (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR)
705 
707 #define snd_seq_ev_timestamp_type(ev) \
708  ((ev)->flags & SND_SEQ_TIME_STAMP_MASK)
709 
710 #define snd_seq_ev_is_tick(ev) \
711  (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK)
712 
713 #define snd_seq_ev_is_real(ev) \
714  (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL)
715 
717 #define snd_seq_ev_timemode_type(ev) \
718  ((ev)->flags & SND_SEQ_TIME_MODE_MASK)
719 
720 #define snd_seq_ev_is_abstime(ev) \
721  (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS)
722 
723 #define snd_seq_ev_is_reltime(ev) \
724  (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL)
725 
727 #define snd_seq_ev_is_direct(ev) \
728  ((ev)->queue == SND_SEQ_QUEUE_DIRECT)
729 
732 #ifdef __cplusplus
733 }
734 #endif
735 
736 #endif /* __ALSA_SEQ_H */
737