source: GPL/alsa-kernel/include/sound/seqmid.h@ 18

Last change on this file since 18 was 18, checked in by vladest, 20 years ago

initial import

File size: 11.6 KB
Line 
1/**
2 * \file <alsa/seqmid.h>
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>
7 * \date 1998-2001
8 *
9 * Application interface library for the ALSA driver
10 *
11 *
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as
14 * published by the Free Software Foundation; either version 2.1 of
15 * the License, or (at your option) any later version.
16 *
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 Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28#ifndef __ALSA_SEQMID_H
29#define __ALSA_SEQMID_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/**
36 * \defgroup SeqMiddle Sequencer Middle Level Interface
37 * Sequencer Middle Level Interface
38 * \ingroup Sequencer
39 * \{
40 */
41
42/**
43 * \brief initialize event record
44 * \param ev event record pointer
45 */
46#define snd_seq_ev_clear(ev) \
47 memset(ev, 0, sizeof(snd_seq_event_t))
48
49/**
50 * \brief set the explicit destination
51 * \param ev event record
52 * \param c destination client id
53 * \param p destination port id
54 */
55#define snd_seq_ev_set_dest(ev,c,p) \
56 ((ev)->dest.client = (c), (ev)->dest.port = (p))
57
58/**
59 * \brief set broadcasting to subscribers
60 * \param ev event record
61 */
62#define snd_seq_ev_set_subs(ev) \
63 ((ev)->dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS,\
64 (ev)->dest.port = SNDRV_SEQ_ADDRESS_UNKNOWN)
65
66/**
67 * \brief set broadcasting to all clients/ports
68 * \param ev event record
69 */
70#define snd_seq_ev_set_broadcast(ev) \
71 ((ev)->dest.client = SNDRV_SEQ_ADDRESS_BROADCAST,\
72 (ev)->dest.port = SNDRV_SEQ_ADDRESS_BROADCAST)
73
74/**
75 * \brief set the source port
76 * \param ev event record
77 * \param p source port id
78 */
79#define snd_seq_ev_set_source(ev,p) \
80 ((ev)->source.port = (p))
81
82/**
83 * \brief set direct passing mode (without queued)
84 * \param ev event instance
85 */
86#define snd_seq_ev_set_direct(ev) \
87 ((ev)->queue = SNDRV_SEQ_QUEUE_DIRECT)
88
89/**
90 * \brief set tick-scheduling mode on queue
91 * \param ev event instance
92 * \param q queue id to schedule
93 * \param relative relative time-stamp if non-zero
94 * \param ttick tick time-stamp to be delivered
95 */
96#define snd_seq_ev_schedule_tick(ev, q, relative, ttick) \
97 ((ev)->flags &= ~(SNDRV_SEQ_TIME_STAMP_MASK | SNDRV_SEQ_TIME_MODE_MASK),\
98 (ev)->flags |= SNDRV_SEQ_TIME_STAMP_TICK,\
99 (ev)->flags |= (relative) ? SNDRV_SEQ_TIME_MODE_REL : SNDRV_SEQ_TIME_MODE_ABS,\
100 (ev)->time.tick = (ttick),\
101 (ev)->queue = (q))
102
103/**
104 * \brief set real-time-scheduling mode on queue
105 * \param ev event instance
106 * \param q queue id to schedule
107 * \param relative relative time-stamp if non-zero
108 * \param rtime time-stamp to be delivered
109 */
110#define snd_seq_ev_schedule_real(ev, q, relative, rtime) \
111 ((ev)->flags &= ~(SNDRV_SEQ_TIME_STAMP_MASK | SNDRV_SEQ_TIME_MODE_MASK),\
112 (ev)->flags |= SNDRV_SEQ_TIME_STAMP_REAL,\
113 (ev)->flags |= (relative) ? SNDRV_SEQ_TIME_MODE_REL : SNDRV_SEQ_TIME_MODE_ABS,\
114 (ev)->time.time = *(rtime),\
115 (ev)->queue = (q))
116
117/**
118 * \brief set event priority
119 * \param ev event instance
120 * \param high_prior 1 for high priority mode
121 */
122#define snd_seq_ev_set_priority(ev, high_prior) \
123 ((ev)->flags &= ~SNDRV_SEQ_PRIORITY_MASK,\
124 (ev)->flags |= (high_prior) ? SNDRV_SEQ_PRIORITY_HIGH : SNDRV_SEQ_PRIORITY_NORMAL)
125
126/**
127 * \brief set fixed data
128 * \param ev event instance
129 *
130 * Sets the event length mode as fixed size.
131 */
132#define snd_seq_ev_set_fixed(ev) \
133 ((ev)->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK,\
134 (ev)->flags |= SNDRV_SEQ_EVENT_LENGTH_FIXED)
135
136/**
137 * \brief set variable data
138 * \param ev event instance
139 * \param datalen length of the external data
140 * \param dataptr pointer of the external data
141 *
142 * Sets the event length mode as variable length and stores the data.
143 */
144#define snd_seq_ev_set_variable(ev, datalen, dataptr) \
145 ((ev)->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK,\
146 (ev)->flags |= SNDRV_SEQ_EVENT_LENGTH_VARIABLE,\
147 (ev)->data.ext.len = (datalen),\
148 (ev)->data.ext.ptr = (dataptr))
149
150/**
151 * \brief set varusr data
152 * \param ev event instance
153 * \param len length of the external data
154 * \param ptr pointer of the external data
155 *
156 * Sets the event length mode as variable user-space data and stores the data.
157 */
158#define snd_seq_ev_set_varusr(ev, datalen, dataptr) \
159 ((ev)->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK,\
160 (ev)->flags |= SNDRV_SEQ_EVENT_LENGTH_VARUSR,\
161 (ev)->data.ext.len = (datalen),\
162 (ev)->data.ext.ptr = (dataptr))
163
164/**
165 * \brief set queue controls
166 * \param ev event record
167 * \param typ event type
168 * \param q queue id
169 * \param val control value
170 */
171#define snd_seq_ev_set_queue_control(ev, typ, q, val) \
172 ((ev)->type = (typ),\
173 snd_seq_ev_set_dest(ev, SNDRV_SEQ_CLIENT_SYSTEM, SNDRV_SEQ_PORT_SYSTEM_TIMER),\
174 (ev)->data.queue.queue = (q),\
175 (ev)->data.queue.param.value = (val))
176
177/**
178 * \brief set the start queue event
179 * \param ev event record
180 * \param q queue id to start
181 */
182#define snd_seq_ev_set_queue_start(ev, q) \
183 snd_seq_ev_set_queue_control(ev, SNDRV_SEQ_EVENT_START, q, 0)
184
185/**
186 * \brief set the stop queue event
187 * \param ev event record
188 * \param q queue id to stop
189 */
190#define snd_seq_ev_set_queue_stop(ev, q) \
191 snd_seq_ev_set_queue_control(ev, SNDRV_SEQ_EVENT_STOP, q, 0)
192
193/**
194 * \brief set the stop queue event
195 * \param ev event record
196 * \param q queue id to continue
197 */
198#define snd_seq_ev_set_queue_continue(ev, q) \
199 snd_seq_ev_set_queue_control(ev, SNDRV_SEQ_EVENT_CONTINUE, q, 0)
200
201/**
202 * \brief set the stop queue event
203 * \param ev event record
204 * \param q queue id to change tempo
205 * \param val the new tempo value
206 */
207#define snd_seq_ev_set_queue_tempo(ev, q, val) \
208 snd_seq_ev_set_queue_control(ev, SNDRV_SEQ_EVENT_TEMPO, q, val)
209
210/**
211 * \brief set the real-time position of a queue
212 * \param ev event record
213 * \param q queue id to change tempo
214 * \param rtime the new real-time pointer
215 */
216#define snd_seq_ev_set_queue_pos_real(ev, q, rtime) \
217 ((ev)->type = SNDRV_SEQ_EVENT_SETPOS_TIME,\
218 snd_seq_ev_set_dest(ev, SNDRV_SEQ_CLIENT_SYSTEM, SNDRV_SEQ_PORT_SYSTEM_TIMER),\
219 (ev)->data.queue.queue = (q),\
220 (ev)->data.queue.param.time.time = *(rtime))
221
222/**
223 * \brief set the tick-time position of a queue
224 * \param ev event record
225 * \param q queue id to change tempo
226 * \param ttime the new tick-time
227 */
228#define snd_seq_ev_set_queue_pos_tick(ev, q, ttime) \
229 ((ev)->type = SNDRV_SEQ_EVENT_SETPOS_TICK,\
230 snd_seq_ev_set_dest(ev, SNDRV_SEQ_CLIENT_SYSTEM, SNDRV_SEQ_PORT_SYSTEM_TIMER),\
231 (ev)->data.queue.queue = (q),\
232 (ev)->data.queue.param.time.tick = (ttime))
233
234/**
235 * \brief start the specified queue
236 * \param seq sequencer handle
237 * \param q queue id to start
238 * \param ev optional event record (see #snd_seq_control_queue)
239 */
240#define snd_seq_start_queue(seq, q, ev) \
241 snd_seq_control_queue(seq, q, SNDRV_SEQ_EVENT_START, 0, ev)
242
243/**
244 * \brief stop the specified queue
245 * \param seq sequencer handle
246 * \param q queue id to stop
247 * \param ev optional event record (see #snd_seq_control_queue)
248 */
249#define snd_seq_stop_queue(seq, q, ev) \
250 snd_seq_control_queue(seq, q, SNDRV_SEQ_EVENT_STOP, 0, ev)
251
252/**
253 * \brief continue the specified queue
254 * \param seq sequencer handle
255 * \param q queue id to continue
256 * \param ev optional event record (see #snd_seq_control_queue)
257 */
258#define snd_seq_continue_queue(seq, q, ev) \
259 snd_seq_control_queue(seq, q, SNDRV_SEQ_EVENT_CONTINUE, 0, ev)
260
261/**
262 * \brief change the tempo of the specified queue
263 * \param seq sequencer handle
264 * \param q queue id
265 * \param tempo the new tempo value
266 * \param ev optional event record (see #snd_seq_control_queue)
267 */
268#define snd_seq_change_queue_tempo(seq, q, tempo, ev) \
269 snd_seq_control_queue(seq, q, SNDRV_SEQ_EVENT_TEMPO, tempo, ev)
270
271
272/**
273 * \brief set note event
274 * \param ev event record
275 * \param ch channel number
276 * \param key note key
277 * \param vel velocity
278 * \param dur duration (in tick or msec)
279 */
280#define snd_seq_ev_set_note(ev, ch, key, vel, dur) \
281 ((ev)->type = SNDRV_SEQ_EVENT_NOTE,\
282 snd_seq_ev_set_fixed(ev),\
283 (ev)->data.note.channel = (ch),\
284 (ev)->data.note.note = (key),\
285 (ev)->data.note.velocity = (vel),\
286 (ev)->data.note.duration = (dur))
287
288/**
289 * \brief set note-on event
290 * \param ev event record
291 * \param ch channel number
292 * \param key note key
293 * \param vel velocity
294 */
295#define snd_seq_ev_set_noteon(ev, ch, key, vel) \
296 ((ev)->type = SNDRV_SEQ_EVENT_NOTEON,\
297 snd_seq_ev_set_fixed(ev),\
298 (ev)->data.note.channel = (ch),\
299 (ev)->data.note.note = (key),\
300 (ev)->data.note.velocity = (vel))
301
302/**
303 * \brief set note-off event
304 * \param ev event record
305 * \param ch channel number
306 * \param key note key
307 * \param vel velocity
308 */
309#define snd_seq_ev_set_noteoff(ev, ch, key, vel) \
310 ((ev)->type = SNDRV_SEQ_EVENT_NOTEOFF,\
311 snd_seq_ev_set_fixed(ev),\
312 (ev)->data.note.channel = (ch),\
313 (ev)->data.note.note = (key),\
314 (ev)->data.note.velocity = (vel))
315
316/**
317 * \brief set key-pressure event
318 * \param ev event record
319 * \param ch channel number
320 * \param key note key
321 * \param vel velocity
322 */
323#define snd_seq_ev_set_keypress(ev,ch,key,vel) \
324 ((ev)->type = SNDRV_SEQ_EVENT_KEYPRESS,\
325 snd_seq_ev_set_fixed(ev),\
326 (ev)->data.note.channel = (ch),\
327 (ev)->data.note.note = (key),\
328 (ev)->data.note.velocity = (vel))
329
330/**
331 * \brief set MIDI controller event
332 * \param ev event record
333 * \param ch channel number
334 * \param cc controller number
335 * \param val control value
336 */
337#define snd_seq_ev_set_controller(ev,ch,cc,val) \
338 ((ev)->type = SNDRV_SEQ_EVENT_CONTROLLER,\
339 snd_seq_ev_set_fixed(ev),\
340 (ev)->data.control.channel = (ch),\
341 (ev)->data.control.param = (cc),\
342 (ev)->data.control.value = (val))
343
344/**
345 * \brief set program change event
346 * \param ev event record
347 * \param ch channel number
348 * \param val program number
349 */
350#define snd_seq_ev_set_pgmchange(ev,ch,val) \
351 ((ev)->type = SNDRV_SEQ_EVENT_PGMCHANGE,\
352 snd_seq_ev_set_fixed(ev),\
353 (ev)->data.control.channel = (ch),\
354 (ev)->data.control.value = (val))
355
356/**
357 * \brief set pitch-bend event
358 * \param ev event record
359 * \param ch channel number
360 * \param val pitch bend; zero centered from -8192 to 8191
361 */
362#define snd_seq_ev_set_pitchbend(ev,ch,val) \
363 ((ev)->type = SNDRV_SEQ_EVENT_PITCHBEND,\
364 snd_seq_ev_set_fixed(ev),\
365 (ev)->data.control.channel = (ch),\
366 (ev)->data.control.value = (val))
367
368/**
369 * \brief set channel pressure event
370 * \param ev event record
371 * \param ch channel number
372 * \param val channel pressure value
373 */
374#define snd_seq_ev_set_chanpress(ev,ch,val) \
375 ((ev)->type = SNDRV_SEQ_EVENT_CHANPRESS,\
376 snd_seq_ev_set_fixed(ev),\
377 (ev)->data.control.channel = (ch),\
378 (ev)->data.control.value = (val))
379
380/**
381 * \brief set sysex event
382 * \param ev event record
383 * \param datalen length of sysex data
384 * \param dataptr sysex data pointer
385 *
386 * the sysex data must contain the start byte 0xf0 and the end byte 0xf7.
387 */
388#define snd_seq_ev_set_sysex(ev,datalen,dataptr) \
389 ((ev)->type = SNDRV_SEQ_EVENT_SYSEX,\
390 snd_seq_ev_set_variable(ev, datalen, dataptr))
391
392/** \} */
393
394#ifdef __cplusplus
395}
396#endif
397
398#endif /* __ALSA_SEQMID_H */
399
Note: See TracBrowser for help on using the repository browser.