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

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