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>
10 * Application interface library for the ALSA driver
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.
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.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 * \defgroup Sequencer MIDI Sequencer
38 * MIDI Sequencer Interface.
39 * See \ref seq page for more details.
43 /** dlsym version for interface entry callback */
44 #define SND_SEQ_DLSYM_VERSION _dlsym_seq_001
46 /** Sequencer handle */
47 typedef struct _snd_seq snd_seq_t;
49 /** Allocate and initialize array on stack \internal */
50 #define SND_ALLOCA(type,ptr) \
53 *ptr = (type##_t *)alloca(type##_sizeof());\
54 memset(*ptr, 0, type##_sizeof());\
58 * sequencer opening stream types
60 #define SND_SEQ_OPEN_OUTPUT 1 /**< open for output (write) */
61 #define SND_SEQ_OPEN_INPUT 2 /**< open for input (read) */
62 #define SND_SEQ_OPEN_DUPLEX (SND_SEQ_OPEN_OUTPUT|SND_SEQ_OPEN_INPUT) /**< open for both input and output (read/write) */
65 * sequencer opening mode
67 #define SND_SEQ_NONBLOCK 0x0001 /**< non-blocking mode (flag to open mode) */
69 /** sequencer handle type */
70 typedef enum _snd_seq_type {
71 SND_SEQ_TYPE_HW, /**< hardware */
72 SND_SEQ_TYPE_SHM, /**< shared memory (NYI) */
73 SND_SEQ_TYPE_INET /**< network (NYI) */
76 /** special client (port) ids */
77 #define SND_SEQ_ADDRESS_UNKNOWN 253 /**< unknown source */
78 #define SND_SEQ_ADDRESS_SUBSCRIBERS 254 /**< send event to all subscribed ports */
79 #define SND_SEQ_ADDRESS_BROADCAST 255 /**< send event to all queues/clients/ports/channels */
81 /** known client numbers */
82 #define SND_SEQ_CLIENT_SYSTEM 0 /**< system client */
83 #define SND_SEQ_CLIENT_DUMMY 62 /**< dummy ports */
84 #define SND_SEQ_CLIENT_OSS 63 /**< OSS sequencer emulator */
88 int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode);
89 int snd_seq_open_lconf(snd_seq_t **handle, const char *name, int streams, int mode, snd_config_t *lconf);
90 const char *snd_seq_name(snd_seq_t *seq);
91 snd_seq_type_t snd_seq_type(snd_seq_t *seq);
92 int snd_seq_close(snd_seq_t *handle);
93 int snd_seq_poll_descriptors_count(snd_seq_t *handle, short events);
94 int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space, short events);
95 int snd_seq_poll_descriptors_revents(snd_seq_t *seq, struct pollfd *pfds, unsigned int nfds, unsigned short *revents);
96 int snd_seq_nonblock(snd_seq_t *handle, int nonblock);
97 int snd_seq_client_id(snd_seq_t *handle);
99 size_t snd_seq_get_output_buffer_size(snd_seq_t *handle);
100 size_t snd_seq_get_input_buffer_size(snd_seq_t *handle);
101 int snd_seq_set_output_buffer_size(snd_seq_t *handle, size_t size);
102 int snd_seq_set_input_buffer_size(snd_seq_t *handle, size_t size);
104 /** system information container */
105 typedef struct _snd_seq_system_info snd_seq_system_info_t;
107 size_t snd_seq_system_info_sizeof(void);
108 /** allocate a #snd_seq_system_info_t container on stack */
109 #define snd_seq_system_info_alloca(ptr) \
110 SND_ALLOCA(snd_seq_system_info, ptr)
111 int snd_seq_system_info_malloc(snd_seq_system_info_t **ptr);
112 void snd_seq_system_info_free(snd_seq_system_info_t *ptr);
113 void snd_seq_system_info_copy(snd_seq_system_info_t *dst, const snd_seq_system_info_t *src);
115 int snd_seq_system_info_get_queues(const snd_seq_system_info_t *info);
116 int snd_seq_system_info_get_clients(const snd_seq_system_info_t *info);
117 int snd_seq_system_info_get_ports(const snd_seq_system_info_t *info);
118 int snd_seq_system_info_get_channels(const snd_seq_system_info_t *info);
119 int snd_seq_system_info_get_cur_clients(const snd_seq_system_info_t *info);
120 int snd_seq_system_info_get_cur_queues(const snd_seq_system_info_t *info);
122 int snd_seq_system_info(snd_seq_t *handle, snd_seq_system_info_t *info);
128 * \defgroup SeqClient Sequencer Client Interface
129 * Sequencer Client Interface
134 /** client information container */
135 typedef struct _snd_seq_client_info snd_seq_client_info_t;
138 typedef enum snd_seq_client_type {
139 SND_SEQ_USER_CLIENT = 1, /**< user client */
140 SND_SEQ_KERNEL_CLIENT = 2 /**< kernel client */
141 } snd_seq_client_type_t;
143 size_t snd_seq_client_info_sizeof(void);
144 /** allocate a #snd_seq_client_info_t container on stack */
145 #define snd_seq_client_info_alloca(ptr) \
146 SND_ALLOCA(snd_seq_client_info, ptr)
147 int snd_seq_client_info_malloc(snd_seq_client_info_t **ptr);
148 void snd_seq_client_info_free(snd_seq_client_info_t *ptr);
149 void snd_seq_client_info_copy(snd_seq_client_info_t *dst, const snd_seq_client_info_t *src);
151 int snd_seq_client_info_get_client(const snd_seq_client_info_t *info);
152 snd_seq_client_type_t snd_seq_client_info_get_type(const snd_seq_client_info_t *info);
153 const char *snd_seq_client_info_get_name(snd_seq_client_info_t *info);
154 int snd_seq_client_info_get_broadcast_filter(const snd_seq_client_info_t *info);
155 int snd_seq_client_info_get_error_bounce(const snd_seq_client_info_t *info);
156 const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_info_t *info);
157 int snd_seq_client_info_get_num_ports(const snd_seq_client_info_t *info);
158 int snd_seq_client_info_get_event_lost(const snd_seq_client_info_t *info);
160 void snd_seq_client_info_set_client(snd_seq_client_info_t *info, int client);
161 void snd_seq_client_info_set_name(snd_seq_client_info_t *info, const char *name);
162 void snd_seq_client_info_set_broadcast_filter(snd_seq_client_info_t *info, int val);
163 void snd_seq_client_info_set_error_bounce(snd_seq_client_info_t *info, int val);
164 void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned char *filter);
166 int snd_seq_get_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
167 int snd_seq_get_any_client_info(snd_seq_t *handle, int client, snd_seq_client_info_t *info);
168 int snd_seq_set_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
169 int snd_seq_query_next_client(snd_seq_t *handle, snd_seq_client_info_t *info);
174 /** client pool information container */
175 typedef struct _snd_seq_client_pool snd_seq_client_pool_t;
177 size_t snd_seq_client_pool_sizeof(void);
178 /** allocate a #snd_seq_client_pool_t container on stack */
179 #define snd_seq_client_pool_alloca(ptr) \
180 SND_ALLOCA(snd_seq_client_pool, ptr)
181 int snd_seq_client_pool_malloc(snd_seq_client_pool_t **ptr);
182 void snd_seq_client_pool_free(snd_seq_client_pool_t *ptr);
183 void snd_seq_client_pool_copy(snd_seq_client_pool_t *dst, const snd_seq_client_pool_t *src);
185 int snd_seq_client_pool_get_client(const snd_seq_client_pool_t *info);
186 size_t snd_seq_client_pool_get_output_pool(const snd_seq_client_pool_t *info);
187 size_t snd_seq_client_pool_get_input_pool(const snd_seq_client_pool_t *info);
188 size_t snd_seq_client_pool_get_output_room(const snd_seq_client_pool_t *info);
189 size_t snd_seq_client_pool_get_output_free(const snd_seq_client_pool_t *info);
190 size_t snd_seq_client_pool_get_input_free(const snd_seq_client_pool_t *info);
191 void snd_seq_client_pool_set_output_pool(snd_seq_client_pool_t *info, size_t size);
192 void snd_seq_client_pool_set_input_pool(snd_seq_client_pool_t *info, size_t size);
193 void snd_seq_client_pool_set_output_room(snd_seq_client_pool_t *info, size_t size);
195 int snd_seq_get_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
196 int snd_seq_set_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
203 * \defgroup SeqPort Sequencer Port Interface
204 * Sequencer Port Interface
209 /** port information container */
210 typedef struct _snd_seq_port_info snd_seq_port_info_t;
212 /** known port numbers */
213 #define SND_SEQ_PORT_SYSTEM_TIMER 0 /**< system timer port */
214 #define SND_SEQ_PORT_SYSTEM_ANNOUNCE 1 /**< system announce port */
216 /** port capabilities (32 bits) */
217 #define SND_SEQ_PORT_CAP_READ (1<<0) /**< readable from this port */
218 #define SND_SEQ_PORT_CAP_WRITE (1<<1) /**< writable to this port */
220 #define SND_SEQ_PORT_CAP_SYNC_READ (1<<2) /**< allow read subscriptions */
221 #define SND_SEQ_PORT_CAP_SYNC_WRITE (1<<3) /**< allow write subscriptions */
223 #define SND_SEQ_PORT_CAP_DUPLEX (1<<4) /**< allow read/write duplex */
225 #define SND_SEQ_PORT_CAP_SUBS_READ (1<<5) /**< allow read subscription */
226 #define SND_SEQ_PORT_CAP_SUBS_WRITE (1<<6) /**< allow write subscription */
227 #define SND_SEQ_PORT_CAP_NO_EXPORT (1<<7) /**< routing not allowed */
230 #define SND_SEQ_PORT_TYPE_SPECIFIC (1<<0) /**< hardware specific */
231 #define SND_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) /**< generic MIDI device */
232 #define SND_SEQ_PORT_TYPE_MIDI_GM (1<<2) /**< General MIDI compatible device */
233 #define SND_SEQ_PORT_TYPE_MIDI_GS (1<<3) /**< GS compatible device */
234 #define SND_SEQ_PORT_TYPE_MIDI_XG (1<<4) /**< XG compatible device */
235 #define SND_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) /**< MT-32 compatible device */
236 #define SND_SEQ_PORT_TYPE_SYNTH (1<<10) /**< Synth device */
237 #define SND_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11) /**< Sampling device (support sample download) */
238 #define SND_SEQ_PORT_TYPE_SAMPLE (1<<12) /**< Sampling device (sample can be downloaded at any time) */
239 #define SND_SEQ_PORT_TYPE_APPLICATION (1<<20) /**< application (sequencer/editor) */
242 size_t snd_seq_port_info_sizeof(void);
243 /** allocate a #snd_seq_port_info_t container on stack */
244 #define snd_seq_port_info_alloca(ptr) \
245 SND_ALLOCA(snd_seq_port_info, ptr)
246 int snd_seq_port_info_malloc(snd_seq_port_info_t **ptr);
247 void snd_seq_port_info_free(snd_seq_port_info_t *ptr);
248 void snd_seq_port_info_copy(snd_seq_port_info_t *dst, const snd_seq_port_info_t *src);
250 int snd_seq_port_info_get_client(const snd_seq_port_info_t *info);
251 int snd_seq_port_info_get_port(const snd_seq_port_info_t *info);
252 const snd_seq_addr_t *snd_seq_port_info_get_addr(const snd_seq_port_info_t *info);
253 const char *snd_seq_port_info_get_name(const snd_seq_port_info_t *info);
254 unsigned int snd_seq_port_info_get_capability(const snd_seq_port_info_t *info);
255 unsigned int snd_seq_port_info_get_type(const snd_seq_port_info_t *info);
256 int snd_seq_port_info_get_midi_channels(const snd_seq_port_info_t *info);
257 int snd_seq_port_info_get_midi_voices(const snd_seq_port_info_t *info);
258 int snd_seq_port_info_get_synth_voices(const snd_seq_port_info_t *info);
259 int snd_seq_port_info_get_read_use(const snd_seq_port_info_t *info);
260 int snd_seq_port_info_get_write_use(const snd_seq_port_info_t *info);
261 int snd_seq_port_info_get_port_specified(const snd_seq_port_info_t *info);
263 void snd_seq_port_info_set_client(snd_seq_port_info_t *info, int client);
264 void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port);
265 void snd_seq_port_info_set_addr(snd_seq_port_info_t *info, const snd_seq_addr_t *addr);
266 void snd_seq_port_info_set_name(snd_seq_port_info_t *info, const char *name);
267 void snd_seq_port_info_set_capability(snd_seq_port_info_t *info, unsigned int capability);
268 void snd_seq_port_info_set_type(snd_seq_port_info_t *info, unsigned int type);
269 void snd_seq_port_info_set_midi_channels(snd_seq_port_info_t *info, int channels);
270 void snd_seq_port_info_set_midi_voices(snd_seq_port_info_t *info, int voices);
271 void snd_seq_port_info_set_synth_voices(snd_seq_port_info_t *info, int voices);
272 void snd_seq_port_info_set_port_specified(snd_seq_port_info_t *info, int val);
274 int snd_seq_create_port(snd_seq_t *handle, snd_seq_port_info_t *info);
275 int snd_seq_delete_port(snd_seq_t *handle, int port);
276 int snd_seq_get_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
277 int snd_seq_get_any_port_info(snd_seq_t *handle, int client, int port, snd_seq_port_info_t *info);
278 int snd_seq_set_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
279 int snd_seq_query_next_port(snd_seq_t *handle, snd_seq_port_info_t *info);
285 * \defgroup SeqSubscribe Sequencer Port Subscription
286 * Sequencer Port Subscription
291 /** port subscription container */
292 typedef struct _snd_seq_port_subscribe snd_seq_port_subscribe_t;
294 size_t snd_seq_port_subscribe_sizeof(void);
295 /** allocate a #snd_seq_port_subscribe_t container on stack */
296 #define snd_seq_port_subscribe_alloca(ptr) \
297 SND_ALLOCA(snd_seq_port_subscribe, ptr)
298 int snd_seq_port_subscribe_malloc(snd_seq_port_subscribe_t **ptr);
299 void snd_seq_port_subscribe_free(snd_seq_port_subscribe_t *ptr);
300 void snd_seq_port_subscribe_copy(snd_seq_port_subscribe_t *dst, const snd_seq_port_subscribe_t *src);
302 const snd_seq_addr_t *snd_seq_port_subscribe_get_sender(const snd_seq_port_subscribe_t *info);
303 const snd_seq_addr_t *snd_seq_port_subscribe_get_dest(const snd_seq_port_subscribe_t *info);
304 int snd_seq_port_subscribe_get_queue(const snd_seq_port_subscribe_t *info);
305 int snd_seq_port_subscribe_get_exclusive(const snd_seq_port_subscribe_t *info);
306 int snd_seq_port_subscribe_get_time_update(const snd_seq_port_subscribe_t *info);
307 int snd_seq_port_subscribe_get_time_real(const snd_seq_port_subscribe_t *info);
309 void snd_seq_port_subscribe_set_sender(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
310 void snd_seq_port_subscribe_set_dest(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
311 void snd_seq_port_subscribe_set_queue(snd_seq_port_subscribe_t *info, int q);
312 void snd_seq_port_subscribe_set_exclusive(snd_seq_port_subscribe_t *info, int val);
313 void snd_seq_port_subscribe_set_time_update(snd_seq_port_subscribe_t *info, int val);
314 void snd_seq_port_subscribe_set_time_real(snd_seq_port_subscribe_t *info, int val);
316 int snd_seq_get_port_subscription(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
317 int snd_seq_subscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
318 int snd_seq_unsubscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
323 /** subscription query container */
324 typedef struct _snd_seq_query_subscribe snd_seq_query_subscribe_t;
326 /** type of query subscription */
328 SND_SEQ_QUERY_SUBS_READ, /**< query read subscriptions */
329 SND_SEQ_QUERY_SUBS_WRITE /**< query write subscriptions */
330 } snd_seq_query_subs_type_t;
332 size_t snd_seq_query_subscribe_sizeof(void);
333 /** allocate a #snd_seq_query_subscribe_t container on stack */
334 #define snd_seq_query_subscribe_alloca(ptr) \
335 SND_ALLOCA(snd_seq_query_subscribe, ptr)
336 int snd_seq_query_subscribe_malloc(snd_seq_query_subscribe_t **ptr);
337 void snd_seq_query_subscribe_free(snd_seq_query_subscribe_t *ptr);
338 void snd_seq_query_subscribe_copy(snd_seq_query_subscribe_t *dst, const snd_seq_query_subscribe_t *src);
340 int snd_seq_query_subscribe_get_client(const snd_seq_query_subscribe_t *info);
341 int snd_seq_query_subscribe_get_port(const snd_seq_query_subscribe_t *info);
342 const snd_seq_addr_t *snd_seq_query_subscribe_get_root(const snd_seq_query_subscribe_t *info);
343 snd_seq_query_subs_type_t snd_seq_query_subscribe_get_type(const snd_seq_query_subscribe_t *info);
344 int snd_seq_query_subscribe_get_index(const snd_seq_query_subscribe_t *info);
345 int snd_seq_query_subscribe_get_num_subs(const snd_seq_query_subscribe_t *info);
346 const snd_seq_addr_t *snd_seq_query_subscribe_get_addr(const snd_seq_query_subscribe_t *info);
347 int snd_seq_query_subscribe_get_queue(const snd_seq_query_subscribe_t *info);
348 int snd_seq_query_subscribe_get_exclusive(const snd_seq_query_subscribe_t *info);
349 int snd_seq_query_subscribe_get_time_update(const snd_seq_query_subscribe_t *info);
350 int snd_seq_query_subscribe_get_time_real(const snd_seq_query_subscribe_t *info);
352 void snd_seq_query_subscribe_set_client(snd_seq_query_subscribe_t *info, int client);
353 void snd_seq_query_subscribe_set_port(snd_seq_query_subscribe_t *info, int port);
354 void snd_seq_query_subscribe_set_root(snd_seq_query_subscribe_t *info, const snd_seq_addr_t *addr);
355 void snd_seq_query_subscribe_set_type(snd_seq_query_subscribe_t *info, snd_seq_query_subs_type_t type);
356 void snd_seq_query_subscribe_set_index(snd_seq_query_subscribe_t *info, int index);
358 int snd_seq_query_port_subscribers(snd_seq_t *seq, snd_seq_query_subscribe_t * subs);
364 * \defgroup SeqQueue Sequencer Queue Interface
365 * Sequencer Queue Interface
370 /** queue information container */
371 typedef struct _snd_seq_queue_info snd_seq_queue_info_t;
372 /** queue status container */
373 typedef struct _snd_seq_queue_status snd_seq_queue_status_t;
374 /** queue tempo container */
375 typedef struct _snd_seq_queue_tempo snd_seq_queue_tempo_t;
376 /** queue timer information container */
377 typedef struct _snd_seq_queue_timer snd_seq_queue_timer_t;
379 /** special queue ids */
380 #define SND_SEQ_QUEUE_DIRECT 253 /**< direct dispatch */
382 size_t snd_seq_queue_info_sizeof(void);
383 /** allocate a #snd_seq_queue_info_t container on stack */
384 #define snd_seq_queue_info_alloca(ptr) \
385 SND_ALLOCA(snd_seq_queue_info, ptr)
386 int snd_seq_queue_info_malloc(snd_seq_queue_info_t **ptr);
387 void snd_seq_queue_info_free(snd_seq_queue_info_t *ptr);
388 void snd_seq_queue_info_copy(snd_seq_queue_info_t *dst, const snd_seq_queue_info_t *src);
390 int snd_seq_queue_info_get_queue(const snd_seq_queue_info_t *info);
391 const char *snd_seq_queue_info_get_name(const snd_seq_queue_info_t *info);
392 int snd_seq_queue_info_get_owner(const snd_seq_queue_info_t *info);
393 int snd_seq_queue_info_get_locked(const snd_seq_queue_info_t *info);
394 unsigned int snd_seq_queue_info_get_flags(const snd_seq_queue_info_t *info);
396 void snd_seq_queue_info_set_name(snd_seq_queue_info_t *info, const char *name);
397 void snd_seq_queue_info_set_owner(snd_seq_queue_info_t *info, int owner);
398 void snd_seq_queue_info_set_locked(snd_seq_queue_info_t *info, int locked);
399 void snd_seq_queue_info_set_flags(snd_seq_queue_info_t *info, unsigned int flags);
401 int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info);
402 int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name);
403 int snd_seq_alloc_queue(snd_seq_t *handle);
404 int snd_seq_free_queue(snd_seq_t *handle, int q);
405 int snd_seq_get_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
406 int snd_seq_set_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
407 int snd_seq_query_named_queue(snd_seq_t *seq, const char *name);
409 int snd_seq_get_queue_usage(snd_seq_t *handle, int q);
410 int snd_seq_set_queue_usage(snd_seq_t *handle, int q, int used);
414 size_t snd_seq_queue_status_sizeof(void);
415 /** allocate a #snd_seq_queue_status_t container on stack */
416 #define snd_seq_queue_status_alloca(ptr) \
417 SND_ALLOCA(snd_seq_queue_status, ptr)
418 int snd_seq_queue_status_malloc(snd_seq_queue_status_t **ptr);
419 void snd_seq_queue_status_free(snd_seq_queue_status_t *ptr);
420 void snd_seq_queue_status_copy(snd_seq_queue_status_t *dst, const snd_seq_queue_status_t *src);
422 int snd_seq_queue_status_get_queue(const snd_seq_queue_status_t *info);
423 int snd_seq_queue_status_get_events(const snd_seq_queue_status_t *info);
424 snd_seq_tick_time_t snd_seq_queue_status_get_tick_time(const snd_seq_queue_status_t *info);
425 const snd_seq_real_time_t *snd_seq_queue_status_get_real_time(const snd_seq_queue_status_t *info);
426 unsigned int snd_seq_queue_status_get_status(const snd_seq_queue_status_t *info);
428 int snd_seq_get_queue_status(snd_seq_t *handle, int q, snd_seq_queue_status_t *status);
432 size_t snd_seq_queue_tempo_sizeof(void);
433 /** allocate a #snd_seq_queue_tempo_t container on stack */
434 #define snd_seq_queue_tempo_alloca(ptr) \
435 SND_ALLOCA(snd_seq_queue_tempo, ptr)
436 int snd_seq_queue_tempo_malloc(snd_seq_queue_tempo_t **ptr);
437 void snd_seq_queue_tempo_free(snd_seq_queue_tempo_t *ptr);
438 void snd_seq_queue_tempo_copy(snd_seq_queue_tempo_t *dst, const snd_seq_queue_tempo_t *src);
440 int snd_seq_queue_tempo_get_queue(const snd_seq_queue_tempo_t *info);
441 unsigned int snd_seq_queue_tempo_get_tempo(const snd_seq_queue_tempo_t *info);
442 int snd_seq_queue_tempo_get_ppq(const snd_seq_queue_tempo_t *info);
443 unsigned int snd_seq_queue_tempo_get_skew(const snd_seq_queue_tempo_t *info);
444 unsigned int snd_seq_queue_tempo_get_skew_base(const snd_seq_queue_tempo_t *info);
445 void snd_seq_queue_tempo_set_tempo(snd_seq_queue_tempo_t *info, unsigned int tempo);
446 void snd_seq_queue_tempo_set_ppq(snd_seq_queue_tempo_t *info, int ppq);
447 void snd_seq_queue_tempo_set_skew(snd_seq_queue_tempo_t *info, unsigned int skew);
448 void snd_seq_queue_tempo_set_skew_base(snd_seq_queue_tempo_t *info, unsigned int base);
450 int snd_seq_get_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
451 int snd_seq_set_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
456 /** sequencer timer sources */
458 SND_SEQ_TIMER_ALSA = 0, /* ALSA timer */
459 SND_SEQ_TIMER_MIDI_CLOCK = 1, /* Midi Clock (CLOCK event) */
460 SND_SEQ_TIMER_MIDI_TICK = 2 /* Midi Timer Tick (TICK event */
461 } snd_seq_queue_timer_type_t;
463 size_t snd_seq_queue_timer_sizeof(void);
464 /** allocate a #snd_seq_queue_timer_t container on stack */
465 #define snd_seq_queue_timer_alloca(ptr) \
466 SND_ALLOCA(snd_seq_queue_timer, ptr)
467 int snd_seq_queue_timer_malloc(snd_seq_queue_timer_t **ptr);
468 void snd_seq_queue_timer_free(snd_seq_queue_timer_t *ptr);
469 void snd_seq_queue_timer_copy(snd_seq_queue_timer_t *dst, const snd_seq_queue_timer_t *src);
471 int snd_seq_queue_timer_get_queue(const snd_seq_queue_timer_t *info);
472 snd_seq_queue_timer_type_t snd_seq_queue_timer_get_type(const snd_seq_queue_timer_t *info);
473 const snd_timer_id_t *snd_seq_queue_timer_get_id(const snd_seq_queue_timer_t *info);
474 unsigned int snd_seq_queue_timer_get_resolution(const snd_seq_queue_timer_t *info);
476 void snd_seq_queue_timer_set_type(snd_seq_queue_timer_t *info, snd_seq_queue_timer_type_t type);
477 void snd_seq_queue_timer_set_id(snd_seq_queue_timer_t *info, const snd_timer_id_t *id);
478 void snd_seq_queue_timer_set_resolution(snd_seq_queue_timer_t *info, unsigned int resolution);
480 int snd_seq_get_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
481 int snd_seq_set_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
486 * \defgroup SeqEvent Sequencer Event API
487 * Sequencer Event API
492 snd_seq_event_t *snd_seq_create_event(void);
493 int snd_seq_free_event(snd_seq_event_t *ev);
494 ssize_t snd_seq_event_length(snd_seq_event_t *ev);
495 int snd_seq_event_output(snd_seq_t *handle, snd_seq_event_t *ev);
496 int snd_seq_event_output_buffer(snd_seq_t *handle, snd_seq_event_t *ev);
497 int snd_seq_event_output_direct(snd_seq_t *handle, snd_seq_event_t *ev);
498 int snd_seq_event_input(snd_seq_t *handle, snd_seq_event_t **ev);
499 int snd_seq_event_input_pending(snd_seq_t *seq, int fetch_sequencer);
500 int snd_seq_drain_output(snd_seq_t *handle);
501 int snd_seq_event_output_pending(snd_seq_t *seq);
502 int snd_seq_extract_output(snd_seq_t *handle, snd_seq_event_t **ev);
503 int snd_seq_drop_output(snd_seq_t *handle);
504 int snd_seq_drop_output_buffer(snd_seq_t *handle);
505 int snd_seq_drop_input(snd_seq_t *handle);
506 int snd_seq_drop_input_buffer(snd_seq_t *handle);
508 /** event removal conditionals */
509 typedef struct _snd_seq_remove_events snd_seq_remove_events_t;
511 /** Remove conditional flags */
512 #define SND_SEQ_REMOVE_INPUT (1<<0) /**< Flush input queues */
513 #define SND_SEQ_REMOVE_OUTPUT (1<<1) /**< Flush output queues */
514 #define SND_SEQ_REMOVE_DEST (1<<2) /**< Restrict by destination q:client:port */
515 #define SND_SEQ_REMOVE_DEST_CHANNEL (1<<3) /**< Restrict by channel */
516 #define SND_SEQ_REMOVE_TIME_BEFORE (1<<4) /**< Restrict to before time */
517 #define SND_SEQ_REMOVE_TIME_AFTER (1<<5) /**< Restrict to time or after */
518 #define SND_SEQ_REMOVE_TIME_TICK (1<<6) /**< Time is in ticks */
519 #define SND_SEQ_REMOVE_EVENT_TYPE (1<<7) /**< Restrict to event type */
520 #define SND_SEQ_REMOVE_IGNORE_OFF (1<<8) /**< Do not flush off events */
521 #define SND_SEQ_REMOVE_TAG_MATCH (1<<9) /**< Restrict to events with given tag */
523 size_t snd_seq_remove_events_sizeof(void);
524 /** allocate a #snd_seq_remove_events_t container on stack */
525 #define snd_seq_remove_events_alloca(ptr) \
526 SND_ALLOCA(snd_seq_remove_events, ptr)
527 int snd_seq_remove_events_malloc(snd_seq_remove_events_t **ptr);
528 void snd_seq_remove_events_free(snd_seq_remove_events_t *ptr);
529 void snd_seq_remove_events_copy(snd_seq_remove_events_t *dst, const snd_seq_remove_events_t *src);
531 unsigned int snd_seq_remove_events_get_condition(const snd_seq_remove_events_t *info);
532 int snd_seq_remove_events_get_queue(const snd_seq_remove_events_t *info);
533 const snd_seq_timestamp_t *snd_seq_remove_events_get_time(const snd_seq_remove_events_t *info);
534 const snd_seq_addr_t *snd_seq_remove_events_get_dest(const snd_seq_remove_events_t *info);
535 int snd_seq_remove_events_get_channel(const snd_seq_remove_events_t *info);
536 int snd_seq_remove_events_get_event_type(const snd_seq_remove_events_t *info);
537 int snd_seq_remove_events_get_tag(const snd_seq_remove_events_t *info);
539 void snd_seq_remove_events_set_condition(snd_seq_remove_events_t *info, unsigned int flags);
540 void snd_seq_remove_events_set_queue(snd_seq_remove_events_t *info, int queue);
541 void snd_seq_remove_events_set_time(snd_seq_remove_events_t *info, const snd_seq_timestamp_t *time);
542 void snd_seq_remove_events_set_dest(snd_seq_remove_events_t *info, const snd_seq_addr_t *addr);
543 void snd_seq_remove_events_set_channel(snd_seq_remove_events_t *info, int channel);
544 void snd_seq_remove_events_set_event_type(snd_seq_remove_events_t *info, int type);
545 void snd_seq_remove_events_set_tag(snd_seq_remove_events_t *info, int tag);
547 int snd_seq_remove_events(snd_seq_t *handle, snd_seq_remove_events_t *info);
552 * \defgroup SeqMisc Sequencer Miscellaneous
553 * Sequencer Miscellaneous
558 void snd_seq_set_bit(int nr, void *array);
559 int snd_seq_change_bit(int nr, void *array);
560 int snd_seq_get_bit(int nr, void *array);
566 * \defgroup SeqEvType Sequencer Event Type Checks
567 * Sequencer Event Type Checks
572 /* event type macros */
574 SND_SEQ_EVFLG_RESULT,
576 SND_SEQ_EVFLG_CONTROL,
578 SND_SEQ_EVFLG_SYSTEM,
579 SND_SEQ_EVFLG_MESSAGE,
580 SND_SEQ_EVFLG_CONNECTION,
581 SND_SEQ_EVFLG_SAMPLE,
588 SND_SEQ_EVFLG_VARIABLE,
589 SND_SEQ_EVFLG_VARUSR,
594 SND_SEQ_EVFLG_NOTE_ONEARG,
595 SND_SEQ_EVFLG_NOTE_TWOARG
599 SND_SEQ_EVFLG_QUEUE_NOARG,
600 SND_SEQ_EVFLG_QUEUE_TICK,
601 SND_SEQ_EVFLG_QUEUE_TIME,
602 SND_SEQ_EVFLG_QUEUE_VALUE
606 * Exported event type table
608 * This table is referred by snd_seq_ev_is_xxx.
610 extern const unsigned int snd_seq_event_types[];
612 #define _SND_SEQ_TYPE(x) (1<<(x)) /**< master type - 24bit */
613 #define _SND_SEQ_TYPE_OPT(x) ((x)<<24) /**< optional type - 8bit */
615 /** check the event type */
616 #define snd_seq_type_check(ev,x) (snd_seq_event_types[(ev)->type] & _SND_SEQ_TYPE(x))
618 /** event type check: result events */
619 #define snd_seq_ev_is_result_type(ev) \
620 snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT)
621 /** event type check: note events */
622 #define snd_seq_ev_is_note_type(ev) \
623 snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE)
624 /** event type check: control events */
625 #define snd_seq_ev_is_control_type(ev) \
626 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL)
627 /** event type check: channel specific events */
628 #define snd_seq_ev_is_channel_type(ev) \
629 (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL)))
631 /** event type check: queue control events */
632 #define snd_seq_ev_is_queue_type(ev) \
633 snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE)
634 /** event type check: system status messages */
635 #define snd_seq_ev_is_message_type(ev) \
636 snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE)
637 /** event type check: system status messages */
638 #define snd_seq_ev_is_subscribe_type(ev) \
639 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION)
640 /** event type check: sample messages */
641 #define snd_seq_ev_is_sample_type(ev) \
642 snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE)
643 /** event type check: user-defined messages */
644 #define snd_seq_ev_is_user_type(ev) \
645 snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS)
646 /** event type check: instrument layer events */
647 #define snd_seq_ev_is_instr_type(ev) \
648 snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR)
649 /** event type check: fixed length events */
650 #define snd_seq_ev_is_fixed_type(ev) \
651 snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED)
652 /** event type check: variable length events */
653 #define snd_seq_ev_is_variable_type(ev) \
654 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE)
655 /** event type check: user pointer events */
656 #define snd_seq_ev_is_varusr_type(ev) \
657 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR)
658 /** event type check: ipc events */
659 #define snd_seq_ev_is_varipc_type(ev) \
660 snd_seq_type_check(ev, SND_SEQ_EVFLG_IPC)
661 /** event type check: reserved for kernel */
662 #define snd_seq_ev_is_reserved(ev) \
663 (! snd_seq_event_types[(ev)->type])
666 * macros to check event flags
669 #define snd_seq_ev_is_prior(ev) \
670 (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH)
672 /** get the data length type */
673 #define snd_seq_ev_length_type(ev) \
674 ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK)
675 /** fixed length events */
676 #define snd_seq_ev_is_fixed(ev) \
677 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED)
678 /** variable length events */
679 #define snd_seq_ev_is_variable(ev) \
680 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE)
681 /** variable length on user-space */
682 #define snd_seq_ev_is_varusr(ev) \
683 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR)
684 /** variable length on IPC shm */
685 #define snd_seq_ev_is_varipc(ev) \
686 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIPC)
688 /** time-stamp type */
689 #define snd_seq_ev_timestamp_type(ev) \
690 ((ev)->flags & SND_SEQ_TIME_STAMP_MASK)
691 /** event is in tick time */
692 #define snd_seq_ev_is_tick(ev) \
693 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK)
694 /** event is in real-time */
695 #define snd_seq_ev_is_real(ev) \
696 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL)
698 /** time-mode type */
699 #define snd_seq_ev_timemode_type(ev) \
700 ((ev)->flags & SND_SEQ_TIME_MODE_MASK)
701 /** scheduled in absolute time */
702 #define snd_seq_ev_is_abstime(ev) \
703 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS)
704 /** scheduled in relative time */
705 #define snd_seq_ev_is_reltime(ev) \
706 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL)
708 /** direct dispatched events */
709 #define snd_seq_ev_is_direct(ev) \
710 ((ev)->queue == SND_SEQ_QUEUE_DIRECT)
718 #endif /* __ALSA_SEQ_H */