1/** 2 * \file include/seq.h 3 * \brief Application interface library for the ALSA driver 4 * \author Jaroslav Kysela <perex@perex.cz> 5 * \author Abramo Bagnara <abramo@alsa-project.org> 6 * \author Takashi Iwai <tiwai@suse.de> 7 * \date 1998-2001 8 */ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 26 * 27 */ 28 29#ifndef __ALSA_SEQ_H 30#define __ALSA_SEQ_H 31 32#ifdef __cplusplus 33extern "C" { 34#endif 35 36/** 37 * \defgroup Sequencer MIDI Sequencer 38 * MIDI Sequencer Interface. 39 * See \ref seq page for more details. 40 * \{ 41 */ 42 43/** dlsym version for interface entry callback */ 44#define SND_SEQ_DLSYM_VERSION _dlsym_seq_001 45 46/** Sequencer handle */ 47typedef struct _snd_seq snd_seq_t; 48 49/** 50 * sequencer opening stream types 51 */ 52#define SND_SEQ_OPEN_OUTPUT 1 /**< open for output (write) */ 53#define SND_SEQ_OPEN_INPUT 2 /**< open for input (read) */ 54#define SND_SEQ_OPEN_DUPLEX (SND_SEQ_OPEN_OUTPUT|SND_SEQ_OPEN_INPUT) /**< open for both input and output (read/write) */ 55 56/** 57 * sequencer opening mode 58 */ 59#define SND_SEQ_NONBLOCK 0x0001 /**< non-blocking mode (flag to open mode) */ 60 61/** sequencer handle type */ 62typedef enum _snd_seq_type { 63 SND_SEQ_TYPE_HW, /**< hardware */ 64 SND_SEQ_TYPE_SHM, /**< shared memory (NYI) */ 65 SND_SEQ_TYPE_INET /**< network (NYI) */ 66} snd_seq_type_t; 67 68/** special client (port) ids */ 69#define SND_SEQ_ADDRESS_UNKNOWN 253 /**< unknown source */ 70#define SND_SEQ_ADDRESS_SUBSCRIBERS 254 /**< send event to all subscribed ports */ 71#define SND_SEQ_ADDRESS_BROADCAST 255 /**< send event to all queues/clients/ports/channels */ 72 73/** known client numbers */ 74#define SND_SEQ_CLIENT_SYSTEM 0 /**< system client */ 75 76/* 77 */ 78int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode); 79int snd_seq_open_lconf(snd_seq_t **handle, const char *name, int streams, int mode, snd_config_t *lconf); 80const char *snd_seq_name(snd_seq_t *seq); 81snd_seq_type_t snd_seq_type(snd_seq_t *seq); 82int snd_seq_close(snd_seq_t *handle); 83int snd_seq_poll_descriptors_count(snd_seq_t *handle, short events); 84int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space, short events); 85int snd_seq_poll_descriptors_revents(snd_seq_t *seq, struct pollfd *pfds, unsigned int nfds, unsigned short *revents); 86int snd_seq_nonblock(snd_seq_t *handle, int nonblock); 87int snd_seq_client_id(snd_seq_t *handle); 88 89size_t snd_seq_get_output_buffer_size(snd_seq_t *handle); 90size_t snd_seq_get_input_buffer_size(snd_seq_t *handle); 91int snd_seq_set_output_buffer_size(snd_seq_t *handle, size_t size); 92int snd_seq_set_input_buffer_size(snd_seq_t *handle, size_t size); 93 94/** system information container */ 95typedef struct _snd_seq_system_info snd_seq_system_info_t; 96 97size_t snd_seq_system_info_sizeof(void); 98/** allocate a #snd_seq_system_info_t container on stack */ 99#define snd_seq_system_info_alloca(ptr) \ 100 __snd_alloca(ptr, snd_seq_system_info) 101int snd_seq_system_info_malloc(snd_seq_system_info_t **ptr); 102void snd_seq_system_info_free(snd_seq_system_info_t *ptr); 103void snd_seq_system_info_copy(snd_seq_system_info_t *dst, const snd_seq_system_info_t *src); 104 105int snd_seq_system_info_get_queues(const snd_seq_system_info_t *info); 106int snd_seq_system_info_get_clients(const snd_seq_system_info_t *info); 107int snd_seq_system_info_get_ports(const snd_seq_system_info_t *info); 108int snd_seq_system_info_get_channels(const snd_seq_system_info_t *info); 109int snd_seq_system_info_get_cur_clients(const snd_seq_system_info_t *info); 110int snd_seq_system_info_get_cur_queues(const snd_seq_system_info_t *info); 111 112int snd_seq_system_info(snd_seq_t *handle, snd_seq_system_info_t *info); 113 114/** \} */ 115 116 117/** 118 * \defgroup SeqClient Sequencer Client Interface 119 * Sequencer Client Interface 120 * \ingroup Sequencer 121 * \{ 122 */ 123 124/** client information container */ 125typedef struct _snd_seq_client_info snd_seq_client_info_t; 126 127/** client types */ 128typedef enum snd_seq_client_type { 129 SND_SEQ_USER_CLIENT = 1, /**< user client */ 130 SND_SEQ_KERNEL_CLIENT = 2 /**< kernel client */ 131} snd_seq_client_type_t; 132 133/** client MIDI version */ 134enum { 135 SND_SEQ_CLIENT_LEGACY_MIDI = 0, /**< Legacy client */ 136 SND_SEQ_CLIENT_UMP_MIDI_1_0 = 1, /**< UMP MIDI 1.0 */ 137 SND_SEQ_CLIENT_UMP_MIDI_2_0 = 2 /**< UMP MIDI 2.0 */ 138}; 139 140size_t snd_seq_client_info_sizeof(void); 141/** allocate a #snd_seq_client_info_t container on stack */ 142#define snd_seq_client_info_alloca(ptr) \ 143 __snd_alloca(ptr, snd_seq_client_info) 144int snd_seq_client_info_malloc(snd_seq_client_info_t **ptr); 145void snd_seq_client_info_free(snd_seq_client_info_t *ptr); 146void snd_seq_client_info_copy(snd_seq_client_info_t *dst, const snd_seq_client_info_t *src); 147 148int snd_seq_client_info_get_client(const snd_seq_client_info_t *info); 149snd_seq_client_type_t snd_seq_client_info_get_type(const snd_seq_client_info_t *info); 150const char *snd_seq_client_info_get_name(snd_seq_client_info_t *info); 151int snd_seq_client_info_get_broadcast_filter(const snd_seq_client_info_t *info); 152int snd_seq_client_info_get_error_bounce(const snd_seq_client_info_t *info); 153int snd_seq_client_info_get_card(const snd_seq_client_info_t *info); 154int snd_seq_client_info_get_pid(const snd_seq_client_info_t *info); 155const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_info_t *info); 156int snd_seq_client_info_get_num_ports(const snd_seq_client_info_t *info); 157int snd_seq_client_info_get_event_lost(const snd_seq_client_info_t *info); 158 159int snd_seq_client_info_get_midi_version(const snd_seq_client_info_t *info); 160int snd_seq_client_info_get_ump_group_enabled(const snd_seq_client_info_t *info, 161 int group); 162int snd_seq_client_info_get_ump_groupless_enabled(const snd_seq_client_info_t *info); 163int snd_seq_client_info_get_ump_conversion(const snd_seq_client_info_t *info); 164void snd_seq_client_info_set_client(snd_seq_client_info_t *info, int client); 165void snd_seq_client_info_set_name(snd_seq_client_info_t *info, const char *name); 166void snd_seq_client_info_set_broadcast_filter(snd_seq_client_info_t *info, int val); 167void snd_seq_client_info_set_error_bounce(snd_seq_client_info_t *info, int val); 168void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned char *filter); 169void snd_seq_client_info_set_midi_version(snd_seq_client_info_t *info, int midi_version); 170void snd_seq_client_info_set_ump_group_enabled(snd_seq_client_info_t *info, 171 int group, int enable); 172void snd_seq_client_info_set_ump_groupless_enabled(snd_seq_client_info_t *info, 173 int enable); 174void snd_seq_client_info_set_ump_conversion(snd_seq_client_info_t *info, int enable); 175 176void snd_seq_client_info_event_filter_clear(snd_seq_client_info_t *info); 177void snd_seq_client_info_event_filter_add(snd_seq_client_info_t *info, int event_type); 178void snd_seq_client_info_event_filter_del(snd_seq_client_info_t *info, int event_type); 179int snd_seq_client_info_event_filter_check(snd_seq_client_info_t *info, int event_type); 180 181int snd_seq_get_client_info(snd_seq_t *handle, snd_seq_client_info_t *info); 182int snd_seq_get_any_client_info(snd_seq_t *handle, int client, snd_seq_client_info_t *info); 183int snd_seq_set_client_info(snd_seq_t *handle, snd_seq_client_info_t *info); 184int snd_seq_query_next_client(snd_seq_t *handle, snd_seq_client_info_t *info); 185 186int snd_seq_get_ump_endpoint_info(snd_seq_t *seq, int client, void *info); 187int snd_seq_get_ump_block_info(snd_seq_t *seq, int client, int blk, void *info); 188int snd_seq_set_ump_endpoint_info(snd_seq_t *seq, const void *info); 189int snd_seq_set_ump_block_info(snd_seq_t *seq, int blk, const void *info); 190 191/* 192 */ 193 194/** client pool information container */ 195typedef struct _snd_seq_client_pool snd_seq_client_pool_t; 196 197size_t snd_seq_client_pool_sizeof(void); 198/** allocate a #snd_seq_client_pool_t container on stack */ 199#define snd_seq_client_pool_alloca(ptr) \ 200 __snd_alloca(ptr, snd_seq_client_pool) 201int snd_seq_client_pool_malloc(snd_seq_client_pool_t **ptr); 202void snd_seq_client_pool_free(snd_seq_client_pool_t *ptr); 203void snd_seq_client_pool_copy(snd_seq_client_pool_t *dst, const snd_seq_client_pool_t *src); 204 205int snd_seq_client_pool_get_client(const snd_seq_client_pool_t *info); 206size_t snd_seq_client_pool_get_output_pool(const snd_seq_client_pool_t *info); 207size_t snd_seq_client_pool_get_input_pool(const snd_seq_client_pool_t *info); 208size_t snd_seq_client_pool_get_output_room(const snd_seq_client_pool_t *info); 209size_t snd_seq_client_pool_get_output_free(const snd_seq_client_pool_t *info); 210size_t snd_seq_client_pool_get_input_free(const snd_seq_client_pool_t *info); 211void snd_seq_client_pool_set_output_pool(snd_seq_client_pool_t *info, size_t size); 212void snd_seq_client_pool_set_input_pool(snd_seq_client_pool_t *info, size_t size); 213void snd_seq_client_pool_set_output_room(snd_seq_client_pool_t *info, size_t size); 214 215int snd_seq_get_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info); 216int snd_seq_set_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info); 217 218 219/** \} */ 220 221 222/** 223 * \defgroup SeqPort Sequencer Port Interface 224 * Sequencer Port Interface 225 * \ingroup Sequencer 226 * \{ 227 */ 228 229/** port information container */ 230typedef struct _snd_seq_port_info snd_seq_port_info_t; 231 232/** known port numbers */ 233#define SND_SEQ_PORT_SYSTEM_TIMER 0 /**< system timer port */ 234#define SND_SEQ_PORT_SYSTEM_ANNOUNCE 1 /**< system announce port */ 235 236/** port capabilities (32 bits) */ 237#define SND_SEQ_PORT_CAP_READ (1<<0) /**< readable from this port */ 238#define SND_SEQ_PORT_CAP_WRITE (1<<1) /**< writable to this port */ 239 240#define SND_SEQ_PORT_CAP_SYNC_READ (1<<2) /**< allow read subscriptions */ 241#define SND_SEQ_PORT_CAP_SYNC_WRITE (1<<3) /**< allow write subscriptions */ 242 243#define SND_SEQ_PORT_CAP_DUPLEX (1<<4) /**< allow read/write duplex */ 244 245#define SND_SEQ_PORT_CAP_SUBS_READ (1<<5) /**< allow read subscription */ 246#define SND_SEQ_PORT_CAP_SUBS_WRITE (1<<6) /**< allow write subscription */ 247#define SND_SEQ_PORT_CAP_NO_EXPORT (1<<7) /**< routing not allowed */ 248#define SND_SEQ_PORT_CAP_INACTIVE (1<<8) /**< inactive port */ 249#define SND_SEQ_PORT_CAP_UMP_ENDPOINT (1<<9) /**< UMP Endpoint port */ 250 251/** port direction */ 252#define SND_SEQ_PORT_DIR_UNKNOWN 0 /**< Unknown */ 253#define SND_SEQ_PORT_DIR_INPUT 1 /**< Input only */ 254#define SND_SEQ_PORT_DIR_OUTPUT 2 /**< Output only */ 255#define SND_SEQ_PORT_DIR_BIDIRECTION 3 /**< Input/output bidirectional */ 256 257/* port type */ 258/** Messages sent from/to this port have device-specific semantics. */ 259#define SND_SEQ_PORT_TYPE_SPECIFIC (1<<0) 260/** This port understands MIDI messages. */ 261#define SND_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) 262/** This port is compatible with the General MIDI specification. */ 263#define SND_SEQ_PORT_TYPE_MIDI_GM (1<<2) 264/** This port is compatible with the Roland GS standard. */ 265#define SND_SEQ_PORT_TYPE_MIDI_GS (1<<3) 266/** This port is compatible with the Yamaha XG specification. */ 267#define SND_SEQ_PORT_TYPE_MIDI_XG (1<<4) 268/** This port is compatible with the Roland MT-32. */ 269#define SND_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) 270/** This port is compatible with the General MIDI 2 specification. */ 271#define SND_SEQ_PORT_TYPE_MIDI_GM2 (1<<6) 272/** This port is a UMP port. */ 273#define SND_SEQ_PORT_TYPE_MIDI_UMP (1<<7) 274/** This port understands SND_SEQ_EVENT_SAMPLE_xxx messages 275 (these are not MIDI messages). */ 276#define SND_SEQ_PORT_TYPE_SYNTH (1<<10) 277/** Instruments can be downloaded to this port 278 (with SND_SEQ_EVENT_INSTR_xxx messages sent directly). */ 279#define SND_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11) 280/** Instruments can be downloaded to this port 281 (with SND_SEQ_EVENT_INSTR_xxx messages sent directly or through a queue). */ 282#define SND_SEQ_PORT_TYPE_SAMPLE (1<<12) 283/** This port is implemented in hardware. */ 284#define SND_SEQ_PORT_TYPE_HARDWARE (1<<16) 285/** This port is implemented in software. */ 286#define SND_SEQ_PORT_TYPE_SOFTWARE (1<<17) 287/** Messages sent to this port will generate sounds. */ 288#define SND_SEQ_PORT_TYPE_SYNTHESIZER (1<<18) 289/** This port may connect to other devices 290 (whose characteristics are not known). */ 291#define SND_SEQ_PORT_TYPE_PORT (1<<19) 292/** This port belongs to an application, such as a sequencer or editor. */ 293#define SND_SEQ_PORT_TYPE_APPLICATION (1<<20) 294 295 296size_t snd_seq_port_info_sizeof(void); 297/** allocate a #snd_seq_port_info_t container on stack */ 298#define snd_seq_port_info_alloca(ptr) \ 299 __snd_alloca(ptr, snd_seq_port_info) 300int snd_seq_port_info_malloc(snd_seq_port_info_t **ptr); 301void snd_seq_port_info_free(snd_seq_port_info_t *ptr); 302void snd_seq_port_info_copy(snd_seq_port_info_t *dst, const snd_seq_port_info_t *src); 303 304int snd_seq_port_info_get_client(const snd_seq_port_info_t *info); 305int snd_seq_port_info_get_port(const snd_seq_port_info_t *info); 306const snd_seq_addr_t *snd_seq_port_info_get_addr(const snd_seq_port_info_t *info); 307const char *snd_seq_port_info_get_name(const snd_seq_port_info_t *info); 308unsigned int snd_seq_port_info_get_capability(const snd_seq_port_info_t *info); 309unsigned int snd_seq_port_info_get_type(const snd_seq_port_info_t *info); 310int snd_seq_port_info_get_midi_channels(const snd_seq_port_info_t *info); 311int snd_seq_port_info_get_midi_voices(const snd_seq_port_info_t *info); 312int snd_seq_port_info_get_synth_voices(const snd_seq_port_info_t *info); 313int snd_seq_port_info_get_read_use(const snd_seq_port_info_t *info); 314int snd_seq_port_info_get_write_use(const snd_seq_port_info_t *info); 315int snd_seq_port_info_get_port_specified(const snd_seq_port_info_t *info); 316int snd_seq_port_info_get_timestamping(const snd_seq_port_info_t *info); 317int snd_seq_port_info_get_timestamp_real(const snd_seq_port_info_t *info); 318int snd_seq_port_info_get_timestamp_queue(const snd_seq_port_info_t *info); 319int snd_seq_port_info_get_direction(const snd_seq_port_info_t *info); 320int snd_seq_port_info_get_ump_group(const snd_seq_port_info_t *info); 321 322void snd_seq_port_info_set_client(snd_seq_port_info_t *info, int client); 323void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port); 324void snd_seq_port_info_set_addr(snd_seq_port_info_t *info, const snd_seq_addr_t *addr); 325void snd_seq_port_info_set_name(snd_seq_port_info_t *info, const char *name); 326void snd_seq_port_info_set_capability(snd_seq_port_info_t *info, unsigned int capability); 327void snd_seq_port_info_set_type(snd_seq_port_info_t *info, unsigned int type); 328void snd_seq_port_info_set_midi_channels(snd_seq_port_info_t *info, int channels); 329void snd_seq_port_info_set_midi_voices(snd_seq_port_info_t *info, int voices); 330void snd_seq_port_info_set_synth_voices(snd_seq_port_info_t *info, int voices); 331void snd_seq_port_info_set_port_specified(snd_seq_port_info_t *info, int val); 332void snd_seq_port_info_set_timestamping(snd_seq_port_info_t *info, int enable); 333void snd_seq_port_info_set_timestamp_real(snd_seq_port_info_t *info, int realtime); 334void snd_seq_port_info_set_timestamp_queue(snd_seq_port_info_t *info, int queue); 335void snd_seq_port_info_set_direction(snd_seq_port_info_t *info, int direction); 336void snd_seq_port_info_set_ump_group(snd_seq_port_info_t *info, int ump_group); 337 338int snd_seq_create_port(snd_seq_t *handle, snd_seq_port_info_t *info); 339int snd_seq_delete_port(snd_seq_t *handle, int port); 340int snd_seq_get_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info); 341int snd_seq_get_any_port_info(snd_seq_t *handle, int client, int port, snd_seq_port_info_t *info); 342int snd_seq_set_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info); 343int snd_seq_query_next_port(snd_seq_t *handle, snd_seq_port_info_t *info); 344 345/** \} */ 346 347 348/** 349 * \defgroup SeqSubscribe Sequencer Port Subscription 350 * Sequencer Port Subscription 351 * \ingroup Sequencer 352 * \{ 353 */ 354 355/** port subscription container */ 356typedef struct _snd_seq_port_subscribe snd_seq_port_subscribe_t; 357 358size_t snd_seq_port_subscribe_sizeof(void); 359/** allocate a #snd_seq_port_subscribe_t container on stack */ 360#define snd_seq_port_subscribe_alloca(ptr) \ 361 __snd_alloca(ptr, snd_seq_port_subscribe) 362int snd_seq_port_subscribe_malloc(snd_seq_port_subscribe_t **ptr); 363void snd_seq_port_subscribe_free(snd_seq_port_subscribe_t *ptr); 364void snd_seq_port_subscribe_copy(snd_seq_port_subscribe_t *dst, const snd_seq_port_subscribe_t *src); 365 366const snd_seq_addr_t *snd_seq_port_subscribe_get_sender(const snd_seq_port_subscribe_t *info); 367const snd_seq_addr_t *snd_seq_port_subscribe_get_dest(const snd_seq_port_subscribe_t *info); 368int snd_seq_port_subscribe_get_queue(const snd_seq_port_subscribe_t *info); 369int snd_seq_port_subscribe_get_exclusive(const snd_seq_port_subscribe_t *info); 370int snd_seq_port_subscribe_get_time_update(const snd_seq_port_subscribe_t *info); 371int snd_seq_port_subscribe_get_time_real(const snd_seq_port_subscribe_t *info); 372 373void snd_seq_port_subscribe_set_sender(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr); 374void snd_seq_port_subscribe_set_dest(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr); 375void snd_seq_port_subscribe_set_queue(snd_seq_port_subscribe_t *info, int q); 376void snd_seq_port_subscribe_set_exclusive(snd_seq_port_subscribe_t *info, int val); 377void snd_seq_port_subscribe_set_time_update(snd_seq_port_subscribe_t *info, int val); 378void snd_seq_port_subscribe_set_time_real(snd_seq_port_subscribe_t *info, int val); 379 380int snd_seq_get_port_subscription(snd_seq_t *handle, snd_seq_port_subscribe_t *sub); 381int snd_seq_subscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub); 382int snd_seq_unsubscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub); 383 384/* 385 */ 386 387/** subscription query container */ 388typedef struct _snd_seq_query_subscribe snd_seq_query_subscribe_t; 389 390/** type of query subscription */ 391typedef enum { 392 SND_SEQ_QUERY_SUBS_READ, /**< query read subscriptions */ 393 SND_SEQ_QUERY_SUBS_WRITE /**< query write subscriptions */ 394} snd_seq_query_subs_type_t; 395 396size_t snd_seq_query_subscribe_sizeof(void); 397/** allocate a #snd_seq_query_subscribe_t container on stack */ 398#define snd_seq_query_subscribe_alloca(ptr) \ 399 __snd_alloca(ptr, snd_seq_query_subscribe) 400int snd_seq_query_subscribe_malloc(snd_seq_query_subscribe_t **ptr); 401void snd_seq_query_subscribe_free(snd_seq_query_subscribe_t *ptr); 402void snd_seq_query_subscribe_copy(snd_seq_query_subscribe_t *dst, const snd_seq_query_subscribe_t *src); 403 404int snd_seq_query_subscribe_get_client(const snd_seq_query_subscribe_t *info); 405int snd_seq_query_subscribe_get_port(const snd_seq_query_subscribe_t *info); 406const snd_seq_addr_t *snd_seq_query_subscribe_get_root(const snd_seq_query_subscribe_t *info); 407snd_seq_query_subs_type_t snd_seq_query_subscribe_get_type(const snd_seq_query_subscribe_t *info); 408int snd_seq_query_subscribe_get_index(const snd_seq_query_subscribe_t *info); 409int snd_seq_query_subscribe_get_num_subs(const snd_seq_query_subscribe_t *info); 410const snd_seq_addr_t *snd_seq_query_subscribe_get_addr(const snd_seq_query_subscribe_t *info); 411int snd_seq_query_subscribe_get_queue(const snd_seq_query_subscribe_t *info); 412int snd_seq_query_subscribe_get_exclusive(const snd_seq_query_subscribe_t *info); 413int snd_seq_query_subscribe_get_time_update(const snd_seq_query_subscribe_t *info); 414int snd_seq_query_subscribe_get_time_real(const snd_seq_query_subscribe_t *info); 415 416void snd_seq_query_subscribe_set_client(snd_seq_query_subscribe_t *info, int client); 417void snd_seq_query_subscribe_set_port(snd_seq_query_subscribe_t *info, int port); 418void snd_seq_query_subscribe_set_root(snd_seq_query_subscribe_t *info, const snd_seq_addr_t *addr); 419void snd_seq_query_subscribe_set_type(snd_seq_query_subscribe_t *info, snd_seq_query_subs_type_t type); 420void snd_seq_query_subscribe_set_index(snd_seq_query_subscribe_t *info, int _index); 421 422int snd_seq_query_port_subscribers(snd_seq_t *seq, snd_seq_query_subscribe_t * subs); 423 424/** \} */ 425 426 427/** 428 * \defgroup SeqQueue Sequencer Queue Interface 429 * Sequencer Queue Interface 430 * \ingroup Sequencer 431 * \{ 432 */ 433 434/** queue information container */ 435typedef struct _snd_seq_queue_info snd_seq_queue_info_t; 436/** queue status container */ 437typedef struct _snd_seq_queue_status snd_seq_queue_status_t; 438/** queue tempo container */ 439typedef struct _snd_seq_queue_tempo snd_seq_queue_tempo_t; 440/** queue timer information container */ 441typedef struct _snd_seq_queue_timer snd_seq_queue_timer_t; 442 443/** special queue ids */ 444#define SND_SEQ_QUEUE_DIRECT 253 /**< direct dispatch */ 445 446size_t snd_seq_queue_info_sizeof(void); 447/** allocate a #snd_seq_queue_info_t container on stack */ 448#define snd_seq_queue_info_alloca(ptr) \ 449 __snd_alloca(ptr, snd_seq_queue_info) 450int snd_seq_queue_info_malloc(snd_seq_queue_info_t **ptr); 451void snd_seq_queue_info_free(snd_seq_queue_info_t *ptr); 452void snd_seq_queue_info_copy(snd_seq_queue_info_t *dst, const snd_seq_queue_info_t *src); 453 454int snd_seq_queue_info_get_queue(const snd_seq_queue_info_t *info); 455const char *snd_seq_queue_info_get_name(const snd_seq_queue_info_t *info); 456int snd_seq_queue_info_get_owner(const snd_seq_queue_info_t *info); 457int snd_seq_queue_info_get_locked(const snd_seq_queue_info_t *info); 458unsigned int snd_seq_queue_info_get_flags(const snd_seq_queue_info_t *info); 459 460void snd_seq_queue_info_set_name(snd_seq_queue_info_t *info, const char *name); 461void snd_seq_queue_info_set_owner(snd_seq_queue_info_t *info, int owner); 462void snd_seq_queue_info_set_locked(snd_seq_queue_info_t *info, int locked); 463void snd_seq_queue_info_set_flags(snd_seq_queue_info_t *info, unsigned int flags); 464 465int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info); 466int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name); 467int snd_seq_alloc_queue(snd_seq_t *handle); 468int snd_seq_free_queue(snd_seq_t *handle, int q); 469int snd_seq_get_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info); 470int snd_seq_set_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info); 471int snd_seq_query_named_queue(snd_seq_t *seq, const char *name); 472 473int snd_seq_get_queue_usage(snd_seq_t *handle, int q); 474int snd_seq_set_queue_usage(snd_seq_t *handle, int q, int used); 475 476/* 477 */ 478size_t snd_seq_queue_status_sizeof(void); 479/** allocate a #snd_seq_queue_status_t container on stack */ 480#define snd_seq_queue_status_alloca(ptr) \ 481 __snd_alloca(ptr, snd_seq_queue_status) 482int snd_seq_queue_status_malloc(snd_seq_queue_status_t **ptr); 483void snd_seq_queue_status_free(snd_seq_queue_status_t *ptr); 484void snd_seq_queue_status_copy(snd_seq_queue_status_t *dst, const snd_seq_queue_status_t *src); 485 486int snd_seq_queue_status_get_queue(const snd_seq_queue_status_t *info); 487int snd_seq_queue_status_get_events(const snd_seq_queue_status_t *info); 488snd_seq_tick_time_t snd_seq_queue_status_get_tick_time(const snd_seq_queue_status_t *info); 489const snd_seq_real_time_t *snd_seq_queue_status_get_real_time(const snd_seq_queue_status_t *info); 490unsigned int snd_seq_queue_status_get_status(const snd_seq_queue_status_t *info); 491 492int snd_seq_get_queue_status(snd_seq_t *handle, int q, snd_seq_queue_status_t *status); 493 494/* 495 */ 496size_t snd_seq_queue_tempo_sizeof(void); 497/** allocate a #snd_seq_queue_tempo_t container on stack */ 498#define snd_seq_queue_tempo_alloca(ptr) \ 499 __snd_alloca(ptr, snd_seq_queue_tempo) 500int snd_seq_queue_tempo_malloc(snd_seq_queue_tempo_t **ptr); 501void snd_seq_queue_tempo_free(snd_seq_queue_tempo_t *ptr); 502void snd_seq_queue_tempo_copy(snd_seq_queue_tempo_t *dst, const snd_seq_queue_tempo_t *src); 503 504int snd_seq_queue_tempo_get_queue(const snd_seq_queue_tempo_t *info); 505unsigned int snd_seq_queue_tempo_get_tempo(const snd_seq_queue_tempo_t *info); 506int snd_seq_queue_tempo_get_ppq(const snd_seq_queue_tempo_t *info); 507unsigned int snd_seq_queue_tempo_get_skew(const snd_seq_queue_tempo_t *info); 508unsigned int snd_seq_queue_tempo_get_skew_base(const snd_seq_queue_tempo_t *info); 509void snd_seq_queue_tempo_set_tempo(snd_seq_queue_tempo_t *info, unsigned int tempo); 510void snd_seq_queue_tempo_set_ppq(snd_seq_queue_tempo_t *info, int ppq); 511void snd_seq_queue_tempo_set_skew(snd_seq_queue_tempo_t *info, unsigned int skew); 512void snd_seq_queue_tempo_set_skew_base(snd_seq_queue_tempo_t *info, unsigned int base); 513 514int snd_seq_get_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo); 515int snd_seq_set_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo); 516 517/* 518 */ 519 520/** sequencer timer sources */ 521typedef enum { 522 SND_SEQ_TIMER_ALSA = 0, /* ALSA timer */ 523 SND_SEQ_TIMER_MIDI_CLOCK = 1, /* Midi Clock (CLOCK event) */ 524 SND_SEQ_TIMER_MIDI_TICK = 2 /* Midi Timer Tick (TICK event */ 525} snd_seq_queue_timer_type_t; 526 527size_t snd_seq_queue_timer_sizeof(void); 528/** allocate a #snd_seq_queue_timer_t container on stack */ 529#define snd_seq_queue_timer_alloca(ptr) \ 530 __snd_alloca(ptr, snd_seq_queue_timer) 531int snd_seq_queue_timer_malloc(snd_seq_queue_timer_t **ptr); 532void snd_seq_queue_timer_free(snd_seq_queue_timer_t *ptr); 533void snd_seq_queue_timer_copy(snd_seq_queue_timer_t *dst, const snd_seq_queue_timer_t *src); 534 535int snd_seq_queue_timer_get_queue(const snd_seq_queue_timer_t *info); 536snd_seq_queue_timer_type_t snd_seq_queue_timer_get_type(const snd_seq_queue_timer_t *info); 537const snd_timer_id_t *snd_seq_queue_timer_get_id(const snd_seq_queue_timer_t *info); 538unsigned int snd_seq_queue_timer_get_resolution(const snd_seq_queue_timer_t *info); 539 540void snd_seq_queue_timer_set_type(snd_seq_queue_timer_t *info, snd_seq_queue_timer_type_t type); 541void snd_seq_queue_timer_set_id(snd_seq_queue_timer_t *info, const snd_timer_id_t *id); 542void snd_seq_queue_timer_set_resolution(snd_seq_queue_timer_t *info, unsigned int resolution); 543 544int snd_seq_get_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer); 545int snd_seq_set_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer); 546 547/** \} */ 548 549/** 550 * \defgroup SeqEvent Sequencer Event API 551 * Sequencer Event API 552 * \ingroup Sequencer 553 * \{ 554 */ 555 556int snd_seq_free_event(snd_seq_event_t *ev); 557ssize_t snd_seq_event_length(snd_seq_event_t *ev); 558int snd_seq_event_output(snd_seq_t *handle, snd_seq_event_t *ev); 559int snd_seq_event_output_buffer(snd_seq_t *handle, snd_seq_event_t *ev); 560int snd_seq_event_output_direct(snd_seq_t *handle, snd_seq_event_t *ev); 561int snd_seq_event_input(snd_seq_t *handle, snd_seq_event_t **ev); 562int snd_seq_event_input_pending(snd_seq_t *seq, int fetch_sequencer); 563int snd_seq_drain_output(snd_seq_t *handle); 564int snd_seq_event_output_pending(snd_seq_t *seq); 565int snd_seq_extract_output(snd_seq_t *handle, snd_seq_event_t **ev); 566int snd_seq_drop_output(snd_seq_t *handle); 567int snd_seq_drop_output_buffer(snd_seq_t *handle); 568int snd_seq_drop_input(snd_seq_t *handle); 569int snd_seq_drop_input_buffer(snd_seq_t *handle); 570 571/** event removal conditionals */ 572typedef struct _snd_seq_remove_events snd_seq_remove_events_t; 573 574/** Remove conditional flags */ 575#define SND_SEQ_REMOVE_INPUT (1<<0) /**< Flush input queues */ 576#define SND_SEQ_REMOVE_OUTPUT (1<<1) /**< Flush output queues */ 577#define SND_SEQ_REMOVE_DEST (1<<2) /**< Restrict by destination q:client:port */ 578#define SND_SEQ_REMOVE_DEST_CHANNEL (1<<3) /**< Restrict by channel */ 579#define SND_SEQ_REMOVE_TIME_BEFORE (1<<4) /**< Restrict to before time */ 580#define SND_SEQ_REMOVE_TIME_AFTER (1<<5) /**< Restrict to time or after */ 581#define SND_SEQ_REMOVE_TIME_TICK (1<<6) /**< Time is in ticks */ 582#define SND_SEQ_REMOVE_EVENT_TYPE (1<<7) /**< Restrict to event type */ 583#define SND_SEQ_REMOVE_IGNORE_OFF (1<<8) /**< Do not flush off events */ 584#define SND_SEQ_REMOVE_TAG_MATCH (1<<9) /**< Restrict to events with given tag */ 585 586size_t snd_seq_remove_events_sizeof(void); 587/** allocate a #snd_seq_remove_events_t container on stack */ 588#define snd_seq_remove_events_alloca(ptr) \ 589 __snd_alloca(ptr, snd_seq_remove_events) 590int snd_seq_remove_events_malloc(snd_seq_remove_events_t **ptr); 591void snd_seq_remove_events_free(snd_seq_remove_events_t *ptr); 592void snd_seq_remove_events_copy(snd_seq_remove_events_t *dst, const snd_seq_remove_events_t *src); 593 594unsigned int snd_seq_remove_events_get_condition(const snd_seq_remove_events_t *info); 595int snd_seq_remove_events_get_queue(const snd_seq_remove_events_t *info); 596const snd_seq_timestamp_t *snd_seq_remove_events_get_time(const snd_seq_remove_events_t *info); 597const snd_seq_addr_t *snd_seq_remove_events_get_dest(const snd_seq_remove_events_t *info); 598int snd_seq_remove_events_get_channel(const snd_seq_remove_events_t *info); 599int snd_seq_remove_events_get_event_type(const snd_seq_remove_events_t *info); 600int snd_seq_remove_events_get_tag(const snd_seq_remove_events_t *info); 601 602void snd_seq_remove_events_set_condition(snd_seq_remove_events_t *info, unsigned int flags); 603void snd_seq_remove_events_set_queue(snd_seq_remove_events_t *info, int queue); 604void snd_seq_remove_events_set_time(snd_seq_remove_events_t *info, const snd_seq_timestamp_t *time); 605void snd_seq_remove_events_set_dest(snd_seq_remove_events_t *info, const snd_seq_addr_t *addr); 606void snd_seq_remove_events_set_channel(snd_seq_remove_events_t *info, int channel); 607void snd_seq_remove_events_set_event_type(snd_seq_remove_events_t *info, int type); 608void snd_seq_remove_events_set_tag(snd_seq_remove_events_t *info, int tag); 609 610int snd_seq_remove_events(snd_seq_t *handle, snd_seq_remove_events_t *info); 611 612int snd_seq_ump_event_output(snd_seq_t *seq, snd_seq_ump_event_t *ev); 613int snd_seq_ump_event_output_buffer(snd_seq_t *seq, snd_seq_ump_event_t *ev); 614int snd_seq_ump_extract_output(snd_seq_t *seq, snd_seq_ump_event_t **ev_res); 615int snd_seq_ump_event_output_direct(snd_seq_t *seq, snd_seq_ump_event_t *ev); 616int snd_seq_ump_event_input(snd_seq_t *seq, snd_seq_ump_event_t **ev); 617 618/** \} */ 619 620/** 621 * \defgroup SeqMisc Sequencer Miscellaneous 622 * Sequencer Miscellaneous 623 * \ingroup Sequencer 624 * \{ 625 */ 626 627void snd_seq_set_bit(int nr, void *array); 628void snd_seq_unset_bit(int nr, void *array); 629int snd_seq_change_bit(int nr, void *array); 630int snd_seq_get_bit(int nr, void *array); 631 632/** \} */ 633 634 635/** 636 * \defgroup SeqEvType Sequencer Event Type Checks 637 * Sequencer Event Type Checks 638 * \ingroup Sequencer 639 * \{ 640 */ 641 642/* event type macros */ 643enum { 644 SND_SEQ_EVFLG_RESULT, 645 SND_SEQ_EVFLG_NOTE, 646 SND_SEQ_EVFLG_CONTROL, 647 SND_SEQ_EVFLG_QUEUE, 648 SND_SEQ_EVFLG_SYSTEM, 649 SND_SEQ_EVFLG_MESSAGE, 650 SND_SEQ_EVFLG_CONNECTION, 651 SND_SEQ_EVFLG_SAMPLE, 652 SND_SEQ_EVFLG_USERS, 653 SND_SEQ_EVFLG_INSTR, 654 SND_SEQ_EVFLG_QUOTE, 655 SND_SEQ_EVFLG_NONE, 656 SND_SEQ_EVFLG_RAW, 657 SND_SEQ_EVFLG_FIXED, 658 SND_SEQ_EVFLG_VARIABLE, 659 SND_SEQ_EVFLG_VARUSR 660}; 661 662enum { 663 SND_SEQ_EVFLG_NOTE_ONEARG, 664 SND_SEQ_EVFLG_NOTE_TWOARG 665}; 666 667enum { 668 SND_SEQ_EVFLG_QUEUE_NOARG, 669 SND_SEQ_EVFLG_QUEUE_TICK, 670 SND_SEQ_EVFLG_QUEUE_TIME, 671 SND_SEQ_EVFLG_QUEUE_VALUE 672}; 673 674/** 675 * Exported event type table 676 * 677 * This table is referred by snd_seq_ev_is_xxx. 678 */ 679extern const unsigned int snd_seq_event_types[]; 680 681#define _SND_SEQ_TYPE(x) (1<<(x)) /**< master type - 24bit */ 682#define _SND_SEQ_TYPE_OPT(x) ((x)<<24) /**< optional type - 8bit */ 683 684/** check the event type */ 685#define snd_seq_type_check(ev,x) (snd_seq_event_types[(ev)->type] & _SND_SEQ_TYPE(x)) 686 687/** event type check: result events */ 688#define snd_seq_ev_is_result_type(ev) \ 689 snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT) 690/** event type check: note events */ 691#define snd_seq_ev_is_note_type(ev) \ 692 snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE) 693/** event type check: control events */ 694#define snd_seq_ev_is_control_type(ev) \ 695 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL) 696/** event type check: channel specific events */ 697#define snd_seq_ev_is_channel_type(ev) \ 698 (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL))) 699 700/** event type check: queue control events */ 701#define snd_seq_ev_is_queue_type(ev) \ 702 snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE) 703/** event type check: system status messages */ 704#define snd_seq_ev_is_message_type(ev) \ 705 snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE) 706/** event type check: system status messages */ 707#define snd_seq_ev_is_subscribe_type(ev) \ 708 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION) 709/** event type check: sample messages */ 710#define snd_seq_ev_is_sample_type(ev) \ 711 snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE) 712/** event type check: user-defined messages */ 713#define snd_seq_ev_is_user_type(ev) \ 714 snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS) 715/** event type check: instrument layer events */ 716#define snd_seq_ev_is_instr_type(ev) \ 717 snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR) 718/** event type check: fixed length events */ 719#define snd_seq_ev_is_fixed_type(ev) \ 720 snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED) 721/** event type check: variable length events */ 722#define snd_seq_ev_is_variable_type(ev) \ 723 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE) 724/** event type check: user pointer events */ 725#define snd_seq_ev_is_varusr_type(ev) \ 726 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR) 727/** event type check: reserved for kernel */ 728#define snd_seq_ev_is_reserved(ev) \ 729 (! snd_seq_event_types[(ev)->type]) 730 731/** 732 * macros to check event flags 733 */ 734/** prior events */ 735#define snd_seq_ev_is_prior(ev) \ 736 (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH) 737 738/** get the data length type */ 739#define snd_seq_ev_length_type(ev) \ 740 ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK) 741/** fixed length events */ 742#define snd_seq_ev_is_fixed(ev) \ 743 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED) 744/** variable length events */ 745#define snd_seq_ev_is_variable(ev) \ 746 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE) 747/** variable length on user-space */ 748#define snd_seq_ev_is_varusr(ev) \ 749 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR) 750 751/** time-stamp type */ 752#define snd_seq_ev_timestamp_type(ev) \ 753 ((ev)->flags & SND_SEQ_TIME_STAMP_MASK) 754/** event is in tick time */ 755#define snd_seq_ev_is_tick(ev) \ 756 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK) 757/** event is in real-time */ 758#define snd_seq_ev_is_real(ev) \ 759 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL) 760 761/** time-mode type */ 762#define snd_seq_ev_timemode_type(ev) \ 763 ((ev)->flags & SND_SEQ_TIME_MODE_MASK) 764/** scheduled in absolute time */ 765#define snd_seq_ev_is_abstime(ev) \ 766 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS) 767/** scheduled in relative time */ 768#define snd_seq_ev_is_reltime(ev) \ 769 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL) 770 771/** direct dispatched events */ 772#define snd_seq_ev_is_direct(ev) \ 773 ((ev)->queue == SND_SEQ_QUEUE_DIRECT) 774 775/** UMP events */ 776#define snd_seq_ev_is_ump(ev) \ 777 ((ev)->flags & SND_SEQ_EVENT_UMP) 778 779/** \} */ 780 781#ifdef __cplusplus 782} 783#endif 784 785#endif /* __ALSA_SEQ_H */ 786 787