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 const char *snd_seq_name(snd_seq_t *seq);
88 snd_seq_type_t snd_seq_type(snd_seq_t *seq);
89 int snd_seq_close(snd_seq_t *handle);
90 int snd_seq_poll_descriptors_count(snd_seq_t *handle, short events);
91 int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space, short events);
92 int snd_seq_nonblock(snd_seq_t *handle, int nonblock);
93 int snd_seq_client_id(snd_seq_t *handle);
95 size_t snd_seq_get_output_buffer_size(snd_seq_t *handle);
96 size_t snd_seq_get_input_buffer_size(snd_seq_t *handle);
97 int snd_seq_set_output_buffer_size(snd_seq_t *handle, size_t size);
98 int snd_seq_set_input_buffer_size(snd_seq_t *handle, size_t size);
100 /** system information container */
101 typedef struct _snd_seq_system_info snd_seq_system_info_t;
103 size_t snd_seq_system_info_sizeof(void);
104 /** allocate a #snd_seq_system_info_t container on stack */
105 #define snd_seq_system_info_alloca(ptr) \
106 SND_ALLOCA(snd_seq_system_info, ptr)
107 int snd_seq_system_info_malloc(snd_seq_system_info_t **ptr);
108 void snd_seq_system_info_free(snd_seq_system_info_t *ptr);
109 void snd_seq_system_info_copy(snd_seq_system_info_t *dst, const snd_seq_system_info_t *src);
111 int snd_seq_system_info_get_queues(const snd_seq_system_info_t *info);
112 int snd_seq_system_info_get_clients(const snd_seq_system_info_t *info);
113 int snd_seq_system_info_get_ports(const snd_seq_system_info_t *info);
114 int snd_seq_system_info_get_channels(const snd_seq_system_info_t *info);
115 int snd_seq_system_info_get_cur_clients(const snd_seq_system_info_t *info);
116 int snd_seq_system_info_get_cur_queues(const snd_seq_system_info_t *info);
118 int snd_seq_system_info(snd_seq_t *handle, snd_seq_system_info_t *info);
124 * \defgroup SeqClient Sequencer Client Interface
125 * Sequencer Client Interface
130 /** client information container */
131 typedef struct _snd_seq_client_info snd_seq_client_info_t;
134 typedef enum snd_seq_client_type {
135 SND_SEQ_USER_CLIENT = 1, /**< user client */
136 SND_SEQ_KERNEL_CLIENT = 2 /**< kernel client */
137 } snd_seq_client_type_t;
139 size_t snd_seq_client_info_sizeof(void);
140 /** allocate a #snd_seq_client_info_t container on stack */
141 #define snd_seq_client_info_alloca(ptr) \
142 SND_ALLOCA(snd_seq_client_info, ptr)
143 int snd_seq_client_info_malloc(snd_seq_client_info_t **ptr);
144 void snd_seq_client_info_free(snd_seq_client_info_t *ptr);
145 void snd_seq_client_info_copy(snd_seq_client_info_t *dst, const snd_seq_client_info_t *src);
147 int snd_seq_client_info_get_client(const snd_seq_client_info_t *info);
148 snd_seq_client_type_t snd_seq_client_info_get_type(const snd_seq_client_info_t *info);
149 const char *snd_seq_client_info_get_name(snd_seq_client_info_t *info);
150 int snd_seq_client_info_get_broadcast_filter(const snd_seq_client_info_t *info);
151 int snd_seq_client_info_get_error_bounce(const snd_seq_client_info_t *info);
152 const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_info_t *info);
153 int snd_seq_client_info_get_num_ports(const snd_seq_client_info_t *info);
154 int snd_seq_client_info_get_event_lost(const snd_seq_client_info_t *info);
156 void snd_seq_client_info_set_client(snd_seq_client_info_t *info, int client);
157 void snd_seq_client_info_set_name(snd_seq_client_info_t *info, const char *name);
158 void snd_seq_client_info_set_broadcast_filter(snd_seq_client_info_t *info, int val);
159 void snd_seq_client_info_set_error_bounce(snd_seq_client_info_t *info, int val);
160 void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned char *filter);
162 int snd_seq_get_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
163 int snd_seq_get_any_client_info(snd_seq_t *handle, int client, snd_seq_client_info_t *info);
164 int snd_seq_set_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
165 int snd_seq_query_next_client(snd_seq_t *handle, snd_seq_client_info_t *info);
170 /** client pool information container */
171 typedef struct _snd_seq_client_pool snd_seq_client_pool_t;
173 size_t snd_seq_client_pool_sizeof(void);
174 /** allocate a #snd_seq_client_pool_t container on stack */
175 #define snd_seq_client_pool_alloca(ptr) \
176 SND_ALLOCA(snd_seq_client_pool, ptr)
177 int snd_seq_client_pool_malloc(snd_seq_client_pool_t **ptr);
178 void snd_seq_client_pool_free(snd_seq_client_pool_t *ptr);
179 void snd_seq_client_pool_copy(snd_seq_client_pool_t *dst, const snd_seq_client_pool_t *src);
181 int snd_seq_client_pool_get_client(const snd_seq_client_pool_t *info);
182 size_t snd_seq_client_pool_get_output_pool(const snd_seq_client_pool_t *info);
183 size_t snd_seq_client_pool_get_input_pool(const snd_seq_client_pool_t *info);
184 size_t snd_seq_client_pool_get_output_room(const snd_seq_client_pool_t *info);
185 size_t snd_seq_client_pool_get_output_free(const snd_seq_client_pool_t *info);
186 size_t snd_seq_client_pool_get_input_free(const snd_seq_client_pool_t *info);
187 void snd_seq_client_pool_set_output_pool(snd_seq_client_pool_t *info, size_t size);
188 void snd_seq_client_pool_set_input_pool(snd_seq_client_pool_t *info, size_t size);
189 void snd_seq_client_pool_set_output_room(snd_seq_client_pool_t *info, size_t size);
191 int snd_seq_get_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
192 int snd_seq_set_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
199 * \defgroup SeqPort Sequencer Port Interface
200 * Sequencer Port Interface
205 /** port information container */
206 typedef struct _snd_seq_port_info snd_seq_port_info_t;
208 /** known port numbers */
209 #define SND_SEQ_PORT_SYSTEM_TIMER 0 /**< system timer port */
210 #define SND_SEQ_PORT_SYSTEM_ANNOUNCE 1 /**< sysem announce port */
212 /** port capabilities (32 bits) */
213 #define SND_SEQ_PORT_CAP_READ (1<<0) /**< readable from this port */
214 #define SND_SEQ_PORT_CAP_WRITE (1<<1) /**< writable to this port */
216 #define SND_SEQ_PORT_CAP_SYNC_READ (1<<2) /**< allow read subscriptions */
217 #define SND_SEQ_PORT_CAP_SYNC_WRITE (1<<3) /**< allow write subscriptions */
219 #define SND_SEQ_PORT_CAP_DUPLEX (1<<4) /**< allow read/write duplex */
221 #define SND_SEQ_PORT_CAP_SUBS_READ (1<<5) /**< allow read subscription */
222 #define SND_SEQ_PORT_CAP_SUBS_WRITE (1<<6) /**< allow write subscription */
223 #define SND_SEQ_PORT_CAP_NO_EXPORT (1<<7) /**< routing not allowed */
226 #define SND_SEQ_PORT_TYPE_SPECIFIC (1<<0) /**< hardware specific */
227 #define SND_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) /**< generic MIDI device */
228 #define SND_SEQ_PORT_TYPE_MIDI_GM (1<<2) /**< General MIDI compatible device */
229 #define SND_SEQ_PORT_TYPE_MIDI_GS (1<<3) /**< GS compatible device */
230 #define SND_SEQ_PORT_TYPE_MIDI_XG (1<<4) /**< XG compatible device */
231 #define SND_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) /**< MT-32 compatible device */
232 #define SND_SEQ_PORT_TYPE_SYNTH (1<<10) /**< Synth device */
233 #define SND_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11) /**< Sampling device (support sample download) */
234 #define SND_SEQ_PORT_TYPE_SAMPLE (1<<12) /**< Sampling device (sample can be downloaded at any time) */
235 #define SND_SEQ_PORT_TYPE_APPLICATION (1<<20) /**< application (sequencer/editor) */
238 size_t snd_seq_port_info_sizeof(void);
239 /** allocate a #snd_seq_port_info_t container on stack */
240 #define snd_seq_port_info_alloca(ptr) \
241 SND_ALLOCA(snd_seq_port_info, ptr)
242 int snd_seq_port_info_malloc(snd_seq_port_info_t **ptr);
243 void snd_seq_port_info_free(snd_seq_port_info_t *ptr);
244 void snd_seq_port_info_copy(snd_seq_port_info_t *dst, const snd_seq_port_info_t *src);
246 int snd_seq_port_info_get_client(const snd_seq_port_info_t *info);
247 int snd_seq_port_info_get_port(const snd_seq_port_info_t *info);
248 const snd_seq_addr_t *snd_seq_port_info_get_addr(const snd_seq_port_info_t *info);
249 const char *snd_seq_port_info_get_name(const snd_seq_port_info_t *info);
250 unsigned int snd_seq_port_info_get_capability(const snd_seq_port_info_t *info);
251 unsigned int snd_seq_port_info_get_type(const snd_seq_port_info_t *info);
252 int snd_seq_port_info_get_midi_channels(const snd_seq_port_info_t *info);
253 int snd_seq_port_info_get_midi_voices(const snd_seq_port_info_t *info);
254 int snd_seq_port_info_get_synth_voices(const snd_seq_port_info_t *info);
255 int snd_seq_port_info_get_read_use(const snd_seq_port_info_t *info);
256 int snd_seq_port_info_get_write_use(const snd_seq_port_info_t *info);
257 int snd_seq_port_info_get_port_specified(const snd_seq_port_info_t *info);
259 void snd_seq_port_info_set_client(snd_seq_port_info_t *info, int client);
260 void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port);
261 void snd_seq_port_info_set_addr(snd_seq_port_info_t *info, const snd_seq_addr_t *addr);
262 void snd_seq_port_info_set_name(snd_seq_port_info_t *info, const char *name);
263 void snd_seq_port_info_set_capability(snd_seq_port_info_t *info, unsigned int capability);
264 void snd_seq_port_info_set_type(snd_seq_port_info_t *info, unsigned int type);
265 void snd_seq_port_info_set_midi_channels(snd_seq_port_info_t *info, int channels);
266 void snd_seq_port_info_set_midi_voices(snd_seq_port_info_t *info, int voices);
267 void snd_seq_port_info_set_synth_voices(snd_seq_port_info_t *info, int voices);
268 void snd_seq_port_info_set_port_specified(snd_seq_port_info_t *info, int val);
270 int snd_seq_create_port(snd_seq_t *handle, snd_seq_port_info_t *info);
271 int snd_seq_delete_port(snd_seq_t *handle, int port);
272 int snd_seq_get_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
273 int snd_seq_get_any_port_info(snd_seq_t *handle, int client, int port, snd_seq_port_info_t *info);
274 int snd_seq_set_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
275 int snd_seq_query_next_port(snd_seq_t *handle, snd_seq_port_info_t *info);
281 * \defgroup SeqSubscribe Sequencer Port Subscription
282 * Sequencer Port Subscription
287 /** port subscription container */
288 typedef struct _snd_seq_port_subscribe snd_seq_port_subscribe_t;
290 size_t snd_seq_port_subscribe_sizeof(void);
291 /** allocate a #snd_seq_port_subscribe_t container on stack */
292 #define snd_seq_port_subscribe_alloca(ptr) \
293 SND_ALLOCA(snd_seq_port_subscribe, ptr)
294 int snd_seq_port_subscribe_malloc(snd_seq_port_subscribe_t **ptr);
295 void snd_seq_port_subscribe_free(snd_seq_port_subscribe_t *ptr);
296 void snd_seq_port_subscribe_copy(snd_seq_port_subscribe_t *dst, const snd_seq_port_subscribe_t *src);
298 const snd_seq_addr_t *snd_seq_port_subscribe_get_sender(const snd_seq_port_subscribe_t *info);
299 const snd_seq_addr_t *snd_seq_port_subscribe_get_dest(const snd_seq_port_subscribe_t *info);
300 int snd_seq_port_subscribe_get_queue(const snd_seq_port_subscribe_t *info);
301 int snd_seq_port_subscribe_get_exclusive(const snd_seq_port_subscribe_t *info);
302 int snd_seq_port_subscribe_get_time_update(const snd_seq_port_subscribe_t *info);
303 int snd_seq_port_subscribe_get_time_real(const snd_seq_port_subscribe_t *info);
305 void snd_seq_port_subscribe_set_sender(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
306 void snd_seq_port_subscribe_set_dest(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
307 void snd_seq_port_subscribe_set_queue(snd_seq_port_subscribe_t *info, int q);
308 void snd_seq_port_subscribe_set_exclusive(snd_seq_port_subscribe_t *info, int val);
309 void snd_seq_port_subscribe_set_time_update(snd_seq_port_subscribe_t *info, int val);
310 void snd_seq_port_subscribe_set_time_real(snd_seq_port_subscribe_t *info, int val);
312 int snd_seq_get_port_subscription(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
313 int snd_seq_subscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
314 int snd_seq_unsubscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
319 /** subscription query container */
320 typedef struct _snd_seq_query_subscribe snd_seq_query_subscribe_t;
322 /** type of query subscription */
324 SND_SEQ_QUERY_SUBS_READ, /**< query read subscriptions */
325 SND_SEQ_QUERY_SUBS_WRITE /**< query write subscriptions */
326 } snd_seq_query_subs_type_t;
328 size_t snd_seq_query_subscribe_sizeof(void);
329 /** allocate a #snd_seq_query_subscribe_t container on stack */
330 #define snd_seq_query_subscribe_alloca(ptr) \
331 SND_ALLOCA(snd_seq_query_subscribe, ptr)
332 int snd_seq_query_subscribe_malloc(snd_seq_query_subscribe_t **ptr);
333 void snd_seq_query_subscribe_free(snd_seq_query_subscribe_t *ptr);
334 void snd_seq_query_subscribe_copy(snd_seq_query_subscribe_t *dst, const snd_seq_query_subscribe_t *src);
336 int snd_seq_query_subscribe_get_client(const snd_seq_query_subscribe_t *info);
337 int snd_seq_query_subscribe_get_port(const snd_seq_query_subscribe_t *info);
338 const snd_seq_addr_t *snd_seq_query_subscribe_get_root(const snd_seq_query_subscribe_t *info);
339 snd_seq_query_subs_type_t snd_seq_query_subscribe_get_type(const snd_seq_query_subscribe_t *info);
340 int snd_seq_query_subscribe_get_index(const snd_seq_query_subscribe_t *info);
341 int snd_seq_query_subscribe_get_num_subs(const snd_seq_query_subscribe_t *info);
342 const snd_seq_addr_t *snd_seq_query_subscribe_get_addr(const snd_seq_query_subscribe_t *info);
343 int snd_seq_query_subscribe_get_queue(const snd_seq_query_subscribe_t *info);
344 int snd_seq_query_subscribe_get_exclusive(const snd_seq_query_subscribe_t *info);
345 int snd_seq_query_subscribe_get_time_update(const snd_seq_query_subscribe_t *info);
346 int snd_seq_query_subscribe_get_time_real(const snd_seq_query_subscribe_t *info);
348 void snd_seq_query_subscribe_set_client(snd_seq_query_subscribe_t *info, int client);
349 void snd_seq_query_subscribe_set_port(snd_seq_query_subscribe_t *info, int port);
350 void snd_seq_query_subscribe_set_root(snd_seq_query_subscribe_t *info, const snd_seq_addr_t *addr);
351 void snd_seq_query_subscribe_set_type(snd_seq_query_subscribe_t *info, snd_seq_query_subs_type_t type);
352 void snd_seq_query_subscribe_set_index(snd_seq_query_subscribe_t *info, int index);
354 int snd_seq_query_port_subscribers(snd_seq_t *seq, snd_seq_query_subscribe_t * subs);
360 * \defgroup SeqQueue Sequencer Queue Interface
361 * Sequencer Queue Interface
366 /** queue information container */
367 typedef struct _snd_seq_queue_info snd_seq_queue_info_t;
368 /** queue status container */
369 typedef struct _snd_seq_queue_status snd_seq_queue_status_t;
370 /** queue tempo container */
371 typedef struct _snd_seq_queue_tempo snd_seq_queue_tempo_t;
372 /** queue timer information container */
373 typedef struct _snd_seq_queue_timer snd_seq_queue_timer_t;
375 /** special queue ids */
376 #define SND_SEQ_QUEUE_DIRECT 253 /**< direct dispatch */
378 size_t snd_seq_queue_info_sizeof(void);
379 /** allocate a #snd_seq_queue_info_t container on stack */
380 #define snd_seq_queue_info_alloca(ptr) \
381 SND_ALLOCA(snd_seq_queue_info, ptr)
382 int snd_seq_queue_info_malloc(snd_seq_queue_info_t **ptr);
383 void snd_seq_queue_info_free(snd_seq_queue_info_t *ptr);
384 void snd_seq_queue_info_copy(snd_seq_queue_info_t *dst, const snd_seq_queue_info_t *src);
386 int snd_seq_queue_info_get_queue(const snd_seq_queue_info_t *info);
387 const char *snd_seq_queue_info_get_name(const snd_seq_queue_info_t *info);
388 int snd_seq_queue_info_get_owner(const snd_seq_queue_info_t *info);
389 int snd_seq_queue_info_get_locked(const snd_seq_queue_info_t *info);
390 unsigned int snd_seq_queue_info_get_flags(const snd_seq_queue_info_t *info);
392 void snd_seq_queue_info_set_name(snd_seq_queue_info_t *info, const char *name);
393 void snd_seq_queue_info_set_owner(snd_seq_queue_info_t *info, int owner);
394 void snd_seq_queue_info_set_locked(snd_seq_queue_info_t *info, int locked);
395 void snd_seq_queue_info_set_flags(snd_seq_queue_info_t *info, unsigned int flags);
397 int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info);
398 int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name);
399 int snd_seq_alloc_queue(snd_seq_t *handle);
400 int snd_seq_free_queue(snd_seq_t *handle, int q);
401 int snd_seq_get_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
402 int snd_seq_set_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
403 int snd_seq_query_named_queue(snd_seq_t *seq, const char *name);
405 int snd_seq_get_queue_usage(snd_seq_t *handle, int q);
406 int snd_seq_set_queue_usage(snd_seq_t *handle, int q, int used);
410 size_t snd_seq_queue_status_sizeof(void);
411 /** allocate a #snd_seq_queue_status_t container on stack */
412 #define snd_seq_queue_status_alloca(ptr) \
413 SND_ALLOCA(snd_seq_queue_status, ptr)
414 int snd_seq_queue_status_malloc(snd_seq_queue_status_t **ptr);
415 void snd_seq_queue_status_free(snd_seq_queue_status_t *ptr);
416 void snd_seq_queue_status_copy(snd_seq_queue_status_t *dst, const snd_seq_queue_status_t *src);
418 int snd_seq_queue_status_get_queue(const snd_seq_queue_status_t *info);
419 int snd_seq_queue_status_get_events(const snd_seq_queue_status_t *info);
420 snd_seq_tick_time_t snd_seq_queue_status_get_tick_time(const snd_seq_queue_status_t *info);
421 const snd_seq_real_time_t *snd_seq_queue_status_get_real_time(const snd_seq_queue_status_t *info);
422 unsigned int snd_seq_queue_status_get_status(const snd_seq_queue_status_t *info);
424 int snd_seq_get_queue_status(snd_seq_t *handle, int q, snd_seq_queue_status_t *status);
428 size_t snd_seq_queue_tempo_sizeof(void);
429 /** allocate a #snd_seq_queue_tempo_t container on stack */
430 #define snd_seq_queue_tempo_alloca(ptr) \
431 SND_ALLOCA(snd_seq_queue_tempo, ptr)
432 int snd_seq_queue_tempo_malloc(snd_seq_queue_tempo_t **ptr);
433 void snd_seq_queue_tempo_free(snd_seq_queue_tempo_t *ptr);
434 void snd_seq_queue_tempo_copy(snd_seq_queue_tempo_t *dst, const snd_seq_queue_tempo_t *src);
436 int snd_seq_queue_tempo_get_queue(const snd_seq_queue_tempo_t *info);
437 unsigned int snd_seq_queue_tempo_get_tempo(const snd_seq_queue_tempo_t *info);
438 int snd_seq_queue_tempo_get_ppq(const snd_seq_queue_tempo_t *info);
439 void snd_seq_queue_tempo_set_tempo(snd_seq_queue_tempo_t *info, unsigned int tempo);
440 void snd_seq_queue_tempo_set_ppq(snd_seq_queue_tempo_t *info, int ppq);
442 int snd_seq_get_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
443 int snd_seq_set_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
448 /** sequencer timer sources */
450 SND_SEQ_TIMER_ALSA = 0, /* ALSA timer */
451 SND_SEQ_TIMER_MIDI_CLOCK = 1, /* Midi Clock (CLOCK event) */
452 SND_SEQ_TIMER_MIDI_TICK = 2, /* Midi Timer Tick (TICK event */
453 } snd_seq_queue_timer_type_t;
455 size_t snd_seq_queue_timer_sizeof(void);
456 /** allocate a #snd_seq_queue_timer_t container on stack */
457 #define snd_seq_queue_timer_alloca(ptr) \
458 SND_ALLOCA(snd_seq_queue_timer, ptr)
459 int snd_seq_queue_timer_malloc(snd_seq_queue_timer_t **ptr);
460 void snd_seq_queue_timer_free(snd_seq_queue_timer_t *ptr);
461 void snd_seq_queue_timer_copy(snd_seq_queue_timer_t *dst, const snd_seq_queue_timer_t *src);
463 int snd_seq_queue_timer_get_queue(const snd_seq_queue_timer_t *info);
464 snd_seq_queue_timer_type_t snd_seq_queue_timer_get_type(const snd_seq_queue_timer_t *info);
465 const snd_timer_id_t *snd_seq_queue_timer_get_id(const snd_seq_queue_timer_t *info);
466 unsigned int snd_seq_queue_timer_get_resolution(const snd_seq_queue_timer_t *info);
468 void snd_seq_queue_timer_set_type(snd_seq_queue_timer_t *info, snd_seq_queue_timer_type_t type);
469 void snd_seq_queue_timer_set_id(snd_seq_queue_timer_t *info, const snd_timer_id_t *id);
470 void snd_seq_queue_timer_set_resolution(snd_seq_queue_timer_t *info, unsigned int resolution);
472 int snd_seq_get_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
473 int snd_seq_set_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
478 * \defgroup SeqEvent Sequencer Event API
479 * Sequencer Event API
484 snd_seq_event_t *snd_seq_create_event(void);
485 int snd_seq_free_event(snd_seq_event_t *ev);
486 ssize_t snd_seq_event_length(snd_seq_event_t *ev);
487 int snd_seq_event_output(snd_seq_t *handle, snd_seq_event_t *ev);
488 int snd_seq_event_output_buffer(snd_seq_t *handle, snd_seq_event_t *ev);
489 int snd_seq_event_output_direct(snd_seq_t *handle, snd_seq_event_t *ev);
490 int snd_seq_event_input(snd_seq_t *handle, snd_seq_event_t **ev);
491 int snd_seq_event_input_pending(snd_seq_t *seq, int fetch_sequencer);
492 int snd_seq_drain_output(snd_seq_t *handle);
493 int snd_seq_event_output_pending(snd_seq_t *seq);
494 int snd_seq_extract_output(snd_seq_t *handle, snd_seq_event_t **ev);
495 int snd_seq_drop_output(snd_seq_t *handle);
496 int snd_seq_drop_output_buffer(snd_seq_t *handle);
497 int snd_seq_drop_input(snd_seq_t *handle);
498 int snd_seq_drop_input_buffer(snd_seq_t *handle);
500 /** event removal conditionals */
501 typedef struct _snd_seq_remove_events snd_seq_remove_events_t;
503 /** Remove conditional flags */
504 #define SND_SEQ_REMOVE_INPUT (1<<0) /**< Flush input queues */
505 #define SND_SEQ_REMOVE_OUTPUT (1<<1) /**< Flush output queues */
506 #define SND_SEQ_REMOVE_DEST (1<<2) /**< Restrict by destination q:client:port */
507 #define SND_SEQ_REMOVE_DEST_CHANNEL (1<<3) /**< Restrict by channel */
508 #define SND_SEQ_REMOVE_TIME_BEFORE (1<<4) /**< Restrict to before time */
509 #define SND_SEQ_REMOVE_TIME_AFTER (1<<5) /**< Restrict to time or after */
510 #define SND_SEQ_REMOVE_TIME_TICK (1<<6) /**< Time is in ticks */
511 #define SND_SEQ_REMOVE_EVENT_TYPE (1<<7) /**< Restrict to event type */
512 #define SND_SEQ_REMOVE_IGNORE_OFF (1<<8) /**< Do not flush off events */
513 #define SND_SEQ_REMOVE_TAG_MATCH (1<<9) /**< Restrict to events with given tag */
515 size_t snd_seq_remove_events_sizeof(void);
516 /** allocate a #snd_seq_remove_events_t container on stack */
517 #define snd_seq_remove_events_alloca(ptr) \
518 SND_ALLOCA(snd_seq_remove_events, ptr)
519 int snd_seq_remove_events_malloc(snd_seq_remove_events_t **ptr);
520 void snd_seq_remove_events_free(snd_seq_remove_events_t *ptr);
521 void snd_seq_remove_events_copy(snd_seq_remove_events_t *dst, const snd_seq_remove_events_t *src);
523 unsigned int snd_seq_remove_events_get_condition(const snd_seq_remove_events_t *info);
524 int snd_seq_remove_events_get_queue(const snd_seq_remove_events_t *info);
525 const snd_seq_timestamp_t *snd_seq_remove_events_get_time(const snd_seq_remove_events_t *info);
526 const snd_seq_addr_t *snd_seq_remove_events_get_dest(const snd_seq_remove_events_t *info);
527 int snd_seq_remove_events_get_channel(const snd_seq_remove_events_t *info);
528 int snd_seq_remove_events_get_event_type(const snd_seq_remove_events_t *info);
529 int snd_seq_remove_events_get_tag(const snd_seq_remove_events_t *info);
531 void snd_seq_remove_events_set_condition(snd_seq_remove_events_t *info, unsigned int flags);
532 void snd_seq_remove_events_set_queue(snd_seq_remove_events_t *info, int queue);
533 void snd_seq_remove_events_set_time(snd_seq_remove_events_t *info, const snd_seq_timestamp_t *time);
534 void snd_seq_remove_events_set_dest(snd_seq_remove_events_t *info, const snd_seq_addr_t *addr);
535 void snd_seq_remove_events_set_channel(snd_seq_remove_events_t *info, int channel);
536 void snd_seq_remove_events_set_event_type(snd_seq_remove_events_t *info, int type);
537 void snd_seq_remove_events_set_tag(snd_seq_remove_events_t *info, int tag);
539 int snd_seq_remove_events(snd_seq_t *handle, snd_seq_remove_events_t *info);
544 * \defgroup SeqMisc Sequencer Miscellaneous
545 * Sequencer Mescellaneous
550 void snd_seq_set_bit(int nr, void *array);
551 int snd_seq_change_bit(int nr, void *array);
552 int snd_seq_get_bit(int nr, void *array);
558 * \defgroup SeqEvType Sequencer Event Type Checks
559 * Sequencer Event Type Checks
564 /* event type macros */
566 SND_SEQ_EVFLG_RESULT,
568 SND_SEQ_EVFLG_CONTROL,
570 SND_SEQ_EVFLG_SYSTEM,
571 SND_SEQ_EVFLG_MESSAGE,
572 SND_SEQ_EVFLG_CONNECTION,
573 SND_SEQ_EVFLG_SAMPLE,
580 SND_SEQ_EVFLG_VARIABLE,
581 SND_SEQ_EVFLG_VARUSR,
586 SND_SEQ_EVFLG_NOTE_ONEARG,
587 SND_SEQ_EVFLG_NOTE_TWOARG
591 SND_SEQ_EVFLG_QUEUE_NOARG,
592 SND_SEQ_EVFLG_QUEUE_TICK,
593 SND_SEQ_EVFLG_QUEUE_TIME,
594 SND_SEQ_EVFLG_QUEUE_VALUE
598 * Exported event type table
600 * This table is referred by snd_seq_ev_is_xxx.
602 extern const unsigned int snd_seq_event_types[];
604 #define _SND_SEQ_TYPE(x) (1<<(x)) /**< master type - 24bit */
605 #define _SND_SEQ_TYPE_OPT(x) ((x)<<24) /**< optional type - 8bit */
607 /** check the event type */
608 #define snd_seq_type_check(ev,x) (snd_seq_event_types[(ev)->type] & _SND_SEQ_TYPE(x))
610 /** event type check: result events */
611 #define snd_seq_ev_is_result_type(ev) \
612 snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT)
613 /** event type check: note events */
614 #define snd_seq_ev_is_note_type(ev) \
615 snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE)
616 /** event type check: control events */
617 #define snd_seq_ev_is_control_type(ev) \
618 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL)
619 /** event type check: channel specific events */
620 #define snd_seq_ev_is_channel_type(ev) \
621 (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL)))
623 /** event type check: queue control events */
624 #define snd_seq_ev_is_queue_type(ev) \
625 snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE)
626 /** event type check: system status messages */
627 #define snd_seq_ev_is_message_type(ev) \
628 snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE)
629 /** event type check: system status messages */
630 #define snd_seq_ev_is_subscribe_type(ev) \
631 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION)
632 /** event type check: sample messages */
633 #define snd_seq_ev_is_sample_type(ev) \
634 snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE)
635 /** event type check: user-defined messages */
636 #define snd_seq_ev_is_user_type(ev) \
637 snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS)
638 /** event type check: instrument layer events */
639 #define snd_seq_ev_is_instr_type(ev) \
640 snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR)
641 /** event type check: fixed length events */
642 #define snd_seq_ev_is_fixed_type(ev) \
643 snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED)
644 /** event type check: variable length events */
645 #define snd_seq_ev_is_variable_type(ev) \
646 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE)
647 /** event type check: user pointer events */
648 #define snd_seq_ev_is_varusr_type(ev) \
649 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR)
650 /** event type check: ipc events */
651 #define snd_seq_ev_is_varipc_type(ev) \
652 snd_seq_type_check(ev, SND_SEQ_EVFLG_IPC)
653 /** event type check: reserved for kernel */
654 #define snd_seq_ev_is_reserved(ev) \
655 (! snd_seq_event_types[(ev)->type])
658 * macros to check event flags
661 #define snd_seq_ev_is_prior(ev) \
662 (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH)
664 /** get the data length type */
665 #define snd_seq_ev_length_type(ev) \
666 ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK)
667 /** fixed length events */
668 #define snd_seq_ev_is_fixed(ev) \
669 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED)
670 /** variable length events */
671 #define snd_seq_ev_is_variable(ev) \
672 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE)
673 /** variable length on user-space */
674 #define snd_seq_ev_is_varusr(ev) \
675 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR)
676 /** variable length on IPC shm */
677 #define snd_seq_ev_is_varipc(ev) \
678 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIPC)
680 /** time-stamp type */
681 #define snd_seq_ev_timestamp_type(ev) \
682 ((ev)->flags & SND_SEQ_TIME_STAMP_MASK)
683 /** event is in tick time */
684 #define snd_seq_ev_is_tick(ev) \
685 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK)
686 /** event is in real-time */
687 #define snd_seq_ev_is_real(ev) \
688 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL)
690 /** time-mode type */
691 #define snd_seq_ev_timemode_type(ev) \
692 ((ev)->flags & SND_SEQ_TIME_MODE_MASK)
693 /** scheduled in absolute time */
694 #define snd_seq_ev_is_abstime(ev) \
695 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS)
696 /** scheduled in relative time */
697 #define snd_seq_ev_is_reltime(ev) \
698 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL)
700 /** direct dispatched events */
701 #define snd_seq_ev_is_direct(ev) \
702 ((ev)->queue == SND_SEQ_QUEUE_DIRECT)
710 #endif /* __ALSA_SEQ_H */