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 <linux/module.h>
36 #include <sound/core.h>
37 #include <sound/seq_kernel.h>
38 #include <sound/seq_midi_emul.h>
39 #include <sound/initval.h>
40 #include <sound/asoundef.h>
42 MODULE_AUTHOR("Takashi Iwai / Steve Ratcliffe");
43 MODULE_DESCRIPTION("Advanced Linux Sound Architecture sequencer MIDI emulation.");
44 MODULE_LICENSE("GPL");
46 /* Prototypes for static functions */
47 static void note_off(struct snd_midi_op
*ops
, void *drv
,
48 struct snd_midi_channel
*chan
,
50 static void do_control(struct snd_midi_op
*ops
, void *private,
51 struct snd_midi_channel_set
*chset
,
52 struct snd_midi_channel
*chan
,
53 int control
, int value
);
54 static void rpn(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
55 struct snd_midi_channel_set
*chset
);
56 static void nrpn(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
57 struct snd_midi_channel_set
*chset
);
58 static void sysex(struct snd_midi_op
*ops
, void *private, unsigned char *sysex
,
59 int len
, struct snd_midi_channel_set
*chset
);
60 static void all_sounds_off(struct snd_midi_op
*ops
, void *private,
61 struct snd_midi_channel
*chan
);
62 static void all_notes_off(struct snd_midi_op
*ops
, void *private,
63 struct snd_midi_channel
*chan
);
64 static void snd_midi_reset_controllers(struct snd_midi_channel
*chan
);
65 static void reset_all_channels(struct snd_midi_channel_set
*chset
);
69 * Process an event in a driver independent way. This means dealing
70 * with RPN, NRPN, SysEx etc that are defined for common midi applications
71 * such as GM, GS and XG.
72 * There modes that this module will run in are:
73 * Generic MIDI - no interpretation at all, it will just save current values
75 * GM - You can use all gm_ prefixed elements of chan. Controls, RPN, NRPN,
76 * SysEx will be interpreded as defined in General Midi.
77 * GS - You can use all gs_ prefixed elements of chan. Codes for GS will be
79 * XG - You can use all xg_ prefixed elements of chan. Codes for XG will
83 snd_midi_process_event(struct snd_midi_op
*ops
,
84 struct snd_seq_event
*ev
,
85 struct snd_midi_channel_set
*chanset
)
87 struct snd_midi_channel
*chan
;
91 if (ev
== NULL
|| chanset
== NULL
) {
92 pr_debug("ALSA: seq_midi_emul: ev or chanbase NULL (snd_midi_process_event)\n");
95 if (chanset
->channels
== NULL
)
98 if (snd_seq_ev_is_channel_type(ev
)) {
99 dest_channel
= ev
->data
.note
.channel
;
100 if (dest_channel
>= chanset
->max_channels
) {
101 pr_debug("ALSA: seq_midi_emul: dest channel is %d, max is %d\n",
102 dest_channel
, chanset
->max_channels
);
107 chan
= chanset
->channels
+ dest_channel
;
108 drv
= chanset
->private_data
;
110 /* EVENT_NOTE should be processed before queued */
111 if (ev
->type
== SNDRV_SEQ_EVENT_NOTE
)
114 /* Make sure that we don't have a note on that should really be
116 if (ev
->type
== SNDRV_SEQ_EVENT_NOTEON
&& ev
->data
.note
.velocity
== 0)
117 ev
->type
= SNDRV_SEQ_EVENT_NOTEOFF
;
119 /* Make sure the note is within array range */
120 if (ev
->type
== SNDRV_SEQ_EVENT_NOTEON
||
121 ev
->type
== SNDRV_SEQ_EVENT_NOTEOFF
||
122 ev
->type
== SNDRV_SEQ_EVENT_KEYPRESS
) {
123 if (ev
->data
.note
.note
>= 128)
128 case SNDRV_SEQ_EVENT_NOTEON
:
129 if (chan
->note
[ev
->data
.note
.note
] & SNDRV_MIDI_NOTE_ON
) {
131 ops
->note_off(drv
, ev
->data
.note
.note
, 0, chan
);
133 chan
->note
[ev
->data
.note
.note
] = SNDRV_MIDI_NOTE_ON
;
135 ops
->note_on(drv
, ev
->data
.note
.note
, ev
->data
.note
.velocity
, chan
);
137 case SNDRV_SEQ_EVENT_NOTEOFF
:
138 if (! (chan
->note
[ev
->data
.note
.note
] & SNDRV_MIDI_NOTE_ON
))
141 note_off(ops
, drv
, chan
, ev
->data
.note
.note
, ev
->data
.note
.velocity
);
143 case SNDRV_SEQ_EVENT_KEYPRESS
:
145 ops
->key_press(drv
, ev
->data
.note
.note
, ev
->data
.note
.velocity
, chan
);
147 case SNDRV_SEQ_EVENT_CONTROLLER
:
148 do_control(ops
, drv
, chanset
, chan
,
149 ev
->data
.control
.param
, ev
->data
.control
.value
);
151 case SNDRV_SEQ_EVENT_PGMCHANGE
:
152 chan
->midi_program
= ev
->data
.control
.value
;
154 case SNDRV_SEQ_EVENT_PITCHBEND
:
155 chan
->midi_pitchbend
= ev
->data
.control
.value
;
157 ops
->control(drv
, MIDI_CTL_PITCHBEND
, chan
);
159 case SNDRV_SEQ_EVENT_CHANPRESS
:
160 chan
->midi_pressure
= ev
->data
.control
.value
;
162 ops
->control(drv
, MIDI_CTL_CHAN_PRESSURE
, chan
);
164 case SNDRV_SEQ_EVENT_CONTROL14
:
165 /* Best guess is that this is any of the 14 bit controller values */
166 if (ev
->data
.control
.param
< 32) {
167 /* set low part first */
168 chan
->control
[ev
->data
.control
.param
+ 32] =
169 ev
->data
.control
.value
& 0x7f;
170 do_control(ops
, drv
, chanset
, chan
,
171 ev
->data
.control
.param
,
172 ((ev
->data
.control
.value
>>7) & 0x7f));
174 do_control(ops
, drv
, chanset
, chan
,
175 ev
->data
.control
.param
,
176 ev
->data
.control
.value
);
178 case SNDRV_SEQ_EVENT_NONREGPARAM
:
179 /* Break it back into its controller values */
180 chan
->param_type
= SNDRV_MIDI_PARAM_TYPE_NONREGISTERED
;
181 chan
->control
[MIDI_CTL_MSB_DATA_ENTRY
]
182 = (ev
->data
.control
.value
>> 7) & 0x7f;
183 chan
->control
[MIDI_CTL_LSB_DATA_ENTRY
]
184 = ev
->data
.control
.value
& 0x7f;
185 chan
->control
[MIDI_CTL_NONREG_PARM_NUM_MSB
]
186 = (ev
->data
.control
.param
>> 7) & 0x7f;
187 chan
->control
[MIDI_CTL_NONREG_PARM_NUM_LSB
]
188 = ev
->data
.control
.param
& 0x7f;
189 nrpn(ops
, drv
, chan
, chanset
);
191 case SNDRV_SEQ_EVENT_REGPARAM
:
192 /* Break it back into its controller values */
193 chan
->param_type
= SNDRV_MIDI_PARAM_TYPE_REGISTERED
;
194 chan
->control
[MIDI_CTL_MSB_DATA_ENTRY
]
195 = (ev
->data
.control
.value
>> 7) & 0x7f;
196 chan
->control
[MIDI_CTL_LSB_DATA_ENTRY
]
197 = ev
->data
.control
.value
& 0x7f;
198 chan
->control
[MIDI_CTL_REGIST_PARM_NUM_MSB
]
199 = (ev
->data
.control
.param
>> 7) & 0x7f;
200 chan
->control
[MIDI_CTL_REGIST_PARM_NUM_LSB
]
201 = ev
->data
.control
.param
& 0x7f;
202 rpn(ops
, drv
, chan
, chanset
);
204 case SNDRV_SEQ_EVENT_SYSEX
:
205 if ((ev
->flags
& SNDRV_SEQ_EVENT_LENGTH_MASK
) == SNDRV_SEQ_EVENT_LENGTH_VARIABLE
) {
206 unsigned char sysexbuf
[64];
208 len
= snd_seq_expand_var_event(ev
, sizeof(sysexbuf
), sysexbuf
, 1, 0);
210 sysex(ops
, drv
, sysexbuf
, len
, chanset
);
213 case SNDRV_SEQ_EVENT_SONGPOS
:
214 case SNDRV_SEQ_EVENT_SONGSEL
:
215 case SNDRV_SEQ_EVENT_CLOCK
:
216 case SNDRV_SEQ_EVENT_START
:
217 case SNDRV_SEQ_EVENT_CONTINUE
:
218 case SNDRV_SEQ_EVENT_STOP
:
219 case SNDRV_SEQ_EVENT_QFRAME
:
220 case SNDRV_SEQ_EVENT_TEMPO
:
221 case SNDRV_SEQ_EVENT_TIMESIGN
:
222 case SNDRV_SEQ_EVENT_KEYSIGN
:
224 case SNDRV_SEQ_EVENT_SENSING
:
226 case SNDRV_SEQ_EVENT_CLIENT_START
:
227 case SNDRV_SEQ_EVENT_CLIENT_EXIT
:
228 case SNDRV_SEQ_EVENT_CLIENT_CHANGE
:
229 case SNDRV_SEQ_EVENT_PORT_START
:
230 case SNDRV_SEQ_EVENT_PORT_EXIT
:
231 case SNDRV_SEQ_EVENT_PORT_CHANGE
:
232 case SNDRV_SEQ_EVENT_ECHO
:
235 /*pr_debug("ALSA: seq_midi_emul: Unimplemented event %d\n", ev->type);*/
245 note_off(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
249 /* Hold this note until pedal is turned off */
250 chan
->note
[note
] |= SNDRV_MIDI_NOTE_RELEASED
;
251 } else if (chan
->note
[note
] & SNDRV_MIDI_NOTE_SOSTENUTO
) {
252 /* Mark this note as release; it will be turned off when sostenuto
254 chan
->note
[note
] |= SNDRV_MIDI_NOTE_RELEASED
;
256 chan
->note
[note
] = 0;
258 ops
->note_off(drv
, note
, vel
, chan
);
263 * Do all driver independent operations for this controller and pass
264 * events that need to take place immediately to the driver.
267 do_control(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel_set
*chset
,
268 struct snd_midi_channel
*chan
, int control
, int value
)
272 if (control
>= ARRAY_SIZE(chan
->control
))
276 if ((control
>=64 && control
<=69) || (control
>= 80 && control
<= 83)) {
277 /* These are all switches; either off or on so set to 0 or 127 */
278 value
= (value
>= 64)? 127: 0;
280 chan
->control
[control
] = value
;
283 case MIDI_CTL_SUSTAIN
:
285 /* Sustain has been released, turn off held notes */
286 for (i
= 0; i
< 128; i
++) {
287 if (chan
->note
[i
] & SNDRV_MIDI_NOTE_RELEASED
) {
288 chan
->note
[i
] = SNDRV_MIDI_NOTE_OFF
;
290 ops
->note_off(drv
, i
, 0, chan
);
295 case MIDI_CTL_PORTAMENTO
:
297 case MIDI_CTL_SOSTENUTO
:
299 /* Mark each note that is currently held down */
300 for (i
= 0; i
< 128; i
++) {
301 if (chan
->note
[i
] & SNDRV_MIDI_NOTE_ON
)
302 chan
->note
[i
] |= SNDRV_MIDI_NOTE_SOSTENUTO
;
305 /* release all notes that were held */
306 for (i
= 0; i
< 128; i
++) {
307 if (chan
->note
[i
] & SNDRV_MIDI_NOTE_SOSTENUTO
) {
308 chan
->note
[i
] &= ~SNDRV_MIDI_NOTE_SOSTENUTO
;
309 if (chan
->note
[i
] & SNDRV_MIDI_NOTE_RELEASED
) {
310 chan
->note
[i
] = SNDRV_MIDI_NOTE_OFF
;
312 ops
->note_off(drv
, i
, 0, chan
);
318 case MIDI_CTL_MSB_DATA_ENTRY
:
319 chan
->control
[MIDI_CTL_LSB_DATA_ENTRY
] = 0;
320 /* go through here */
321 case MIDI_CTL_LSB_DATA_ENTRY
:
322 if (chan
->param_type
== SNDRV_MIDI_PARAM_TYPE_REGISTERED
)
323 rpn(ops
, drv
, chan
, chset
);
325 nrpn(ops
, drv
, chan
, chset
);
327 case MIDI_CTL_REGIST_PARM_NUM_LSB
:
328 case MIDI_CTL_REGIST_PARM_NUM_MSB
:
329 chan
->param_type
= SNDRV_MIDI_PARAM_TYPE_REGISTERED
;
331 case MIDI_CTL_NONREG_PARM_NUM_LSB
:
332 case MIDI_CTL_NONREG_PARM_NUM_MSB
:
333 chan
->param_type
= SNDRV_MIDI_PARAM_TYPE_NONREGISTERED
;
336 case MIDI_CTL_ALL_SOUNDS_OFF
:
337 all_sounds_off(ops
, drv
, chan
);
340 case MIDI_CTL_ALL_NOTES_OFF
:
341 all_notes_off(ops
, drv
, chan
);
344 case MIDI_CTL_MSB_BANK
:
345 if (chset
->midi_mode
== SNDRV_MIDI_MODE_XG
) {
347 chan
->drum_channel
= 1;
349 chan
->drum_channel
= 0;
352 case MIDI_CTL_LSB_BANK
:
355 case MIDI_CTL_RESET_CONTROLLERS
:
356 snd_midi_reset_controllers(chan
);
359 case MIDI_CTL_SOFT_PEDAL
:
360 case MIDI_CTL_LEGATO_FOOTSWITCH
:
362 case MIDI_CTL_SC1_SOUND_VARIATION
:
363 case MIDI_CTL_SC2_TIMBRE
:
364 case MIDI_CTL_SC3_RELEASE_TIME
:
365 case MIDI_CTL_SC4_ATTACK_TIME
:
366 case MIDI_CTL_SC5_BRIGHTNESS
:
367 case MIDI_CTL_E1_REVERB_DEPTH
:
368 case MIDI_CTL_E2_TREMOLO_DEPTH
:
369 case MIDI_CTL_E3_CHORUS_DEPTH
:
370 case MIDI_CTL_E4_DETUNE_DEPTH
:
371 case MIDI_CTL_E5_PHASER_DEPTH
:
376 ops
->control(drv
, control
, chan
);
383 * initialize the MIDI status
386 snd_midi_channel_set_clear(struct snd_midi_channel_set
*chset
)
390 chset
->midi_mode
= SNDRV_MIDI_MODE_GM
;
391 chset
->gs_master_volume
= 127;
393 for (i
= 0; i
< chset
->max_channels
; i
++) {
394 struct snd_midi_channel
*chan
= chset
->channels
+ i
;
395 memset(chan
->note
, 0, sizeof(chan
->note
));
397 chan
->midi_aftertouch
= 0;
398 chan
->midi_pressure
= 0;
399 chan
->midi_program
= 0;
400 chan
->midi_pitchbend
= 0;
401 snd_midi_reset_controllers(chan
);
402 chan
->gm_rpn_pitch_bend_range
= 256; /* 2 semitones */
403 chan
->gm_rpn_fine_tuning
= 0;
404 chan
->gm_rpn_coarse_tuning
= 0;
407 chan
->drum_channel
= 1;
409 chan
->drum_channel
= 0;
414 * Process a rpn message.
417 rpn(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
418 struct snd_midi_channel_set
*chset
)
423 if (chset
->midi_mode
!= SNDRV_MIDI_MODE_NONE
) {
424 type
= (chan
->control
[MIDI_CTL_REGIST_PARM_NUM_MSB
] << 8) |
425 chan
->control
[MIDI_CTL_REGIST_PARM_NUM_LSB
];
426 val
= (chan
->control
[MIDI_CTL_MSB_DATA_ENTRY
] << 7) |
427 chan
->control
[MIDI_CTL_LSB_DATA_ENTRY
];
430 case 0x0000: /* Pitch bend sensitivity */
431 /* MSB only / 1 semitone per 128 */
432 chan
->gm_rpn_pitch_bend_range
= val
;
435 case 0x0001: /* fine tuning: */
436 /* MSB/LSB, 8192=center, 100/8192 cent step */
437 chan
->gm_rpn_fine_tuning
= val
- 8192;
440 case 0x0002: /* coarse tuning */
441 /* MSB only / 8192=center, 1 semitone per 128 */
442 chan
->gm_rpn_coarse_tuning
= val
- 8192;
445 case 0x7F7F: /* "lock-in" RPN */
450 /* should call nrpn or rpn callback here.. */
454 * Process an nrpn message.
457 nrpn(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
,
458 struct snd_midi_channel_set
*chset
)
460 /* parse XG NRPNs here if possible */
462 ops
->nrpn(drv
, chan
, chset
);
467 * convert channel parameter in GS sysex
470 get_channel(unsigned char cmd
)
482 * Process a sysex message.
485 sysex(struct snd_midi_op
*ops
, void *private, unsigned char *buf
, int len
,
486 struct snd_midi_channel_set
*chset
)
489 static unsigned char gm_on_macro
[] = {
493 static unsigned char xg_on_macro
[] = {
494 0x43,0x10,0x4c,0x00,0x00,0x7e,0x00,
497 * drum channel: XX=0x1?(channel), YY=0x15, ZZ=on/off
498 * reverb mode: XX=0x01, YY=0x30, ZZ=0-7
499 * chorus mode: XX=0x01, YY=0x38, ZZ=0-7
500 * master vol: XX=0x00, YY=0x04, ZZ=0-127
502 static unsigned char gs_pfx_macro
[] = {
503 0x41,0x10,0x42,0x12,0x40,/*XX,YY,ZZ*/
506 int parsed
= SNDRV_MIDI_SYSEX_NOT_PARSED
;
508 if (len
<= 0 || buf
[0] != 0xf0)
510 /* skip first byte */
515 if (len
>= (int)sizeof(gm_on_macro
) &&
516 memcmp(buf
, gm_on_macro
, sizeof(gm_on_macro
)) == 0) {
517 if (chset
->midi_mode
!= SNDRV_MIDI_MODE_GS
&&
518 chset
->midi_mode
!= SNDRV_MIDI_MODE_XG
) {
519 chset
->midi_mode
= SNDRV_MIDI_MODE_GM
;
520 reset_all_channels(chset
);
521 parsed
= SNDRV_MIDI_SYSEX_GM_ON
;
527 memcmp(buf
, gs_pfx_macro
, sizeof(gs_pfx_macro
)) == 0) {
528 if (chset
->midi_mode
!= SNDRV_MIDI_MODE_GS
&&
529 chset
->midi_mode
!= SNDRV_MIDI_MODE_XG
)
530 chset
->midi_mode
= SNDRV_MIDI_MODE_GS
;
532 if (buf
[5] == 0x00 && buf
[6] == 0x7f && buf
[7] == 0x00) {
534 parsed
= SNDRV_MIDI_SYSEX_GS_RESET
;
535 reset_all_channels(chset
);
538 else if ((buf
[5] & 0xf0) == 0x10 && buf
[6] == 0x15) {
540 int p
= get_channel(buf
[5]);
541 if (p
< chset
->max_channels
) {
542 parsed
= SNDRV_MIDI_SYSEX_GS_DRUM_CHANNEL
;
544 chset
->channels
[p
].drum_channel
= 1;
546 chset
->channels
[p
].drum_channel
= 0;
549 } else if ((buf
[5] & 0xf0) == 0x10 && buf
[6] == 0x21) {
551 int p
= get_channel(buf
[5]);
552 if (p
< chset
->max_channels
&&
553 ! chset
->channels
[p
].drum_channel
) {
554 parsed
= SNDRV_MIDI_SYSEX_GS_DRUM_CHANNEL
;
555 chset
->channels
[p
].midi_program
= buf
[7];
558 } else if (buf
[5] == 0x01 && buf
[6] == 0x30) {
560 parsed
= SNDRV_MIDI_SYSEX_GS_REVERB_MODE
;
561 chset
->gs_reverb_mode
= buf
[7];
563 } else if (buf
[5] == 0x01 && buf
[6] == 0x38) {
565 parsed
= SNDRV_MIDI_SYSEX_GS_CHORUS_MODE
;
566 chset
->gs_chorus_mode
= buf
[7];
568 } else if (buf
[5] == 0x00 && buf
[6] == 0x04) {
570 parsed
= SNDRV_MIDI_SYSEX_GS_MASTER_VOLUME
;
571 chset
->gs_master_volume
= buf
[7];
577 else if (len
>= (int)sizeof(xg_on_macro
) &&
578 memcmp(buf
, xg_on_macro
, sizeof(xg_on_macro
)) == 0) {
580 chset
->midi_mode
= SNDRV_MIDI_MODE_XG
;
581 parsed
= SNDRV_MIDI_SYSEX_XG_ON
;
582 /* reset CC#0 for drums */
583 for (i
= 0; i
< chset
->max_channels
; i
++) {
584 if (chset
->channels
[i
].drum_channel
)
585 chset
->channels
[i
].control
[MIDI_CTL_MSB_BANK
] = 127;
587 chset
->channels
[i
].control
[MIDI_CTL_MSB_BANK
] = 0;
592 ops
->sysex(private, buf
- 1, len
+ 1, parsed
, chset
);
599 all_sounds_off(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
)
603 if (! ops
->note_terminate
)
605 for (n
= 0; n
< 128; n
++) {
607 ops
->note_terminate(drv
, n
, chan
);
617 all_notes_off(struct snd_midi_op
*ops
, void *drv
, struct snd_midi_channel
*chan
)
623 for (n
= 0; n
< 128; n
++) {
624 if (chan
->note
[n
] == SNDRV_MIDI_NOTE_ON
)
625 note_off(ops
, drv
, chan
, n
, 0);
630 * Initialise a single midi channel control block.
632 static void snd_midi_channel_init(struct snd_midi_channel
*p
, int n
)
637 memset(p
, 0, sizeof(struct snd_midi_channel
));
641 snd_midi_reset_controllers(p
);
642 p
->gm_rpn_pitch_bend_range
= 256; /* 2 semitones */
643 p
->gm_rpn_fine_tuning
= 0;
644 p
->gm_rpn_coarse_tuning
= 0;
647 p
->drum_channel
= 1; /* Default ch 10 as drums */
651 * Allocate and initialise a set of midi channel control blocks.
653 static struct snd_midi_channel
*snd_midi_channel_init_set(int n
)
655 struct snd_midi_channel
*chan
;
658 chan
= kmalloc(n
* sizeof(struct snd_midi_channel
), GFP_KERNEL
);
660 for (i
= 0; i
< n
; i
++)
661 snd_midi_channel_init(chan
+i
, i
);
668 * reset all midi channels
671 reset_all_channels(struct snd_midi_channel_set
*chset
)
674 for (ch
= 0; ch
< chset
->max_channels
; ch
++) {
675 struct snd_midi_channel
*chan
= chset
->channels
+ ch
;
676 snd_midi_reset_controllers(chan
);
677 chan
->gm_rpn_pitch_bend_range
= 256; /* 2 semitones */
678 chan
->gm_rpn_fine_tuning
= 0;
679 chan
->gm_rpn_coarse_tuning
= 0;
682 chan
->drum_channel
= 1;
684 chan
->drum_channel
= 0;
690 * Allocate and initialise a midi channel set.
692 struct snd_midi_channel_set
*snd_midi_channel_alloc_set(int n
)
694 struct snd_midi_channel_set
*chset
;
696 chset
= kmalloc(sizeof(*chset
), GFP_KERNEL
);
698 chset
->channels
= snd_midi_channel_init_set(n
);
699 chset
->private_data
= NULL
;
700 chset
->max_channels
= n
;
706 * Reset the midi controllers on a particular channel to default values.
708 static void snd_midi_reset_controllers(struct snd_midi_channel
*chan
)
710 memset(chan
->control
, 0, sizeof(chan
->control
));
711 chan
->gm_volume
= 127;
712 chan
->gm_expression
= 127;
718 * Free a midi channel set.
720 void snd_midi_channel_free_set(struct snd_midi_channel_set
*chset
)
724 kfree(chset
->channels
);
728 static int __init
alsa_seq_midi_emul_init(void)
733 static void __exit
alsa_seq_midi_emul_exit(void)
737 module_init(alsa_seq_midi_emul_init
)
738 module_exit(alsa_seq_midi_emul_exit
)
740 EXPORT_SYMBOL(snd_midi_process_event
);
741 EXPORT_SYMBOL(snd_midi_channel_set_clear
);
742 EXPORT_SYMBOL(snd_midi_channel_alloc_set
);
743 EXPORT_SYMBOL(snd_midi_channel_free_set
);