1 /*
2  *   This library is free software; you can redistribute it and/or modify
3  *   it under the terms of the GNU Lesser General Public License as
4  *   published by the Free Software Foundation; either version 2.1 of
5  *   the License, or (at your option) any later version.
6  *
7  *   This program is distributed in the hope that it will be useful,
8  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  *   GNU Lesser General Public License for more details.
11  *
12  *   You should have received a copy of the GNU Lesser General Public
13  *   License along with this library; if not, write to the Free Software
14  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15  *
16  */
17 
18 #ifndef __ALSA_SEQ_EVENT_COMPAT_H
19 #define __ALSA_SEQ_EVENT_COMPAT_H
20 
21 /**
22  * Sequencer event data type
23  */
24 typedef unsigned char snd_seq_event_type_t;
25 
26 /** Sequencer event type */
27 enum snd_seq_event_type {
28         /** system status; event data type = #snd_seq_result_t */
29         SND_SEQ_EVENT_SYSTEM = 0,
30         /** returned result status; event data type = #snd_seq_result_t */
31         SND_SEQ_EVENT_RESULT,
32 
33         /** note on and off with duration; event data type = #snd_seq_ev_note_t */
34         SND_SEQ_EVENT_NOTE = 5,
35         /** note on; event data type = #snd_seq_ev_note_t */
36         SND_SEQ_EVENT_NOTEON,
37         /** note off; event data type = #snd_seq_ev_note_t */
38         SND_SEQ_EVENT_NOTEOFF,
39         /** key pressure change (aftertouch); event data type = #snd_seq_ev_note_t */
40         SND_SEQ_EVENT_KEYPRESS,
41 
42         /** controller; event data type = #snd_seq_ev_ctrl_t */
43         SND_SEQ_EVENT_CONTROLLER = 10,
44         /** program change; event data type = #snd_seq_ev_ctrl_t */
45         SND_SEQ_EVENT_PGMCHANGE,
46         /** channel pressure; event data type = #snd_seq_ev_ctrl_t */
47         SND_SEQ_EVENT_CHANPRESS,
48         /** pitchwheel; event data type = #snd_seq_ev_ctrl_t; data is from -8192 to 8191) */
49         SND_SEQ_EVENT_PITCHBEND,
50         /** 14 bit controller value; event data type = #snd_seq_ev_ctrl_t */
51         SND_SEQ_EVENT_CONTROL14,
52         /** 14 bit NRPN;  event data type = #snd_seq_ev_ctrl_t */
53         SND_SEQ_EVENT_NONREGPARAM,
54         /** 14 bit RPN; event data type = #snd_seq_ev_ctrl_t */
55         SND_SEQ_EVENT_REGPARAM,
56 
57         /** SPP with LSB and MSB values; event data type = #snd_seq_ev_ctrl_t */
58         SND_SEQ_EVENT_SONGPOS = 20,
59         /** Song Select with song ID number; event data type = #snd_seq_ev_ctrl_t */
60         SND_SEQ_EVENT_SONGSEL,
61         /** midi time code quarter frame; event data type = #snd_seq_ev_ctrl_t */
62         SND_SEQ_EVENT_QFRAME,
63         /** SMF Time Signature event; event data type = #snd_seq_ev_ctrl_t */
64         SND_SEQ_EVENT_TIMESIGN,
65         /** SMF Key Signature event; event data type = #snd_seq_ev_ctrl_t */
66         SND_SEQ_EVENT_KEYSIGN,
67 
68         /** MIDI Real Time Start message; event data type = #snd_seq_ev_queue_control_t */
69         SND_SEQ_EVENT_START = 30,
70         /** MIDI Real Time Continue message; event data type = #snd_seq_ev_queue_control_t */
71         SND_SEQ_EVENT_CONTINUE,
72         /** MIDI Real Time Stop message; event data type = #snd_seq_ev_queue_control_t */
73         SND_SEQ_EVENT_STOP,
74         /** Set tick queue position; event data type = #snd_seq_ev_queue_control_t */
75         SND_SEQ_EVENT_SETPOS_TICK,
76         /** Set real-time queue position; event data type = #snd_seq_ev_queue_control_t */
77         SND_SEQ_EVENT_SETPOS_TIME,
78         /** (SMF) Tempo event; event data type = #snd_seq_ev_queue_control_t */
79         SND_SEQ_EVENT_TEMPO,
80         /** MIDI Real Time Clock message; event data type = #snd_seq_ev_queue_control_t */
81         SND_SEQ_EVENT_CLOCK,
82         /** MIDI Real Time Tick message; event data type = #snd_seq_ev_queue_control_t */
83         SND_SEQ_EVENT_TICK,
84         /** Queue timer skew; event data type = #snd_seq_ev_queue_control_t */
85         SND_SEQ_EVENT_QUEUE_SKEW,
86         /** Sync position changed; event data type = #snd_seq_ev_queue_control_t */
87         SND_SEQ_EVENT_SYNC_POS,
88 
89         /** Tune request; event data type = none */
90         SND_SEQ_EVENT_TUNE_REQUEST = 40,
91         /** Reset to power-on state; event data type = none */
92         SND_SEQ_EVENT_RESET,
93         /** Active sensing event; event data type = none */
94         SND_SEQ_EVENT_SENSING,
95 
96         /** Echo-back event; event data type = any type */
97         SND_SEQ_EVENT_ECHO = 50,
98         /** OSS emulation raw event; event data type = any type */
99         SND_SEQ_EVENT_OSS,
100 
101         /** New client has connected; event data type = #snd_seq_addr_t */
102         SND_SEQ_EVENT_CLIENT_START = 60,
103         /** Client has left the system; event data type = #snd_seq_addr_t */
104         SND_SEQ_EVENT_CLIENT_EXIT,
105         /** Client status/info has changed; event data type = #snd_seq_addr_t */
106         SND_SEQ_EVENT_CLIENT_CHANGE,
107         /** New port was created; event data type = #snd_seq_addr_t */
108         SND_SEQ_EVENT_PORT_START,
109         /** Port was deleted from system; event data type = #snd_seq_addr_t */
110         SND_SEQ_EVENT_PORT_EXIT,
111         /** Port status/info has changed; event data type = #snd_seq_addr_t */
112         SND_SEQ_EVENT_PORT_CHANGE,
113 
114         /** Ports connected; event data type = #snd_seq_connect_t */
115         SND_SEQ_EVENT_PORT_SUBSCRIBED,
116         /** Ports disconnected; event data type = #snd_seq_connect_t */
117         SND_SEQ_EVENT_PORT_UNSUBSCRIBED,
118 
119         /** user-defined event; event data type = any (fixed size) */
120         SND_SEQ_EVENT_USR0 = 90,
121         /** user-defined event; event data type = any (fixed size) */
122         SND_SEQ_EVENT_USR1,
123         /** user-defined event; event data type = any (fixed size) */
124         SND_SEQ_EVENT_USR2,
125         /** user-defined event; event data type = any (fixed size) */
126         SND_SEQ_EVENT_USR3,
127         /** user-defined event; event data type = any (fixed size) */
128         SND_SEQ_EVENT_USR4,
129         /** user-defined event; event data type = any (fixed size) */
130         SND_SEQ_EVENT_USR5,
131         /** user-defined event; event data type = any (fixed size) */
132         SND_SEQ_EVENT_USR6,
133         /** user-defined event; event data type = any (fixed size) */
134         SND_SEQ_EVENT_USR7,
135         /** user-defined event; event data type = any (fixed size) */
136         SND_SEQ_EVENT_USR8,
137         /** user-defined event; event data type = any (fixed size) */
138         SND_SEQ_EVENT_USR9,
139 
140         /** system exclusive data (variable length);  event data type = #snd_seq_ev_ext_t */
141         SND_SEQ_EVENT_SYSEX = 130,
142         /** error event;  event data type = #snd_seq_ev_ext_t */
143         SND_SEQ_EVENT_BOUNCE,
144         /** reserved for user apps;  event data type = #snd_seq_ev_ext_t */
145         SND_SEQ_EVENT_USR_VAR0 = 135,
146         /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
147         SND_SEQ_EVENT_USR_VAR1,
148         /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
149         SND_SEQ_EVENT_USR_VAR2,
150         /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
151         SND_SEQ_EVENT_USR_VAR3,
152         /** reserved for user apps; event data type = #snd_seq_ev_ext_t */
153         SND_SEQ_EVENT_USR_VAR4,
154 
155         /** NOP; ignored in any case */
156         SND_SEQ_EVENT_NONE = 255
157 };
158 
159 /** Sequencer event address */
160 typedef struct snd_seq_addr {
161         unsigned char client;	/**< Client id */
162         unsigned char port;	/**< Port id */
163 } snd_seq_addr_t;
164 
165 /** Connection (subscription) between ports */
166 typedef struct snd_seq_connect {
167         snd_seq_addr_t sender;	/**< sender address */
168         snd_seq_addr_t dest;	/**< destination address */
169 } snd_seq_connect_t;
170 
171 /** Real-time data record */
172 typedef struct snd_seq_real_time {
173         unsigned int tv_sec;		/**< seconds */
174         unsigned int tv_nsec;		/**< nanoseconds */
175 } snd_seq_real_time_t;
176 
177 /** (MIDI) Tick-time data record */
178 typedef unsigned int snd_seq_tick_time_t;
179 
180 /** unioned time stamp */
181 typedef union snd_seq_timestamp {
182         snd_seq_tick_time_t tick;       /**< tick-time */
183         struct snd_seq_real_time time;  /**< real-time */
184 } snd_seq_timestamp_t;
185 
186 /** Note event */
187 typedef struct snd_seq_ev_note {
188         unsigned char channel;		/**< channel number */
189         unsigned char note;		/**< note */
190         unsigned char velocity;		/**< velocity */
191         unsigned char off_velocity;	/**< note-off velocity; only for #SND_SEQ_EVENT_NOTE */
192         unsigned int duration;		/**< duration until note-off; only for #SND_SEQ_EVENT_NOTE */
193 } snd_seq_ev_note_t;
194 
195 /** Controller event */
196 typedef struct snd_seq_ev_ctrl {
197         unsigned char channel;		/**< channel number */
198         unsigned char unused[3];	/**< reserved */
199         unsigned int param;		/**< control parameter */
200         signed int value;		/**< control value */
201 } snd_seq_ev_ctrl_t;
202 
203 /** generic set of bytes (12x8 bit) */
204 typedef struct snd_seq_ev_raw8 {
205         unsigned char d[12];		/**< 8 bit value */
206 } snd_seq_ev_raw8_t;
207 
208 /** generic set of integers (3x32 bit) */
209 typedef struct snd_seq_ev_raw32 {
210         unsigned int d[3];		/**< 32 bit value */
211 } snd_seq_ev_raw32_t;
212 
213 /** external stored data */
214 typedef struct snd_seq_ev_ext {
215         unsigned int len;		/**< length of data */
216         void *ptr;			/**< pointer to data (note: can be 64-bit) */
217 } __attribute__((packed)) snd_seq_ev_ext_t;
218 
219 /** Result events */
220 typedef struct snd_seq_result {
221         int event;		/**< processed event type */
222         int result;		/**< status */
223 } snd_seq_result_t;
224 
225 /** Queue skew values */
226 typedef struct snd_seq_queue_skew {
227         unsigned int value;	/**< skew value */
228         unsigned int base;	/**< skew base */
229 } snd_seq_queue_skew_t;
230 
231 /** queue timer control */
232 typedef struct snd_seq_ev_queue_control {
233         unsigned char queue;			/**< affected queue */
234         unsigned char unused[3];		/**< reserved */
235         union {
236                 signed int value;		/**< affected value (e.g. tempo) */
237                 snd_seq_timestamp_t time;	/**< time */
238                 unsigned int position;		/**< sync position */
239                 snd_seq_queue_skew_t skew;	/**< queue skew */
240                 unsigned int d32[2];		/**< any data */
241                 unsigned char d8[8];		/**< any data */
242         } param;				/**< data value union */
243 } snd_seq_ev_queue_control_t;
244 
245 /** Sequencer event */
246 typedef struct snd_seq_event {
247         snd_seq_event_type_t type;      /**< event type */
248         unsigned char flags;            /**< event flags */
249         unsigned char tag;              /**< tag */
250 
251         unsigned char queue;            /**< schedule queue */
252         snd_seq_timestamp_t time;       /**< schedule time */
253 
254         snd_seq_addr_t source;          /**< source address */
255         snd_seq_addr_t dest;            /**< destination address */
256 
257         union {
258                 snd_seq_ev_note_t note;         /**< note information */
259                 snd_seq_ev_ctrl_t control;      /**< MIDI control information */
260                 snd_seq_ev_raw8_t raw8;         /**< raw8 data */
261                 snd_seq_ev_raw32_t raw32;       /**< raw32 data */
262                 snd_seq_ev_ext_t ext;           /**< external data */
263                 snd_seq_ev_queue_control_t queue; /**< queue control */
264                 snd_seq_timestamp_t time;       /**< timestamp */
265                 snd_seq_addr_t addr;            /**< address */
266                 snd_seq_connect_t connect;      /**< connect information */
267                 snd_seq_result_t result;        /**< operation result code */
268         } data;                         /**< event data... */
269 } snd_seq_event_t;
270 
271 #endif /* __ALSA_SEQ_EVENT_COMPAT_H */
272 
273