33 #include <linux/slab.h>
34 #include <linux/string.h>
35 #include <linux/module.h>
47 static void note_off(
struct snd_midi_op *ops,
void *drv,
50 static void do_control(
struct snd_midi_op *ops,
void *
private,
58 static void sysex(
struct snd_midi_op *ops,
void *
private,
unsigned char *sysex,
60 static void all_sounds_off(
struct snd_midi_op *ops,
void *
private,
62 static void all_notes_off(
struct snd_midi_op *ops,
void *
private,
92 snd_printd(
"ev or chanbase NULL (snd_midi_process_event)\n");
98 if (snd_seq_ev_is_channel_type(ev)) {
99 dest_channel = ev->
data.
note.channel;
107 chan = chanset->
channels + dest_channel;
148 do_control(ops, drv, chanset, chan,
170 do_control(ops, drv, chanset, chan,
174 do_control(ops, drv, chanset, chan,
189 nrpn(ops, drv, chan, chanset);
202 rpn(ops, drv, chan, chanset);
206 unsigned char sysexbuf[64];
210 sysex(ops, drv, sysexbuf, len, chanset);
258 ops->
note_off(drv, note, vel, chan);
273 if ((control >=64 && control <=69) || (control >= 80 && control <= 83)) {
275 value = (value >= 64)? 127: 0;
283 for (i = 0; i < 128; i++) {
297 for (i = 0; i < 128; i++) {
303 for (i = 0; i < 128; i++) {
304 if (chan->
note[i] & SNDRV_MIDI_NOTE_SOSTENUTO) {
305 chan->
note[
i] &= ~SNDRV_MIDI_NOTE_SOSTENUTO;
306 if (chan->
note[i] & SNDRV_MIDI_NOTE_RELEASED) {
320 rpn(ops, drv, chan, chset);
322 nrpn(ops, drv, chan, chset);
334 all_sounds_off(ops, drv, chan);
338 all_notes_off(ops, drv, chan);
353 snd_midi_reset_controllers(chan);
373 ops->
control(drv, control, chan);
398 snd_midi_reset_controllers(chan);
459 ops->
nrpn(drv, chan, chset);
467 get_channel(
unsigned char cmd)
482 sysex(
struct snd_midi_op *ops,
void *
private,
unsigned char *
buf,
int len,
486 static unsigned char gm_on_macro[] = {
490 static unsigned char xg_on_macro[] = {
491 0x43,0x10,0x4c,0x00,0x00,0x7e,0x00,
499 static unsigned char gs_pfx_macro[] = {
500 0x41,0x10,0x42,0x12,0x40,
505 if (len <= 0 || buf[0] != 0xf0)
512 if (len >= (
int)
sizeof(gm_on_macro) &&
513 memcmp(buf, gm_on_macro,
sizeof(gm_on_macro)) == 0) {
517 reset_all_channels(chset);
524 memcmp(buf, gs_pfx_macro,
sizeof(gs_pfx_macro)) == 0) {
529 if (buf[5] == 0x00 && buf[6] == 0x7f && buf[7] == 0x00) {
532 reset_all_channels(chset);
535 else if ((buf[5] & 0xf0) == 0x10 && buf[6] == 0x15) {
537 int p = get_channel(buf[5]);
538 if (p < chset->max_channels) {
546 }
else if ((buf[5] & 0xf0) == 0x10 && buf[6] == 0x21) {
548 int p = get_channel(buf[5]);
549 if (p < chset->max_channels &&
550 ! chset->
channels[p].drum_channel) {
552 chset->
channels[
p].midi_program = buf[7];
555 }
else if (buf[5] == 0x01 && buf[6] == 0x30) {
560 }
else if (buf[5] == 0x01 && buf[6] == 0x38) {
565 }
else if (buf[5] == 0x00 && buf[6] == 0x04) {
574 else if (len >= (
int)
sizeof(xg_on_macro) &&
575 memcmp(buf, xg_on_macro,
sizeof(xg_on_macro)) == 0) {
581 if (chset->
channels[i].drum_channel)
589 ops->
sysex(
private, buf - 1, len + 1, parsed, chset);
602 for (n = 0; n < 128; n++) {
620 for (n = 0; n < 128; n++) {
622 note_off(ops, drv, chan, n, 0);
638 snd_midi_reset_controllers(p);
657 for (i = 0; i <
n; i++)
658 snd_midi_channel_init(chan+i, i);
673 snd_midi_reset_controllers(chan);
695 chset->
channels = snd_midi_channel_init_set(n);
708 chan->gm_volume = 127;
709 chan->gm_expression = 127;
725 static int __init alsa_seq_midi_emul_init(
void)
730 static void __exit alsa_seq_midi_emul_exit(
void)