comparison plugin/api/alsa/seq_event.h @ 0:fc9323a41f5a

start base : Sonic Visualiser sv1-1.0rc1
author lbajardsilogic
date Fri, 11 May 2007 09:08:14 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:fc9323a41f5a
1 /* DSSI ALSA compatibility library
2 *
3 * This library provides for Mac OS X the ALSA snd_seq_event_t handling
4 * necessary to compile and run DSSI. It was extracted from alsa-lib 1.0.8.
5 */
6
7 /**
8 * \file <alsa/seq_event.h>
9 * \brief Application interface library for the ALSA driver
10 * \author Jaroslav Kysela <perex@suse.cz>
11 * \author Abramo Bagnara <abramo@alsa-project.org>
12 * \author Takashi Iwai <tiwai@suse.de>
13 * \date 1998-2001
14 *
15 * Application interface library for the ALSA driver
16 *
17 *
18 * This library is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU Lesser General Public License as
20 * published by the Free Software Foundation; either version 2.1 of
21 * the License, or (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Lesser General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public
29 * License along with this library; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 *
32 */
33
34 #ifndef __ALSA_SEQ_EVENT_H
35 #define __ALSA_SEQ_EVENT_H
36
37 /* If we're not using GNU C, elide __attribute__ */
38 #ifndef __GNUC__
39 # define __attribute__(x) /*NOTHING*/
40 #endif
41
42 /**
43 * \defgroup SeqEvents Sequencer Event Definitions
44 * Sequencer Event Definitions
45 * \ingroup Sequencer
46 * \{
47 */
48
49 /**
50 * Sequencer event data type
51 */
52 typedef unsigned char snd_seq_event_type_t;
53
54 /** Sequencer event type */
55 enum snd_seq_event_type {
56 /** system status; event data type = #snd_seq_result_t */
57 SND_SEQ_EVENT_SYSTEM = 0,
58 /** returned result status; event data type = #snd_seq_result_t */
59 SND_SEQ_EVENT_RESULT,
60
61 /** note on and off with duration; event data type = #snd_seq_ev_note_t */
62 SND_SEQ_EVENT_NOTE = 5,
63 /** note on; event data type = #snd_seq_ev_note_t */
64 SND_SEQ_EVENT_NOTEON,
65 /** note off; event data type = #snd_seq_ev_note_t */
66 SND_SEQ_EVENT_NOTEOFF,
67 /** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */
68 SND_SEQ_EVENT_KEYPRESS,
69
70 /** controller; event data type = #snd_seq_ev_ctrl_t */
71 SND_SEQ_EVENT_CONTROLLER = 10,
72 /** program change; event data type = #snd_seq_ev_ctrl_t */
73 SND_SEQ_EVENT_PGMCHANGE,
74 /** channel pressure; event data type = #snd_seq_ev_ctrl_t */
75 SND_SEQ_EVENT_CHANPRESS,
76 /** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */
77 SND_SEQ_EVENT_PITCHBEND,
78 /** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */
79 SND_SEQ_EVENT_CONTROL14,
80 /** 14 bit NRPN; event data type = #snd_seq_ev_ctrl_t */
81 SND_SEQ_EVENT_NONREGPARAM,
82 /** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */
83 SND_SEQ_EVENT_REGPARAM,
84
85 /** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */
86 SND_SEQ_EVENT_SONGPOS = 20,
87 /** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */
88 SND_SEQ_EVENT_SONGSEL,
89 /** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */
90 SND_SEQ_EVENT_QFRAME,
91 /** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */
92 SND_SEQ_EVENT_TIMESIGN,
93 /** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */
94 SND_SEQ_EVENT_KEYSIGN,
95
96 /** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */
97 SND_SEQ_EVENT_START = 30,
98 /** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */
99 SND_SEQ_EVENT_CONTINUE,
100 /** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */
101 SND_SEQ_EVENT_STOP,
102 /** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */
103 SND_SEQ_EVENT_SETPOS_TICK,
104 /** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */
105 SND_SEQ_EVENT_SETPOS_TIME,
106 /** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */
107 SND_SEQ_EVENT_TEMPO,
108 /** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */
109 SND_SEQ_EVENT_CLOCK,
110 /** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */
111 SND_SEQ_EVENT_TICK,
112 /** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */
113 SND_SEQ_EVENT_QUEUE_SKEW,
114 /** Sync position changed; event data type = #snd_seq_ev_queue_control_t */
115 SND_SEQ_EVENT_SYNC_POS,
116
117 /** Tune request; event data type = none */
118 SND_SEQ_EVENT_TUNE_REQUEST = 40,
119 /** Reset to power-on state; event data type = none */
120 SND_SEQ_EVENT_RESET,
121 /** Active sensing event; event data type = none */
122 SND_SEQ_EVENT_SENSING,
123
124 /** Echo-back event; event data type = any type */
125 SND_SEQ_EVENT_ECHO = 50,
126 /** OSS emulation raw event; event data type = any type */
127 SND_SEQ_EVENT_OSS,
128
129 /** New client has connected; event data type = #snd_seq_addr_t */
130 SND_SEQ_EVENT_CLIENT_START = 60,
131 /** Client has left the system; event data type = #snd_seq_addr_t */
132 SND_SEQ_EVENT_CLIENT_EXIT,
133 /** Client status/info has changed; event data type = #snd_seq_addr_t */
134 SND_SEQ_EVENT_CLIENT_CHANGE,
135 /** New port was created; event data type = #snd_seq_addr_t */
136 SND_SEQ_EVENT_PORT_START,
137 /** Port was deleted from system; event data type = #snd_seq_addr_t */
138 SND_SEQ_EVENT_PORT_EXIT,
139 /** Port status/info has changed; event data type = #snd_seq_addr_t */
140 SND_SEQ_EVENT_PORT_CHANGE,
141
142 /** Ports connected; event data type = #snd_seq_connect_t */
143 SND_SEQ_EVENT_PORT_SUBSCRIBED,
144 /** Ports disconnected; event data type = #snd_seq_connect_t */
145 SND_SEQ_EVENT_PORT_UNSUBSCRIBED,
146
147 /** Sample select; event data type = #snd_seq_ev_sample_control_t */
148 SND_SEQ_EVENT_SAMPLE = 70,
149 /** Sample cluster select; event data type = #snd_seq_ev_sample_control_t */
150 SND_SEQ_EVENT_SAMPLE_CLUSTER,
151 /** voice start */
152 SND_SEQ_EVENT_SAMPLE_START,
153 /** voice stop */
154 SND_SEQ_EVENT_SAMPLE_STOP,
155 /** playback frequency */
156 SND_SEQ_EVENT_SAMPLE_FREQ,
157 /** volume and balance */
158 SND_SEQ_EVENT_SAMPLE_VOLUME,
159 /** sample loop */
160 SND_SEQ_EVENT_SAMPLE_LOOP,
161 /** sample position */
162 SND_SEQ_EVENT_SAMPLE_POSITION,
163 /** private (hardware dependent) event */
164 SND_SEQ_EVENT_SAMPLE_PRIVATE1,
165
166 /** user-defined event; event data type = any (fixed size) */
167 SND_SEQ_EVENT_USR0 = 90,
168 /** user-defined event; event data type = any (fixed size) */
169 SND_SEQ_EVENT_USR1,
170 /** user-defined event; event data type = any (fixed size) */
171 SND_SEQ_EVENT_USR2,
172 /** user-defined event; event data type = any (fixed size) */
173 SND_SEQ_EVENT_USR3,
174 /** user-defined event; event data type = any (fixed size) */
175 SND_SEQ_EVENT_USR4,
176 /** user-defined event; event data type = any (fixed size) */
177 SND_SEQ_EVENT_USR5,
178 /** user-defined event; event data type = any (fixed size) */
179 SND_SEQ_EVENT_USR6,
180 /** user-defined event; event data type = any (fixed size) */
181 SND_SEQ_EVENT_USR7,
182 /** user-defined event; event data type = any (fixed size) */
183 SND_SEQ_EVENT_USR8,
184 /** user-defined event; event data type = any (fixed size) */
185 SND_SEQ_EVENT_USR9,
186
187 /** begin of instrument management */
188 SND_SEQ_EVENT_INSTR_BEGIN = 100,
189 /** end of instrument management */
190 SND_SEQ_EVENT_INSTR_END,
191 /** query instrument interface info */
192 SND_SEQ_EVENT_INSTR_INFO,
193 /** result of instrument interface info */
194 SND_SEQ_EVENT_INSTR_INFO_RESULT,
195 /** query instrument format info */
196 SND_SEQ_EVENT_INSTR_FINFO,
197 /** result of instrument format info */
198 SND_SEQ_EVENT_INSTR_FINFO_RESULT,
199 /** reset instrument instrument memory */
200 SND_SEQ_EVENT_INSTR_RESET,
201 /** get instrument interface status */
202 SND_SEQ_EVENT_INSTR_STATUS,
203 /** result of instrument interface status */
204 SND_SEQ_EVENT_INSTR_STATUS_RESULT,
205 /** put an instrument to port */
206 SND_SEQ_EVENT_INSTR_PUT,
207 /** get an instrument from port */
208 SND_SEQ_EVENT_INSTR_GET,
209 /** result of instrument query */
210 SND_SEQ_EVENT_INSTR_GET_RESULT,
211 /** free instrument(s) */
212 SND_SEQ_EVENT_INSTR_FREE,
213 /** get instrument list */
214 SND_SEQ_EVENT_INSTR_LIST,
215 /** result of instrument list */
216 SND_SEQ_EVENT_INSTR_LIST_RESULT,
217 /** set cluster parameters */
218 SND_SEQ_EVENT_INSTR_CLUSTER,
219 /** get cluster parameters */
220 SND_SEQ_EVENT_INSTR_CLUSTER_GET,
221 /** result of cluster parameters */
222 SND_SEQ_EVENT_INSTR_CLUSTER_RESULT,
223 /** instrument change */
224 SND_SEQ_EVENT_INSTR_CHANGE,
225
226 /** system exclusive data (variable length); event data type = #snd_seq_ev_ext_t */
227 SND_SEQ_EVENT_SYSEX = 130,
228 /** error event; event data type = #snd_seq_ev_ext_t */
229 SND_SEQ_EVENT_BOUNCE,
230 /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
231 SND_SEQ_EVENT_USR_VAR0 = 135,
232 /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
233 SND_SEQ_EVENT_USR_VAR1,
234 /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
235 SND_SEQ_EVENT_USR_VAR2,
236 /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
237 SND_SEQ_EVENT_USR_VAR3,
238 /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
239 SND_SEQ_EVENT_USR_VAR4,
240
241 /** NOP; ignored in any case */
242 SND_SEQ_EVENT_NONE = 255
243 };
244
245
246 /** Sequencer event address */
247 typedef struct snd_seq_addr {
248 unsigned char client; /**< Client id */
249 unsigned char port; /**< Port id */
250 } snd_seq_addr_t;
251
252 /** Connection (subscription) between ports */
253 typedef struct snd_seq_connect {
254 snd_seq_addr_t sender; /**< sender address */
255 snd_seq_addr_t dest; /**< destination address */
256 } snd_seq_connect_t;
257
258
259 /** Real-time data record */
260 typedef struct snd_seq_real_time {
261 unsigned int tv_sec; /**< seconds */
262 unsigned int tv_nsec; /**< nanoseconds */
263 } snd_seq_real_time_t;
264
265 /** (MIDI) Tick-time data record */
266 typedef unsigned int snd_seq_tick_time_t;
267
268 /** unioned time stamp */
269 typedef union snd_seq_timestamp {
270 snd_seq_tick_time_t tick; /**< tick-time */
271 struct snd_seq_real_time time; /**< real-time */
272 } snd_seq_timestamp_t;
273
274
275 /**
276 * Event mode flags
277 *
278 * NOTE: only 8 bits available!
279 */
280 #define SND_SEQ_TIME_STAMP_TICK (0<<0) /**< timestamp in clock ticks */
281 #define SND_SEQ_TIME_STAMP_REAL (1<<0) /**< timestamp in real time */
282 #define SND_SEQ_TIME_STAMP_MASK (1<<0) /**< mask for timestamp bits */
283
284 #define SND_SEQ_TIME_MODE_ABS (0<<1) /**< absolute timestamp */
285 #define SND_SEQ_TIME_MODE_REL (1<<1) /**< relative to current time */
286 #define SND_SEQ_TIME_MODE_MASK (1<<1) /**< mask for time mode bits */
287
288 #define SND_SEQ_EVENT_LENGTH_FIXED (0<<2) /**< fixed event size */
289 #define SND_SEQ_EVENT_LENGTH_VARIABLE (1<<2) /**< variable event size */
290 #define SND_SEQ_EVENT_LENGTH_VARUSR (2<<2) /**< variable event size - user memory space */
291 #define SND_SEQ_EVENT_LENGTH_MASK (3<<2) /**< mask for event length bits */
292
293 #define SND_SEQ_PRIORITY_NORMAL (0<<4) /**< normal priority */
294 #define SND_SEQ_PRIORITY_HIGH (1<<4) /**< event should be processed before others */
295 #define SND_SEQ_PRIORITY_MASK (1<<4) /**< mask for priority bits */
296
297
298 /** Note event */
299 typedef struct snd_seq_ev_note {
300 unsigned char channel; /**< channel number */
301 unsigned char note; /**< note */
302 unsigned char velocity; /**< velocity */
303 unsigned char off_velocity; /**< note-off velocity; only for #SND_SEQ_EVENT_NOTE */
304 unsigned int duration; /**< duration until note-off; only for #SND_SEQ_EVENT_NOTE */
305 } snd_seq_ev_note_t;
306
307 /** Controller event */
308 typedef struct snd_seq_ev_ctrl {
309 unsigned char channel; /**< channel number */
310 unsigned char unused[3]; /**< reserved */
311 unsigned int param; /**< control parameter */
312 signed int value; /**< control value */
313 } snd_seq_ev_ctrl_t;
314
315 /** generic set of bytes (12x8 bit) */
316 typedef struct snd_seq_ev_raw8 {
317 unsigned char d[12]; /**< 8 bit value */
318 } snd_seq_ev_raw8_t;
319
320 /** generic set of integers (3x32 bit) */
321 typedef struct snd_seq_ev_raw32 {
322 unsigned int d[3]; /**< 32 bit value */
323 } snd_seq_ev_raw32_t;
324
325 /** external stored data */
326 typedef struct snd_seq_ev_ext {
327 unsigned int len; /**< length of data */
328 void *ptr; /**< pointer to data (note: can be 64-bit) */
329 } __attribute__((packed)) snd_seq_ev_ext_t;
330
331 /** Instrument cluster type */
332 typedef unsigned int snd_seq_instr_cluster_t;
333
334 /** Instrument type */
335 typedef struct snd_seq_instr {
336 snd_seq_instr_cluster_t cluster; /**< cluster id */
337 unsigned int std; /**< instrument standard id; the upper byte means a private instrument (owner - client id) */
338 unsigned short bank; /**< instrument bank id */
339 unsigned short prg; /**< instrument program id */
340 } snd_seq_instr_t;
341
342 /** sample number */
343 typedef struct snd_seq_ev_sample {
344 unsigned int std; /**< sample standard id */
345 unsigned short bank; /**< sample bank id */
346 unsigned short prg; /**< sample program id */
347 } snd_seq_ev_sample_t;
348
349 /** sample cluster */
350 typedef struct snd_seq_ev_cluster {
351 snd_seq_instr_cluster_t cluster; /**< cluster id */
352 } snd_seq_ev_cluster_t;
353
354 /** sample position */
355 typedef unsigned int snd_seq_position_t; /**< playback position (in samples) * 16 */
356
357 /** sample stop mode */
358 typedef enum snd_seq_stop_mode {
359 SND_SEQ_SAMPLE_STOP_IMMEDIATELY = 0, /**< terminate playing immediately */
360 SND_SEQ_SAMPLE_STOP_VENVELOPE = 1, /**< finish volume envelope */
361 SND_SEQ_SAMPLE_STOP_LOOP = 2 /**< terminate loop and finish wave */
362 } snd_seq_stop_mode_t;
363
364 /** sample frequency */
365 typedef int snd_seq_frequency_t; /**< playback frequency in HZ * 16 */
366
367 /** sample volume control; if any value is set to -1 == do not change */
368 typedef struct snd_seq_ev_volume {
369 signed short volume; /**< range: 0-16383 */
370 signed short lr; /**< left-right balance; range: 0-16383 */
371 signed short fr; /**< front-rear balance; range: 0-16383 */
372 signed short du; /**< down-up balance; range: 0-16383 */
373 } snd_seq_ev_volume_t;
374
375 /** simple loop redefinition */
376 typedef struct snd_seq_ev_loop {
377 unsigned int start; /**< loop start (in samples) * 16 */
378 unsigned int end; /**< loop end (in samples) * 16 */
379 } snd_seq_ev_loop_t;
380
381 /** Sample control events */
382 typedef struct snd_seq_ev_sample_control {
383 unsigned char channel; /**< channel */
384 unsigned char unused[3]; /**< reserved */
385 union {
386 snd_seq_ev_sample_t sample; /**< sample number */
387 snd_seq_ev_cluster_t cluster; /**< cluster number */
388 snd_seq_position_t position; /**< position */
389 snd_seq_stop_mode_t stop_mode; /**< stop mode */
390 snd_seq_frequency_t frequency; /**< frequency */
391 snd_seq_ev_volume_t volume; /**< volume */
392 snd_seq_ev_loop_t loop; /**< loop control */
393 unsigned char raw8[8]; /**< raw 8-bit */
394 } param; /**< control parameters */
395 } snd_seq_ev_sample_control_t;
396
397
398
399 /** INSTR_BEGIN event */
400 typedef struct snd_seq_ev_instr_begin {
401 int timeout; /**< zero = forever, otherwise timeout in ms */
402 } snd_seq_ev_instr_begin_t;
403
404 /** Result events */
405 typedef struct snd_seq_result {
406 int event; /**< processed event type */
407 int result; /**< status */
408 } snd_seq_result_t;
409
410 /** Queue skew values */
411 typedef struct snd_seq_queue_skew {
412 unsigned int value; /**< skew value */
413 unsigned int base; /**< skew base */
414 } snd_seq_queue_skew_t;
415
416 /** queue timer control */
417 typedef struct snd_seq_ev_queue_control {
418 unsigned char queue; /**< affected queue */
419 unsigned char unused[3]; /**< reserved */
420 union {
421 signed int value; /**< affected value (e.g. tempo) */
422 snd_seq_timestamp_t time; /**< time */
423 unsigned int position; /**< sync position */
424 snd_seq_queue_skew_t skew; /**< queue skew */
425 unsigned int d32[2]; /**< any data */
426 unsigned char d8[8]; /**< any data */
427 } param; /**< data value union */
428 } snd_seq_ev_queue_control_t;
429
430
431 /** Sequencer event */
432 typedef struct snd_seq_event {
433 snd_seq_event_type_t type; /**< event type */
434 unsigned char flags; /**< event flags */
435 unsigned char tag; /**< tag */
436
437 unsigned char queue; /**< schedule queue */
438 snd_seq_timestamp_t time; /**< schedule time */
439
440 snd_seq_addr_t source; /**< source address */
441 snd_seq_addr_t dest; /**< destination address */
442
443 union {
444 snd_seq_ev_note_t note; /**< note information */
445 snd_seq_ev_ctrl_t control; /**< MIDI control information */
446 snd_seq_ev_raw8_t raw8; /**< raw8 data */
447 snd_seq_ev_raw32_t raw32; /**< raw32 data */
448 snd_seq_ev_ext_t ext; /**< external data */
449 snd_seq_ev_queue_control_t queue; /**< queue control */
450 snd_seq_timestamp_t time; /**< timestamp */
451 snd_seq_addr_t addr; /**< address */
452 snd_seq_connect_t connect; /**< connect information */
453 snd_seq_result_t result; /**< operation result code */
454 snd_seq_ev_instr_begin_t instr_begin; /**< instrument */
455 snd_seq_ev_sample_control_t sample; /**< sample control */
456 } data; /**< event data... */
457 } snd_seq_event_t;
458
459
460 /** \} */
461
462 #endif /* __ALSA_SEQ_EVENT_H */
463