2 * GM/GS/XG midi module.
4 * Copyright (C) 1999 Steve Ratcliffe
6 * Based on awe_wave.c by Takashi Iwai
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * This module is used to keep track of the current midi state.
25 * It can be used for drivers that are required to emulate midi when
26 * the hardware doesn't.
28 * It was written for a AWE64 driver, but there should be no AWE specific
29 * code in here. If there is it should be reported as a bug.
32 #include <linux/init.h>
33 #include <linux/slab.h>
34 #include <linux/string.h>
35 #include <sound/core.h>
36 #include <sound/seq_kernel.h>
37 #include <sound/seq_midi_emul.h>
38 #include <sound/initval.h>
39 #include <sound/asoundef.h>
41 MODULE_AUTHOR("Takashi Iwai / Steve Ratcliffe");
42 MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI emulation.");
43 MODULE_LICENSE("GPL");
45 /* Prototypes for static functions */
46 static void note_off(struct snd_midi_op
*ops
, void *drv
,
47 struct snd_midi_channel
*chan
,
49 static void do_control(struct snd_midi_op
*ops
, void *private,
50 struct snd_midi_channel_set
*chset
,
51 struct snd_midi_channel
*chan
,
52 int control
, int value
);
53 static void rpn(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
54 struct snd_midi_channel_set
*chset
);
55 static void nrpn(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
56 struct snd_midi_channel_set
*chset
);
57 static void sysex(struct snd_midi_op
*ops
, void *private, unsigned char *sysex
,
58 int len
, struct snd_midi_channel_set
*chset
);
59 static void all_sounds_off(struct snd_midi_op
*ops
, void *private,
60 struct snd_midi_channel
*chan
);
61 static void all_notes_off(struct snd_midi_op
*ops
, void *private,
62 struct snd_midi_channel
*chan
);
63 static void snd_midi_reset_controllers(struct snd_midi_channel
*chan
);
64 static void reset_all_channels(struct snd_midi_channel_set
*chset
);
68 * Process an event in a driver independent way. This means dealing
69 * with RPN, NRPN, SysEx etc that are defined for common midi applications
70 * such as GM, GS and XG.
71 * There modes that this module will run in are:
72 * Generic MIDI - no interpretation at all, it will just save current values
74 * GM - You can use all gm_ prefixed elements of chan. Controls, RPN, NRPN,
75 * SysEx will be interpreded as defined in General Midi.
76 * GS - You can use all gs_ prefixed elements of chan. Codes for GS will be
78 * XG - You can use all xg_ prefixed elements of chan. Codes for XG will
82 snd_midi_process_event(struct snd_midi_op
*ops
,
83 struct snd_seq_event
*ev
,
84 struct snd_midi_channel_set
*chanset
)
86 struct snd_midi_channel
*chan
;
90 if (ev
== NULL
|| chanset
== NULL
) {
91 snd_printd("ev or chanbase NULL (snd_midi_process_event)\n");
94 if (chanset
->channels
== NULL
)
97 if (snd_seq_ev_is_channel_type(ev
)) {
98 dest_channel
= ev
->data
.note
.channel
;
99 if (dest_channel
>= chanset
->max_channels
) {
100 snd_printd("dest channel is %d, max is %d\n",
101 dest_channel
, chanset
->max_channels
);
106 chan
= chanset
->channels
+ dest_channel
;
107 drv
= chanset
->private_data
;
109 /* EVENT_NOTE should be processed before queued */
110 if (ev
->type
== SNDRV_SEQ_EVENT_NOTE
)
113 /* Make sure that we don't have a note on that should really be
115 if (ev
->type
== SNDRV_SEQ_EVENT_NOTEON
&& ev
->data
.note
.velocity
== 0)
116 ev
->type
= SNDRV_SEQ_EVENT_NOTEOFF
;
118 /* Make sure the note is within array range */
119 if (ev
->type
== SNDRV_SEQ_EVENT_NOTEON
||
120 ev
->type
== SNDRV_SEQ_EVENT_NOTEOFF
||
121 ev
->type
== SNDRV_SEQ_EVENT_KEYPRESS
) {
122 if (ev
->data
.note
.note
>= 128)
127 case SNDRV_SEQ_EVENT_NOTEON
:
128 if (chan
->note
[ev
->data
.note
.note
] & SNDRV_MIDI_NOTE_ON
) {
130 ops
->note_off(drv
, ev
->data
.note
.note
, 0, chan
);
132 chan
->note
[ev
->data
.note
.note
] = SNDRV_MIDI_NOTE_ON
;
134 ops
->note_on(drv
, ev
->data
.note
.note
, ev
->data
.note
.velocity
, chan
);
136 case SNDRV_SEQ_EVENT_NOTEOFF
:
137 if (! (chan
->note
[ev
->data
.note
.note
] & SNDRV_MIDI_NOTE_ON
))
140 note_off(ops
, drv
, chan
, ev
->data
.note
.note
, ev
->data
.note
.velocity
);
142 case SNDRV_SEQ_EVENT_KEYPRESS
:
144 ops
->key_press(drv
, ev
->data
.note
.note
, ev
->data
.note
.velocity
, chan
);
146 case SNDRV_SEQ_EVENT_CONTROLLER
:
147 do_control(ops
, drv
, chanset
, chan
,
148 ev
->data
.control
.param
, ev
->data
.control
.value
);
150 case SNDRV_SEQ_EVENT_PGMCHANGE
:
151 chan
->midi_program
= ev
->data
.control
.value
;
153 case SNDRV_SEQ_EVENT_PITCHBEND
:
154 chan
->midi_pitchbend
= ev
->data
.control
.value
;
156 ops
->control(drv
, MIDI_CTL_PITCHBEND
, chan
);
158 case SNDRV_SEQ_EVENT_CHANPRESS
:
159 chan
->midi_pressure
= ev
->data
.control
.value
;
161 ops
->control(drv
, MIDI_CTL_CHAN_PRESSURE
, chan
);
163 case SNDRV_SEQ_EVENT_CONTROL14
:
164 /* Best guess is that this is any of the 14 bit controller values */
165 if (ev
->data
.control
.param
< 32) {
166 /* set low part first */
167 chan
->control
[ev
->data
.control
.param
+ 32] =
168 ev
->data
.control
.value
& 0x7f;
169 do_control(ops
, drv
, chanset
, chan
,
170 ev
->data
.control
.param
,
171 ((ev
->data
.control
.value
>>7) & 0x7f));
173 do_control(ops
, drv
, chanset
, chan
,
174 ev
->data
.control
.param
,
175 ev
->data
.control
.value
);
177 case SNDRV_SEQ_EVENT_NONREGPARAM
:
178 /* Break it back into its controller values */
179 chan
->param_type
= SNDRV_MIDI_PARAM_TYPE_NONREGISTERED
;
180 chan
->control
[MIDI_CTL_MSB_DATA_ENTRY
]
181 = (ev
->data
.control
.value
>> 7) & 0x7f;
182 chan
->control
[MIDI_CTL_LSB_DATA_ENTRY
]
183 = ev
->data
.control
.value
& 0x7f;
184 chan
->control
[MIDI_CTL_NONREG_PARM_NUM_MSB
]
185 = (ev
->data
.control
.param
>> 7) & 0x7f;
186 chan
->control
[MIDI_CTL_NONREG_PARM_NUM_LSB
]
187 = ev
->data
.control
.param
& 0x7f;
188 nrpn(ops
, drv
, chan
, chanset
);
190 case SNDRV_SEQ_EVENT_REGPARAM
:
191 /* Break it back into its controller values */
192 chan
->param_type
= SNDRV_MIDI_PARAM_TYPE_REGISTERED
;
193 chan
->control
[MIDI_CTL_MSB_DATA_ENTRY
]
194 = (ev
->data
.control
.value
>> 7) & 0x7f;
195 chan
->control
[MIDI_CTL_LSB_DATA_ENTRY
]
196 = ev
->data
.control
.value
& 0x7f;
197 chan
->control
[MIDI_CTL_REGIST_PARM_NUM_MSB
]
198 = (ev
->data
.control
.param
>> 7) & 0x7f;
199 chan
->control
[MIDI_CTL_REGIST_PARM_NUM_LSB
]
200 = ev
->data
.control
.param
& 0x7f;
201 rpn(ops
, drv
, chan
, chanset
);
203 case SNDRV_SEQ_EVENT_SYSEX
:
204 if ((ev
->flags
& SNDRV_SEQ_EVENT_LENGTH_MASK
) == SNDRV_SEQ_EVENT_LENGTH_VARIABLE
) {
205 unsigned char sysexbuf
[64];
207 len
= snd_seq_expand_var_event(ev
, sizeof(sysexbuf
), sysexbuf
, 1, 0);
209 sysex(ops
, drv
, sysexbuf
, len
, chanset
);
212 case SNDRV_SEQ_EVENT_SONGPOS
:
213 case SNDRV_SEQ_EVENT_SONGSEL
:
214 case SNDRV_SEQ_EVENT_CLOCK
:
215 case SNDRV_SEQ_EVENT_START
:
216 case SNDRV_SEQ_EVENT_CONTINUE
:
217 case SNDRV_SEQ_EVENT_STOP
:
218 case SNDRV_SEQ_EVENT_QFRAME
:
219 case SNDRV_SEQ_EVENT_TEMPO
:
220 case SNDRV_SEQ_EVENT_TIMESIGN
:
221 case SNDRV_SEQ_EVENT_KEYSIGN
:
223 case SNDRV_SEQ_EVENT_SENSING
:
225 case SNDRV_SEQ_EVENT_CLIENT_START
:
226 case SNDRV_SEQ_EVENT_CLIENT_EXIT
:
227 case SNDRV_SEQ_EVENT_CLIENT_CHANGE
:
228 case SNDRV_SEQ_EVENT_PORT_START
:
229 case SNDRV_SEQ_EVENT_PORT_EXIT
:
230 case SNDRV_SEQ_EVENT_PORT_CHANGE
:
231 case SNDRV_SEQ_EVENT_ECHO
:
234 /*snd_printd("Unimplemented event %d\n", ev->type);*/
244 note_off(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
248 /* Hold this note until pedal is turned off */
249 chan
->note
[note
] |= SNDRV_MIDI_NOTE_RELEASED
;
250 } else if (chan
->note
[note
] & SNDRV_MIDI_NOTE_SOSTENUTO
) {
251 /* Mark this note as release; it will be turned off when sostenuto
253 chan
->note
[note
] |= SNDRV_MIDI_NOTE_RELEASED
;
255 chan
->note
[note
] = 0;
257 ops
->note_off(drv
, note
, vel
, chan
);
262 * Do all driver independent operations for this controller and pass
263 * events that need to take place immediately to the driver.
266 do_control(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel_set
*chset
,
267 struct snd_midi_channel
*chan
, int control
, int value
)
272 if ((control
>=64 && control
<=69) || (control
>= 80 && control
<= 83)) {
273 /* These are all switches; either off or on so set to 0 or 127 */
274 value
= (value
>= 64)? 127: 0;
276 chan
->control
[control
] = value
;
279 case MIDI_CTL_SUSTAIN
:
281 /* Sustain has been released, turn off held notes */
282 for (i
= 0; i
< 128; i
++) {
283 if (chan
->note
[i
] & SNDRV_MIDI_NOTE_RELEASED
) {
284 chan
->note
[i
] = SNDRV_MIDI_NOTE_OFF
;
286 ops
->note_off(drv
, i
, 0, chan
);
291 case MIDI_CTL_PORTAMENTO
:
293 case MIDI_CTL_SOSTENUTO
:
295 /* Mark each note that is currently held down */
296 for (i
= 0; i
< 128; i
++) {
297 if (chan
->note
[i
] & SNDRV_MIDI_NOTE_ON
)
298 chan
->note
[i
] |= SNDRV_MIDI_NOTE_SOSTENUTO
;
301 /* release all notes that were held */
302 for (i
= 0; i
< 128; i
++) {
303 if (chan
->note
[i
] & SNDRV_MIDI_NOTE_SOSTENUTO
) {
304 chan
->note
[i
] &= ~SNDRV_MIDI_NOTE_SOSTENUTO
;
305 if (chan
->note
[i
] & SNDRV_MIDI_NOTE_RELEASED
) {
306 chan
->note
[i
] = SNDRV_MIDI_NOTE_OFF
;
308 ops
->note_off(drv
, i
, 0, chan
);
314 case MIDI_CTL_MSB_DATA_ENTRY
:
315 chan
->control
[MIDI_CTL_LSB_DATA_ENTRY
] = 0;
316 /* go through here */
317 case MIDI_CTL_LSB_DATA_ENTRY
:
318 if (chan
->param_type
== SNDRV_MIDI_PARAM_TYPE_REGISTERED
)
319 rpn(ops
, drv
, chan
, chset
);
321 nrpn(ops
, drv
, chan
, chset
);
323 case MIDI_CTL_REGIST_PARM_NUM_LSB
:
324 case MIDI_CTL_REGIST_PARM_NUM_MSB
:
325 chan
->param_type
= SNDRV_MIDI_PARAM_TYPE_REGISTERED
;
327 case MIDI_CTL_NONREG_PARM_NUM_LSB
:
328 case MIDI_CTL_NONREG_PARM_NUM_MSB
:
329 chan
->param_type
= SNDRV_MIDI_PARAM_TYPE_NONREGISTERED
;
332 case MIDI_CTL_ALL_SOUNDS_OFF
:
333 all_sounds_off(ops
, drv
, chan
);
336 case MIDI_CTL_ALL_NOTES_OFF
:
337 all_notes_off(ops
, drv
, chan
);
340 case MIDI_CTL_MSB_BANK
:
341 if (chset
->midi_mode
== SNDRV_MIDI_MODE_XG
) {
343 chan
->drum_channel
= 1;
345 chan
->drum_channel
= 0;
348 case MIDI_CTL_LSB_BANK
:
351 case MIDI_CTL_RESET_CONTROLLERS
:
352 snd_midi_reset_controllers(chan
);
355 case MIDI_CTL_SOFT_PEDAL
:
356 case MIDI_CTL_LEGATO_FOOTSWITCH
:
358 case MIDI_CTL_SC1_SOUND_VARIATION
:
359 case MIDI_CTL_SC2_TIMBRE
:
360 case MIDI_CTL_SC3_RELEASE_TIME
:
361 case MIDI_CTL_SC4_ATTACK_TIME
:
362 case MIDI_CTL_SC5_BRIGHTNESS
:
363 case MIDI_CTL_E1_REVERB_DEPTH
:
364 case MIDI_CTL_E2_TREMOLO_DEPTH
:
365 case MIDI_CTL_E3_CHORUS_DEPTH
:
366 case MIDI_CTL_E4_DETUNE_DEPTH
:
367 case MIDI_CTL_E5_PHASER_DEPTH
:
372 ops
->control(drv
, control
, chan
);
379 * initialize the MIDI status
382 snd_midi_channel_set_clear(struct snd_midi_channel_set
*chset
)
386 chset
->midi_mode
= SNDRV_MIDI_MODE_GM
;
387 chset
->gs_master_volume
= 127;
389 for (i
= 0; i
< chset
->max_channels
; i
++) {
390 struct snd_midi_channel
*chan
= chset
->channels
+ i
;
391 memset(chan
->note
, 0, sizeof(chan
->note
));
393 chan
->midi_aftertouch
= 0;
394 chan
->midi_pressure
= 0;
395 chan
->midi_program
= 0;
396 chan
->midi_pitchbend
= 0;
397 snd_midi_reset_controllers(chan
);
398 chan
->gm_rpn_pitch_bend_range
= 256; /* 2 semitones */
399 chan
->gm_rpn_fine_tuning
= 0;
400 chan
->gm_rpn_coarse_tuning
= 0;
403 chan
->drum_channel
= 1;
405 chan
->drum_channel
= 0;
410 * Process a rpn message.
413 rpn(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
414 struct snd_midi_channel_set
*chset
)
419 if (chset
->midi_mode
!= SNDRV_MIDI_MODE_NONE
) {
420 type
= (chan
->control
[MIDI_CTL_REGIST_PARM_NUM_MSB
] << 8) |
421 chan
->control
[MIDI_CTL_REGIST_PARM_NUM_LSB
];
422 val
= (chan
->control
[MIDI_CTL_MSB_DATA_ENTRY
] << 7) |
423 chan
->control
[MIDI_CTL_LSB_DATA_ENTRY
];
426 case 0x0000: /* Pitch bend sensitivity */
427 /* MSB only / 1 semitone per 128 */
428 chan
->gm_rpn_pitch_bend_range
= val
;
431 case 0x0001: /* fine tuning: */
432 /* MSB/LSB, 8192=center, 100/8192 cent step */
433 chan
->gm_rpn_fine_tuning
= val
- 8192;
436 case 0x0002: /* coarse tuning */
437 /* MSB only / 8192=center, 1 semitone per 128 */
438 chan
->gm_rpn_coarse_tuning
= val
- 8192;
441 case 0x7F7F: /* "lock-in" RPN */
446 /* should call nrpn or rpn callback here.. */
450 * Process an nrpn message.
453 nrpn(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
454 struct snd_midi_channel_set
*chset
)
456 /* parse XG NRPNs here if possible */
458 ops
->nrpn(drv
, chan
, chset
);
463 * convert channel parameter in GS sysex
466 get_channel(unsigned char cmd
)
478 * Process a sysex message.
481 sysex(struct snd_midi_op
*ops
, void *private, unsigned char *buf
, int len
,
482 struct snd_midi_channel_set
*chset
)
485 static unsigned char gm_on_macro
[] = {
489 static unsigned char xg_on_macro
[] = {
490 0x43,0x10,0x4c,0x00,0x00,0x7e,0x00,
493 * drum channel: XX=0x1?(channel), YY=0x15, ZZ=on/off
494 * reverb mode: XX=0x01, YY=0x30, ZZ=0-7
495 * chorus mode: XX=0x01, YY=0x38, ZZ=0-7
496 * master vol: XX=0x00, YY=0x04, ZZ=0-127
498 static unsigned char gs_pfx_macro
[] = {
499 0x41,0x10,0x42,0x12,0x40,/*XX,YY,ZZ*/
502 int parsed
= SNDRV_MIDI_SYSEX_NOT_PARSED
;
504 if (len
<= 0 || buf
[0] != 0xf0)
506 /* skip first byte */
511 if (len
>= (int)sizeof(gm_on_macro
) &&
512 memcmp(buf
, gm_on_macro
, sizeof(gm_on_macro
)) == 0) {
513 if (chset
->midi_mode
!= SNDRV_MIDI_MODE_GS
&&
514 chset
->midi_mode
!= SNDRV_MIDI_MODE_XG
) {
515 chset
->midi_mode
= SNDRV_MIDI_MODE_GM
;
516 reset_all_channels(chset
);
517 parsed
= SNDRV_MIDI_SYSEX_GM_ON
;
523 memcmp(buf
, gs_pfx_macro
, sizeof(gs_pfx_macro
)) == 0) {
524 if (chset
->midi_mode
!= SNDRV_MIDI_MODE_GS
&&
525 chset
->midi_mode
!= SNDRV_MIDI_MODE_XG
)
526 chset
->midi_mode
= SNDRV_MIDI_MODE_GS
;
528 if (buf
[5] == 0x00 && buf
[6] == 0x7f && buf
[7] == 0x00) {
530 parsed
= SNDRV_MIDI_SYSEX_GS_RESET
;
531 reset_all_channels(chset
);
534 else if ((buf
[5] & 0xf0) == 0x10 && buf
[6] == 0x15) {
536 int p
= get_channel(buf
[5]);
537 if (p
< chset
->max_channels
) {
538 parsed
= SNDRV_MIDI_SYSEX_GS_DRUM_CHANNEL
;
540 chset
->channels
[p
].drum_channel
= 1;
542 chset
->channels
[p
].drum_channel
= 0;
545 } else if ((buf
[5] & 0xf0) == 0x10 && buf
[6] == 0x21) {
547 int p
= get_channel(buf
[5]);
548 if (p
< chset
->max_channels
&&
549 ! chset
->channels
[p
].drum_channel
) {
550 parsed
= SNDRV_MIDI_SYSEX_GS_DRUM_CHANNEL
;
551 chset
->channels
[p
].midi_program
= buf
[7];
554 } else if (buf
[5] == 0x01 && buf
[6] == 0x30) {
556 parsed
= SNDRV_MIDI_SYSEX_GS_REVERB_MODE
;
557 chset
->gs_reverb_mode
= buf
[7];
559 } else if (buf
[5] == 0x01 && buf
[6] == 0x38) {
561 parsed
= SNDRV_MIDI_SYSEX_GS_CHORUS_MODE
;
562 chset
->gs_chorus_mode
= buf
[7];
564 } else if (buf
[5] == 0x00 && buf
[6] == 0x04) {
566 parsed
= SNDRV_MIDI_SYSEX_GS_MASTER_VOLUME
;
567 chset
->gs_master_volume
= buf
[7];
573 else if (len
>= (int)sizeof(xg_on_macro
) &&
574 memcmp(buf
, xg_on_macro
, sizeof(xg_on_macro
)) == 0) {
576 chset
->midi_mode
= SNDRV_MIDI_MODE_XG
;
577 parsed
= SNDRV_MIDI_SYSEX_XG_ON
;
578 /* reset CC#0 for drums */
579 for (i
= 0; i
< chset
->max_channels
; i
++) {
580 if (chset
->channels
[i
].drum_channel
)
581 chset
->channels
[i
].control
[MIDI_CTL_MSB_BANK
] = 127;
583 chset
->channels
[i
].control
[MIDI_CTL_MSB_BANK
] = 0;
588 ops
->sysex(private, buf
- 1, len
+ 1, parsed
, chset
);
595 all_sounds_off(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
)
599 if (! ops
->note_terminate
)
601 for (n
= 0; n
< 128; n
++) {
603 ops
->note_terminate(drv
, n
, chan
);
613 all_notes_off(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
)
619 for (n
= 0; n
< 128; n
++) {
620 if (chan
->note
[n
] == SNDRV_MIDI_NOTE_ON
)
621 note_off(ops
, drv
, chan
, n
, 0);
626 * Initialise a single midi channel control block.
628 static void snd_midi_channel_init(struct snd_midi_channel
*p
, int n
)
633 memset(p
, 0, sizeof(struct snd_midi_channel
));
637 snd_midi_reset_controllers(p
);
638 p
->gm_rpn_pitch_bend_range
= 256; /* 2 semitones */
639 p
->gm_rpn_fine_tuning
= 0;
640 p
->gm_rpn_coarse_tuning
= 0;
643 p
->drum_channel
= 1; /* Default ch 10 as drums */
647 * Allocate and initialise a set of midi channel control blocks.
649 static struct snd_midi_channel
*snd_midi_channel_init_set(int n
)
651 struct snd_midi_channel
*chan
;
654 chan
= kmalloc(n
* sizeof(struct snd_midi_channel
), GFP_KERNEL
);
656 for (i
= 0; i
< n
; i
++)
657 snd_midi_channel_init(chan
+i
, i
);
664 * reset all midi channels
667 reset_all_channels(struct snd_midi_channel_set
*chset
)
670 for (ch
= 0; ch
< chset
->max_channels
; ch
++) {
671 struct snd_midi_channel
*chan
= chset
->channels
+ ch
;
672 snd_midi_reset_controllers(chan
);
673 chan
->gm_rpn_pitch_bend_range
= 256; /* 2 semitones */
674 chan
->gm_rpn_fine_tuning
= 0;
675 chan
->gm_rpn_coarse_tuning
= 0;
678 chan
->drum_channel
= 1;
680 chan
->drum_channel
= 0;
686 * Allocate and initialise a midi channel set.
688 struct snd_midi_channel_set
*snd_midi_channel_alloc_set(int n
)
690 struct snd_midi_channel_set
*chset
;
692 chset
= kmalloc(sizeof(*chset
), GFP_KERNEL
);
694 chset
->channels
= snd_midi_channel_init_set(n
);
695 chset
->private_data
= NULL
;
696 chset
->max_channels
= n
;
702 * Reset the midi controllers on a particular channel to default values.
704 static void snd_midi_reset_controllers(struct snd_midi_channel
*chan
)
706 memset(chan
->control
, 0, sizeof(chan
->control
));
707 chan
->gm_volume
= 127;
708 chan
->gm_expression
= 127;
714 * Free a midi channel set.
716 void snd_midi_channel_free_set(struct snd_midi_channel_set
*chset
)
720 kfree(chset
->channels
);
724 static int __init
alsa_seq_midi_emul_init(void)
729 static void __exit
alsa_seq_midi_emul_exit(void)
733 module_init(alsa_seq_midi_emul_init
)
734 module_exit(alsa_seq_midi_emul_exit
)
736 EXPORT_SYMBOL(snd_midi_process_event
);
737 EXPORT_SYMBOL(snd_midi_channel_set_clear
);
738 EXPORT_SYMBOL(snd_midi_channel_alloc_set
);
739 EXPORT_SYMBOL(snd_midi_channel_free_set
);