3 * \brief Application interface library for the ALSA driver
4 * \author Jaroslav Kysela <perex@suse.cz>
5 * \author Abramo Bagnara <abramo@alsa-project.org>
6 * \author Takashi Iwai <tiwai@suse.de>
9 * Application interface library for the ALSA driver
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
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 Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36 * \defgroup Sequencer MIDI Sequencer
37 * MIDI Sequencer Interface
41 /** dlsym version for interface entry callback */
42 #define SND_SEQ_DLSYM_VERSION _dlsym_seq_001
44 /** Sequencer handle */
45 typedef struct _snd_seq snd_seq_t;
48 #define SND_ALLOCA(type,ptr) \
51 *ptr = (type##_t *)alloca(type##_sizeof());\
52 memset(*ptr, 0, type##_sizeof());\
56 * sequencer opening stream types
58 #define SND_SEQ_OPEN_OUTPUT 1 /**< open for output (write) */
59 #define SND_SEQ_OPEN_INPUT 2 /**< open for input (read) */
60 #define SND_SEQ_OPEN_DUPLEX (SND_SEQ_OPEN_OUTPUT|SND_SEQ_OPEN_INPUT) /**< open for both input and output (read/write) */
63 * sequencer opening mode
65 #define SND_SEQ_NONBLOCK 1 /**< non-blocking mode */
67 /** sequencer handle type */
68 typedef enum _snd_seq_type {
69 SND_SEQ_TYPE_HW, /**< hardware */
70 SND_SEQ_TYPE_SHM, /**< shared memory (NYI) */
71 SND_SEQ_TYPE_INET, /**< network (NYI) */
74 /** special client (port) ids */
75 #define SND_SEQ_ADDRESS_UNKNOWN 253 /**< unknown source */
76 #define SND_SEQ_ADDRESS_SUBSCRIBERS 254 /**< send event to all subscribed ports */
77 #define SND_SEQ_ADDRESS_BROADCAST 255 /**< send event to all queues/clients/ports/channels */
79 /** known client numbers */
80 #define SND_SEQ_CLIENT_SYSTEM 0 /**< system client */
81 #define SND_SEQ_CLIENT_DUMMY 62 /**< dummy ports */
82 #define SND_SEQ_CLIENT_OSS 63 /**< oss sequencer emulator */
86 int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode);
87 int snd_seq_open_lconf(snd_seq_t **handle, const char *name, int streams, int mode, snd_config_t *lconf);
88 const char *snd_seq_name(snd_seq_t *seq);
89 snd_seq_type_t snd_seq_type(snd_seq_t *seq);
90 int snd_seq_close(snd_seq_t *handle);
91 int snd_seq_poll_descriptors_count(snd_seq_t *handle, short events);
92 int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space, short events);
93 int snd_seq_poll_descriptors_revents(snd_seq_t *seq, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
94 int snd_seq_nonblock(snd_seq_t *handle, int nonblock);
95 int snd_seq_client_id(snd_seq_t *handle);
97 size_t snd_seq_get_output_buffer_size(snd_seq_t *handle);
98 size_t snd_seq_get_input_buffer_size(snd_seq_t *handle);
99 int snd_seq_set_output_buffer_size(snd_seq_t *handle, size_t size);
100 int snd_seq_set_input_buffer_size(snd_seq_t *handle, size_t size);
102 /** system information container */
103 typedef struct _snd_seq_system_info snd_seq_system_info_t;
105 size_t snd_seq_system_info_sizeof(void);
106 /** allocate a #snd_seq_system_info_t container on stack */
107 #define snd_seq_system_info_alloca(ptr) \
108 SND_ALLOCA(snd_seq_system_info, ptr)
109 int snd_seq_system_info_malloc(snd_seq_system_info_t **ptr);
110 void snd_seq_system_info_free(snd_seq_system_info_t *ptr);
111 void snd_seq_system_info_copy(snd_seq_system_info_t *dst, const snd_seq_system_info_t *src);
113 int snd_seq_system_info_get_queues(const snd_seq_system_info_t *info);
114 int snd_seq_system_info_get_clients(const snd_seq_system_info_t *info);
115 int snd_seq_system_info_get_ports(const snd_seq_system_info_t *info);
116 int snd_seq_system_info_get_channels(const snd_seq_system_info_t *info);
117 int snd_seq_system_info_get_cur_clients(const snd_seq_system_info_t *info);
118 int snd_seq_system_info_get_cur_queues(const snd_seq_system_info_t *info);
120 int snd_seq_system_info(snd_seq_t *handle, snd_seq_system_info_t *info);
126 * \defgroup SeqClient Sequencer Client Interface
127 * Sequencer Client Interface
132 /** client information container */
133 typedef struct _snd_seq_client_info snd_seq_client_info_t;
136 typedef enum snd_seq_client_type {
137 SND_SEQ_USER_CLIENT = 1, /**< user client */
138 SND_SEQ_KERNEL_CLIENT = 2 /**< kernel client */
139 } snd_seq_client_type_t;
141 size_t snd_seq_client_info_sizeof(void);
142 /** allocate a #snd_seq_client_info_t container on stack */
143 #define snd_seq_client_info_alloca(ptr) \
144 SND_ALLOCA(snd_seq_client_info, ptr)
145 int snd_seq_client_info_malloc(snd_seq_client_info_t **ptr);
146 void snd_seq_client_info_free(snd_seq_client_info_t *ptr);
147 void snd_seq_client_info_copy(snd_seq_client_info_t *dst, const snd_seq_client_info_t *src);
149 int snd_seq_client_info_get_client(const snd_seq_client_info_t *info);
150 snd_seq_client_type_t snd_seq_client_info_get_type(const snd_seq_client_info_t *info);
151 const char *snd_seq_client_info_get_name(snd_seq_client_info_t *info);
152 int snd_seq_client_info_get_broadcast_filter(const snd_seq_client_info_t *info);
153 int snd_seq_client_info_get_error_bounce(const snd_seq_client_info_t *info);
154 const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_info_t *info);
155 int snd_seq_client_info_get_num_ports(const snd_seq_client_info_t *info);
156 int snd_seq_client_info_get_event_lost(const snd_seq_client_info_t *info);
158 void snd_seq_client_info_set_client(snd_seq_client_info_t *info, int client);
159 void snd_seq_client_info_set_name(snd_seq_client_info_t *info, const char *name);
160 void snd_seq_client_info_set_broadcast_filter(snd_seq_client_info_t *info, int val);
161 void snd_seq_client_info_set_error_bounce(snd_seq_client_info_t *info, int val);
162 void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned char *filter);
164 int snd_seq_get_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
165 int snd_seq_get_any_client_info(snd_seq_t *handle, int client, snd_seq_client_info_t *info);
166 int snd_seq_set_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
167 int snd_seq_query_next_client(snd_seq_t *handle, snd_seq_client_info_t *info);
172 /** client pool information container */
173 typedef struct _snd_seq_client_pool snd_seq_client_pool_t;
175 size_t snd_seq_client_pool_sizeof(void);
176 /** allocate a #snd_seq_client_pool_t container on stack */
177 #define snd_seq_client_pool_alloca(ptr) \
178 SND_ALLOCA(snd_seq_client_pool, ptr)
179 int snd_seq_client_pool_malloc(snd_seq_client_pool_t **ptr);
180 void snd_seq_client_pool_free(snd_seq_client_pool_t *ptr);
181 void snd_seq_client_pool_copy(snd_seq_client_pool_t *dst, const snd_seq_client_pool_t *src);
183 int snd_seq_client_pool_get_client(const snd_seq_client_pool_t *info);
184 size_t snd_seq_client_pool_get_output_pool(const snd_seq_client_pool_t *info);
185 size_t snd_seq_client_pool_get_input_pool(const snd_seq_client_pool_t *info);
186 size_t snd_seq_client_pool_get_output_room(const snd_seq_client_pool_t *info);
187 size_t snd_seq_client_pool_get_output_free(const snd_seq_client_pool_t *info);
188 size_t snd_seq_client_pool_get_input_free(const snd_seq_client_pool_t *info);
189 void snd_seq_client_pool_set_output_pool(snd_seq_client_pool_t *info, size_t size);
190 void snd_seq_client_pool_set_input_pool(snd_seq_client_pool_t *info, size_t size);
191 void snd_seq_client_pool_set_output_room(snd_seq_client_pool_t *info, size_t size);
193 int snd_seq_get_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
194 int snd_seq_set_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
201 * \defgroup SeqPort Sequencer Port Interface
202 * Sequencer Port Interface
207 /** port information container */
208 typedef struct _snd_seq_port_info snd_seq_port_info_t;
210 /** known port numbers */
211 #define SND_SEQ_PORT_SYSTEM_TIMER 0 /**< system timer port */
212 #define SND_SEQ_PORT_SYSTEM_ANNOUNCE 1 /**< sysem announce port */
214 /** port capabilities (32 bits) */
215 #define SND_SEQ_PORT_CAP_READ (1<<0) /**< readable from this port */
216 #define SND_SEQ_PORT_CAP_WRITE (1<<1) /**< writable to this port */
218 #define SND_SEQ_PORT_CAP_SYNC_READ (1<<2) /**< allow read subscriptions */
219 #define SND_SEQ_PORT_CAP_SYNC_WRITE (1<<3) /**< allow write subscriptions */
221 #define SND_SEQ_PORT_CAP_DUPLEX (1<<4) /**< allow read/write duplex */
223 #define SND_SEQ_PORT_CAP_SUBS_READ (1<<5) /**< allow read subscription */
224 #define SND_SEQ_PORT_CAP_SUBS_WRITE (1<<6) /**< allow write subscription */
225 #define SND_SEQ_PORT_CAP_NO_EXPORT (1<<7) /**< routing not allowed */
228 #define SND_SEQ_PORT_TYPE_SPECIFIC (1<<0) /**< hardware specific */
229 #define SND_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) /**< generic MIDI device */
230 #define SND_SEQ_PORT_TYPE_MIDI_GM (1<<2) /**< General MIDI compatible device */
231 #define SND_SEQ_PORT_TYPE_MIDI_GS (1<<3) /**< GS compatible device */
232 #define SND_SEQ_PORT_TYPE_MIDI_XG (1<<4) /**< XG compatible device */
233 #define SND_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) /**< MT-32 compatible device */
234 #define SND_SEQ_PORT_TYPE_SYNTH (1<<10) /**< Synth device */
235 #define SND_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11) /**< Sampling device (support sample download) */
236 #define SND_SEQ_PORT_TYPE_SAMPLE (1<<12) /**< Sampling device (sample can be downloaded at any time) */
237 #define SND_SEQ_PORT_TYPE_APPLICATION (1<<20) /**< application (sequencer/editor) */
240 size_t snd_seq_port_info_sizeof(void);
241 /** allocate a #snd_seq_port_info_t container on stack */
242 #define snd_seq_port_info_alloca(ptr) \
243 SND_ALLOCA(snd_seq_port_info, ptr)
244 int snd_seq_port_info_malloc(snd_seq_port_info_t **ptr);
245 void snd_seq_port_info_free(snd_seq_port_info_t *ptr);
246 void snd_seq_port_info_copy(snd_seq_port_info_t *dst, const snd_seq_port_info_t *src);
248 int snd_seq_port_info_get_client(const snd_seq_port_info_t *info);
249 int snd_seq_port_info_get_port(const snd_seq_port_info_t *info);
250 const snd_seq_addr_t *snd_seq_port_info_get_addr(const snd_seq_port_info_t *info);
251 const char *snd_seq_port_info_get_name(const snd_seq_port_info_t *info);
252 unsigned int snd_seq_port_info_get_capability(const snd_seq_port_info_t *info);
253 unsigned int snd_seq_port_info_get_type(const snd_seq_port_info_t *info);
254 int snd_seq_port_info_get_midi_channels(const snd_seq_port_info_t *info);
255 int snd_seq_port_info_get_midi_voices(const snd_seq_port_info_t *info);
256 int snd_seq_port_info_get_synth_voices(const snd_seq_port_info_t *info);
257 int snd_seq_port_info_get_read_use(const snd_seq_port_info_t *info);
258 int snd_seq_port_info_get_write_use(const snd_seq_port_info_t *info);
259 int snd_seq_port_info_get_port_specified(const snd_seq_port_info_t *info);
261 void snd_seq_port_info_set_client(snd_seq_port_info_t *info, int client);
262 void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port);
263 void snd_seq_port_info_set_addr(snd_seq_port_info_t *info, const snd_seq_addr_t *addr);
264 void snd_seq_port_info_set_name(snd_seq_port_info_t *info, const char *name);
265 void snd_seq_port_info_set_capability(snd_seq_port_info_t *info, unsigned int capability);
266 void snd_seq_port_info_set_type(snd_seq_port_info_t *info, unsigned int type);
267 void snd_seq_port_info_set_midi_channels(snd_seq_port_info_t *info, int channels);
268 void snd_seq_port_info_set_midi_voices(snd_seq_port_info_t *info, int voices);
269 void snd_seq_port_info_set_synth_voices(snd_seq_port_info_t *info, int voices);
270 void snd_seq_port_info_set_port_specified(snd_seq_port_info_t *info, int val);
272 int snd_seq_create_port(snd_seq_t *handle, snd_seq_port_info_t *info);
273 int snd_seq_delete_port(snd_seq_t *handle, int port);
274 int snd_seq_get_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
275 int snd_seq_get_any_port_info(snd_seq_t *handle, int client, int port, snd_seq_port_info_t *info);
276 int snd_seq_set_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
277 int snd_seq_query_next_port(snd_seq_t *handle, snd_seq_port_info_t *info);
283 * \defgroup SeqSubscribe Sequencer Port Subscription
284 * Sequencer Port Subscription
289 /** port subscription container */
290 typedef struct _snd_seq_port_subscribe snd_seq_port_subscribe_t;
292 size_t snd_seq_port_subscribe_sizeof(void);
293 /** allocate a #snd_seq_port_subscribe_t container on stack */
294 #define snd_seq_port_subscribe_alloca(ptr) \
295 SND_ALLOCA(snd_seq_port_subscribe, ptr)
296 int snd_seq_port_subscribe_malloc(snd_seq_port_subscribe_t **ptr);
297 void snd_seq_port_subscribe_free(snd_seq_port_subscribe_t *ptr);
298 void snd_seq_port_subscribe_copy(snd_seq_port_subscribe_t *dst, const snd_seq_port_subscribe_t *src);
300 const snd_seq_addr_t *snd_seq_port_subscribe_get_sender(const snd_seq_port_subscribe_t *info);
301 const snd_seq_addr_t *snd_seq_port_subscribe_get_dest(const snd_seq_port_subscribe_t *info);
302 int snd_seq_port_subscribe_get_queue(const snd_seq_port_subscribe_t *info);
303 int snd_seq_port_subscribe_get_exclusive(const snd_seq_port_subscribe_t *info);
304 int snd_seq_port_subscribe_get_time_update(const snd_seq_port_subscribe_t *info);
305 int snd_seq_port_subscribe_get_time_real(const snd_seq_port_subscribe_t *info);
307 void snd_seq_port_subscribe_set_sender(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
308 void snd_seq_port_subscribe_set_dest(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
309 void snd_seq_port_subscribe_set_queue(snd_seq_port_subscribe_t *info, int q);
310 void snd_seq_port_subscribe_set_exclusive(snd_seq_port_subscribe_t *info, int val);
311 void snd_seq_port_subscribe_set_time_update(snd_seq_port_subscribe_t *info, int val);
312 void snd_seq_port_subscribe_set_time_real(snd_seq_port_subscribe_t *info, int val);
314 int snd_seq_get_port_subscription(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
315 int snd_seq_subscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
316 int snd_seq_unsubscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
321 /** subscription query container */
322 typedef struct _snd_seq_query_subscribe snd_seq_query_subscribe_t;
324 /** type of query subscription */
326 SND_SEQ_QUERY_SUBS_READ, /**< query read subscriptions */
327 SND_SEQ_QUERY_SUBS_WRITE /**< query write subscriptions */
328 } snd_seq_query_subs_type_t;
330 size_t snd_seq_query_subscribe_sizeof(void);
331 /** allocate a #snd_seq_query_subscribe_t container on stack */
332 #define snd_seq_query_subscribe_alloca(ptr) \
333 SND_ALLOCA(snd_seq_query_subscribe, ptr)
334 int snd_seq_query_subscribe_malloc(snd_seq_query_subscribe_t **ptr);
335 void snd_seq_query_subscribe_free(snd_seq_query_subscribe_t *ptr);
336 void snd_seq_query_subscribe_copy(snd_seq_query_subscribe_t *dst, const snd_seq_query_subscribe_t *src);
338 int snd_seq_query_subscribe_get_client(const snd_seq_query_subscribe_t *info);
339 int snd_seq_query_subscribe_get_port(const snd_seq_query_subscribe_t *info);
340 const snd_seq_addr_t *snd_seq_query_subscribe_get_root(const snd_seq_query_subscribe_t *info);
341 snd_seq_query_subs_type_t snd_seq_query_subscribe_get_type(const snd_seq_query_subscribe_t *info);
342 int snd_seq_query_subscribe_get_index(const snd_seq_query_subscribe_t *info);
343 int snd_seq_query_subscribe_get_num_subs(const snd_seq_query_subscribe_t *info);
344 const snd_seq_addr_t *snd_seq_query_subscribe_get_addr(const snd_seq_query_subscribe_t *info);
345 int snd_seq_query_subscribe_get_queue(const snd_seq_query_subscribe_t *info);
346 int snd_seq_query_subscribe_get_exclusive(const snd_seq_query_subscribe_t *info);
347 int snd_seq_query_subscribe_get_time_update(const snd_seq_query_subscribe_t *info);
348 int snd_seq_query_subscribe_get_time_real(const snd_seq_query_subscribe_t *info);
350 void snd_seq_query_subscribe_set_client(snd_seq_query_subscribe_t *info, int client);
351 void snd_seq_query_subscribe_set_port(snd_seq_query_subscribe_t *info, int port);
352 void snd_seq_query_subscribe_set_root(snd_seq_query_subscribe_t *info, const snd_seq_addr_t *addr);
353 void snd_seq_query_subscribe_set_type(snd_seq_query_subscribe_t *info, snd_seq_query_subs_type_t type);
354 void snd_seq_query_subscribe_set_index(snd_seq_query_subscribe_t *info, int index);
356 int snd_seq_query_port_subscribers(snd_seq_t *seq, snd_seq_query_subscribe_t * subs);
362 * \defgroup SeqQueue Sequencer Queue Interface
363 * Sequencer Queue Interface
368 /** queue information container */
369 typedef struct _snd_seq_queue_info snd_seq_queue_info_t;
370 /** queue status container */
371 typedef struct _snd_seq_queue_status snd_seq_queue_status_t;
372 /** queue tempo container */
373 typedef struct _snd_seq_queue_tempo snd_seq_queue_tempo_t;
374 /** queue timer information container */
375 typedef struct _snd_seq_queue_timer snd_seq_queue_timer_t;
377 /** special queue ids */
378 #define SND_SEQ_QUEUE_DIRECT 253 /**< direct dispatch */
380 size_t snd_seq_queue_info_sizeof(void);
381 /** allocate a #snd_seq_queue_info_t container on stack */
382 #define snd_seq_queue_info_alloca(ptr) \
383 SND_ALLOCA(snd_seq_queue_info, ptr)
384 int snd_seq_queue_info_malloc(snd_seq_queue_info_t **ptr);
385 void snd_seq_queue_info_free(snd_seq_queue_info_t *ptr);
386 void snd_seq_queue_info_copy(snd_seq_queue_info_t *dst, const snd_seq_queue_info_t *src);
388 int snd_seq_queue_info_get_queue(const snd_seq_queue_info_t *info);
389 const char *snd_seq_queue_info_get_name(const snd_seq_queue_info_t *info);
390 int snd_seq_queue_info_get_owner(const snd_seq_queue_info_t *info);
391 int snd_seq_queue_info_get_locked(const snd_seq_queue_info_t *info);
392 unsigned int snd_seq_queue_info_get_flags(const snd_seq_queue_info_t *info);
394 void snd_seq_queue_info_set_name(snd_seq_queue_info_t *info, const char *name);
395 void snd_seq_queue_info_set_owner(snd_seq_queue_info_t *info, int owner);
396 void snd_seq_queue_info_set_locked(snd_seq_queue_info_t *info, int locked);
397 void snd_seq_queue_info_set_flags(snd_seq_queue_info_t *info, unsigned int flags);
399 int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info);
400 int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name);
401 int snd_seq_alloc_queue(snd_seq_t *handle);
402 int snd_seq_free_queue(snd_seq_t *handle, int q);
403 int snd_seq_get_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
404 int snd_seq_set_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
405 int snd_seq_query_named_queue(snd_seq_t *seq, const char *name);
407 int snd_seq_get_queue_usage(snd_seq_t *handle, int q);
408 int snd_seq_set_queue_usage(snd_seq_t *handle, int q, int used);
412 size_t snd_seq_queue_status_sizeof(void);
413 /** allocate a #snd_seq_queue_status_t container on stack */
414 #define snd_seq_queue_status_alloca(ptr) \
415 SND_ALLOCA(snd_seq_queue_status, ptr)
416 int snd_seq_queue_status_malloc(snd_seq_queue_status_t **ptr);
417 void snd_seq_queue_status_free(snd_seq_queue_status_t *ptr);
418 void snd_seq_queue_status_copy(snd_seq_queue_status_t *dst, const snd_seq_queue_status_t *src);
420 int snd_seq_queue_status_get_queue(const snd_seq_queue_status_t *info);
421 int snd_seq_queue_status_get_events(const snd_seq_queue_status_t *info);
422 snd_seq_tick_time_t snd_seq_queue_status_get_tick_time(const snd_seq_queue_status_t *info);
423 const snd_seq_real_time_t *snd_seq_queue_status_get_real_time(const snd_seq_queue_status_t *info);
424 unsigned int snd_seq_queue_status_get_status(const snd_seq_queue_status_t *info);
426 int snd_seq_get_queue_status(snd_seq_t *handle, int q, snd_seq_queue_status_t *status);
430 size_t snd_seq_queue_tempo_sizeof(void);
431 /** allocate a #snd_seq_queue_tempo_t container on stack */
432 #define snd_seq_queue_tempo_alloca(ptr) \
433 SND_ALLOCA(snd_seq_queue_tempo, ptr)
434 int snd_seq_queue_tempo_malloc(snd_seq_queue_tempo_t **ptr);
435 void snd_seq_queue_tempo_free(snd_seq_queue_tempo_t *ptr);
436 void snd_seq_queue_tempo_copy(snd_seq_queue_tempo_t *dst, const snd_seq_queue_tempo_t *src);
438 int snd_seq_queue_tempo_get_queue(const snd_seq_queue_tempo_t *info);
439 unsigned int snd_seq_queue_tempo_get_tempo(const snd_seq_queue_tempo_t *info);
440 int snd_seq_queue_tempo_get_ppq(const snd_seq_queue_tempo_t *info);
441 void snd_seq_queue_tempo_set_tempo(snd_seq_queue_tempo_t *info, unsigned int tempo);
442 void snd_seq_queue_tempo_set_ppq(snd_seq_queue_tempo_t *info, int ppq);
444 int snd_seq_get_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
445 int snd_seq_set_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
450 /** sequencer timer sources */
452 SND_SEQ_TIMER_ALSA = 0, /* ALSA timer */
453 SND_SEQ_TIMER_MIDI_CLOCK = 1, /* Midi Clock (CLOCK event) */
454 SND_SEQ_TIMER_MIDI_TICK = 2, /* Midi Timer Tick (TICK event */
455 } snd_seq_queue_timer_type_t;
457 size_t snd_seq_queue_timer_sizeof(void);
458 /** allocate a #snd_seq_queue_timer_t container on stack */
459 #define snd_seq_queue_timer_alloca(ptr) \
460 SND_ALLOCA(snd_seq_queue_timer, ptr)
461 int snd_seq_queue_timer_malloc(snd_seq_queue_timer_t **ptr);
462 void snd_seq_queue_timer_free(snd_seq_queue_timer_t *ptr);
463 void snd_seq_queue_timer_copy(snd_seq_queue_timer_t *dst, const snd_seq_queue_timer_t *src);
465 int snd_seq_queue_timer_get_queue(const snd_seq_queue_timer_t *info);
466 snd_seq_queue_timer_type_t snd_seq_queue_timer_get_type(const snd_seq_queue_timer_t *info);
467 const snd_timer_id_t *snd_seq_queue_timer_get_id(const snd_seq_queue_timer_t *info);
468 unsigned int snd_seq_queue_timer_get_resolution(const snd_seq_queue_timer_t *info);
470 void snd_seq_queue_timer_set_type(snd_seq_queue_timer_t *info, snd_seq_queue_timer_type_t type);
471 void snd_seq_queue_timer_set_id(snd_seq_queue_timer_t *info, const snd_timer_id_t *id);
472 void snd_seq_queue_timer_set_resolution(snd_seq_queue_timer_t *info, unsigned int resolution);
474 int snd_seq_get_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
475 int snd_seq_set_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
480 * \defgroup SeqEvent Sequencer Event API
481 * Sequencer Event API
486 snd_seq_event_t *snd_seq_create_event(void);
487 int snd_seq_free_event(snd_seq_event_t *ev);
488 ssize_t snd_seq_event_length(snd_seq_event_t *ev);
489 int snd_seq_event_output(snd_seq_t *handle, snd_seq_event_t *ev);
490 int snd_seq_event_output_buffer(snd_seq_t *handle, snd_seq_event_t *ev);
491 int snd_seq_event_output_direct(snd_seq_t *handle, snd_seq_event_t *ev);
492 int snd_seq_event_input(snd_seq_t *handle, snd_seq_event_t **ev);
493 int snd_seq_event_input_pending(snd_seq_t *seq, int fetch_sequencer);
494 int snd_seq_drain_output(snd_seq_t *handle);
495 int snd_seq_event_output_pending(snd_seq_t *seq);
496 int snd_seq_extract_output(snd_seq_t *handle, snd_seq_event_t **ev);
497 int snd_seq_drop_output(snd_seq_t *handle);
498 int snd_seq_drop_output_buffer(snd_seq_t *handle);
499 int snd_seq_drop_input(snd_seq_t *handle);
500 int snd_seq_drop_input_buffer(snd_seq_t *handle);
502 /** event removal conditionals */
503 typedef struct _snd_seq_remove_events snd_seq_remove_events_t;
505 /** Remove conditional flags */
506 #define SND_SEQ_REMOVE_INPUT (1<<0) /**< Flush input queues */
507 #define SND_SEQ_REMOVE_OUTPUT (1<<1) /**< Flush output queues */
508 #define SND_SEQ_REMOVE_DEST (1<<2) /**< Restrict by destination q:client:port */
509 #define SND_SEQ_REMOVE_DEST_CHANNEL (1<<3) /**< Restrict by channel */
510 #define SND_SEQ_REMOVE_TIME_BEFORE (1<<4) /**< Restrict to before time */
511 #define SND_SEQ_REMOVE_TIME_AFTER (1<<5) /**< Restrict to time or after */
512 #define SND_SEQ_REMOVE_TIME_TICK (1<<6) /**< Time is in ticks */
513 #define SND_SEQ_REMOVE_EVENT_TYPE (1<<7) /**< Restrict to event type */
514 #define SND_SEQ_REMOVE_IGNORE_OFF (1<<8) /**< Do not flush off events */
515 #define SND_SEQ_REMOVE_TAG_MATCH (1<<9) /**< Restrict to events with given tag */
517 size_t snd_seq_remove_events_sizeof(void);
518 /** allocate a #snd_seq_remove_events_t container on stack */
519 #define snd_seq_remove_events_alloca(ptr) \
520 SND_ALLOCA(snd_seq_remove_events, ptr)
521 int snd_seq_remove_events_malloc(snd_seq_remove_events_t **ptr);
522 void snd_seq_remove_events_free(snd_seq_remove_events_t *ptr);
523 void snd_seq_remove_events_copy(snd_seq_remove_events_t *dst, const snd_seq_remove_events_t *src);
525 unsigned int snd_seq_remove_events_get_condition(const snd_seq_remove_events_t *info);
526 int snd_seq_remove_events_get_queue(const snd_seq_remove_events_t *info);
527 const snd_seq_timestamp_t *snd_seq_remove_events_get_time(const snd_seq_remove_events_t *info);
528 const snd_seq_addr_t *snd_seq_remove_events_get_dest(const snd_seq_remove_events_t *info);
529 int snd_seq_remove_events_get_channel(const snd_seq_remove_events_t *info);
530 int snd_seq_remove_events_get_event_type(const snd_seq_remove_events_t *info);
531 int snd_seq_remove_events_get_tag(const snd_seq_remove_events_t *info);
533 void snd_seq_remove_events_set_condition(snd_seq_remove_events_t *info, unsigned int flags);
534 void snd_seq_remove_events_set_queue(snd_seq_remove_events_t *info, int queue);
535 void snd_seq_remove_events_set_time(snd_seq_remove_events_t *info, const snd_seq_timestamp_t *time);
536 void snd_seq_remove_events_set_dest(snd_seq_remove_events_t *info, const snd_seq_addr_t *addr);
537 void snd_seq_remove_events_set_channel(snd_seq_remove_events_t *info, int channel);
538 void snd_seq_remove_events_set_event_type(snd_seq_remove_events_t *info, int type);
539 void snd_seq_remove_events_set_tag(snd_seq_remove_events_t *info, int tag);
541 int snd_seq_remove_events(snd_seq_t *handle, snd_seq_remove_events_t *info);
546 * \defgroup SeqMisc Sequencer Miscellaneous
547 * Sequencer Mescellaneous
552 void snd_seq_set_bit(int nr, void *array);
553 int snd_seq_change_bit(int nr, void *array);
554 int snd_seq_get_bit(int nr, void *array);
560 * \defgroup SeqEvType Sequencer Event Type Checks
561 * Sequencer Event Type Checks
566 /* event type macros */
568 SND_SEQ_EVFLG_RESULT,
570 SND_SEQ_EVFLG_CONTROL,
572 SND_SEQ_EVFLG_SYSTEM,
573 SND_SEQ_EVFLG_MESSAGE,
574 SND_SEQ_EVFLG_CONNECTION,
575 SND_SEQ_EVFLG_SAMPLE,
582 SND_SEQ_EVFLG_VARIABLE,
583 SND_SEQ_EVFLG_VARUSR,
588 SND_SEQ_EVFLG_NOTE_ONEARG,
589 SND_SEQ_EVFLG_NOTE_TWOARG
593 SND_SEQ_EVFLG_QUEUE_NOARG,
594 SND_SEQ_EVFLG_QUEUE_TICK,
595 SND_SEQ_EVFLG_QUEUE_TIME,
596 SND_SEQ_EVFLG_QUEUE_VALUE
600 * Exported event type table
602 * This table is referred by snd_seq_ev_is_xxx.
604 extern const unsigned int snd_seq_event_types[];
606 #define _SND_SEQ_TYPE(x) (1<<(x)) /**< master type - 24bit */
607 #define _SND_SEQ_TYPE_OPT(x) ((x)<<24) /**< optional type - 8bit */
609 /** check the event type */
610 #define snd_seq_type_check(ev,x) (snd_seq_event_types[(ev)->type] & _SND_SEQ_TYPE(x))
612 /** event type check: result events */
613 #define snd_seq_ev_is_result_type(ev) \
614 snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT)
615 /** event type check: note events */
616 #define snd_seq_ev_is_note_type(ev) \
617 snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE)
618 /** event type check: control events */
619 #define snd_seq_ev_is_control_type(ev) \
620 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL)
621 /** event type check: channel specific events */
622 #define snd_seq_ev_is_channel_type(ev) \
623 (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL)))
625 /** event type check: queue control events */
626 #define snd_seq_ev_is_queue_type(ev) \
627 snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE)
628 /** event type check: system status messages */
629 #define snd_seq_ev_is_message_type(ev) \
630 snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE)
631 /** event type check: system status messages */
632 #define snd_seq_ev_is_subscribe_type(ev) \
633 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION)
634 /** event type check: sample messages */
635 #define snd_seq_ev_is_sample_type(ev) \
636 snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE)
637 /** event type check: user-defined messages */
638 #define snd_seq_ev_is_user_type(ev) \
639 snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS)
640 /** event type check: instrument layer events */
641 #define snd_seq_ev_is_instr_type(ev) \
642 snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR)
643 /** event type check: fixed length events */
644 #define snd_seq_ev_is_fixed_type(ev) \
645 snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED)
646 /** event type check: variable length events */
647 #define snd_seq_ev_is_variable_type(ev) \
648 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE)
649 /** event type check: user pointer events */
650 #define snd_seq_ev_is_varusr_type(ev) \
651 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR)
652 /** event type check: ipc events */
653 #define snd_seq_ev_is_varipc_type(ev) \
654 snd_seq_type_check(ev, SND_SEQ_EVFLG_IPC)
655 /** event type check: reserved for kernel */
656 #define snd_seq_ev_is_reserved(ev) \
657 (! snd_seq_event_types[(ev)->type])
660 * macros to check event flags
663 #define snd_seq_ev_is_prior(ev) \
664 (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH)
666 /** get the data length type */
667 #define snd_seq_ev_length_type(ev) \
668 ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK)
669 /** fixed length events */
670 #define snd_seq_ev_is_fixed(ev) \
671 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED)
672 /** variable length events */
673 #define snd_seq_ev_is_variable(ev) \
674 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE)
675 /** variable length on user-space */
676 #define snd_seq_ev_is_varusr(ev) \
677 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR)
678 /** variable length on IPC shm */
679 #define snd_seq_ev_is_varipc(ev) \
680 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIPC)
682 /** time-stamp type */
683 #define snd_seq_ev_timestamp_type(ev) \
684 ((ev)->flags & SND_SEQ_TIME_STAMP_MASK)
685 /** event is in tick time */
686 #define snd_seq_ev_is_tick(ev) \
687 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK)
688 /** event is in real-time */
689 #define snd_seq_ev_is_real(ev) \
690 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL)
692 /** time-mode type */
693 #define snd_seq_ev_timemode_type(ev) \
694 ((ev)->flags & SND_SEQ_TIME_MODE_MASK)
695 /** scheduled in absolute time */
696 #define snd_seq_ev_is_abstime(ev) \
697 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS)
698 /** scheduled in relative time */
699 #define snd_seq_ev_is_reltime(ev) \
700 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL)
702 /** direct dispatched events */
703 #define snd_seq_ev_is_direct(ev) \
704 ((ev)->queue == SND_SEQ_QUEUE_DIRECT)
712 #endif /* __ALSA_SEQ_H */