1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) by Uros Bizjak <uros@kss-loka.si>
5 * Midi synth routines for OPL2/OPL3/OPL4 FM
11 #include "opl3_voice.h"
12 #include <sound/asoundef.h>
15 #define opl3_dbg(opl3, fmt, ...) \
16 dev_dbg(((struct snd_opl3 *)(opl3))->card->dev, fmt, ##__VA_ARGS__)
18 #define opl3_dbg(opl3, fmt, ...) do {} while (0)
21 static void snd_opl3_note_off_unsafe(void *p, int note, int vel,
22 struct snd_midi_channel *chan);
24 * The next table looks magical, but it certainly is not. Its values have
25 * been calculated as table[i]=8*log(i/64)/log(2) with an obvious exception
26 * for i=0. This log-table converts a linear volume-scaling (0..127) to a
27 * logarithmic scaling as present in the FM-synthesizer chips. so : Volume
28 * 64 = 0 db = relative volume 0 and: Volume 32 = -6 db = relative
29 * volume -8 it was implemented as a table because it is only 128 bytes and
30 * it saves a lot of log() calculations. (Rob Hooft <hooft@chem.ruu.nl>)
33 static const char opl3_volume_table[128] =
35 -63, -48, -40, -35, -32, -29, -27, -26,
36 -24, -23, -21, -20, -19, -18, -18, -17,
37 -16, -15, -15, -14, -13, -13, -12, -12,
38 -11, -11, -10, -10, -10, -9, -9, -8,
39 -8, -8, -7, -7, -7, -6, -6, -6,
40 -5, -5, -5, -5, -4, -4, -4, -4,
41 -3, -3, -3, -3, -2, -2, -2, -2,
42 -2, -1, -1, -1, -1, 0, 0, 0,
43 0, 0, 0, 1, 1, 1, 1, 1,
44 1, 2, 2, 2, 2, 2, 2, 2,
45 3, 3, 3, 3, 3, 3, 3, 4,
46 4, 4, 4, 4, 4, 4, 4, 5,
47 5, 5, 5, 5, 5, 5, 5, 5,
48 6, 6, 6, 6, 6, 6, 6, 6,
49 6, 7, 7, 7, 7, 7, 7, 7,
50 7, 7, 7, 8, 8, 8, 8, 8
53 void snd_opl3_calc_volume(unsigned char *volbyte, int vel,
54 struct snd_midi_channel *chan)
56 int oldvol, newvol, n;
59 volume = (vel * chan->gm_volume * chan->gm_expression) / (127*127);
63 oldvol = OPL3_TOTAL_LEVEL_MASK - (*volbyte & OPL3_TOTAL_LEVEL_MASK);
65 newvol = opl3_volume_table[volume] + oldvol;
66 if (newvol > OPL3_TOTAL_LEVEL_MASK)
67 newvol = OPL3_TOTAL_LEVEL_MASK;
71 n = OPL3_TOTAL_LEVEL_MASK - (newvol & OPL3_TOTAL_LEVEL_MASK);
73 *volbyte = (*volbyte & OPL3_KSL_MASK) | (n & OPL3_TOTAL_LEVEL_MASK);
77 * Converts the note frequency to block and fnum values for the FM chip
79 static const short opl3_note_table[16] =
81 305, 323, /* for pitch bending, -2 semitones */
82 343, 363, 385, 408, 432, 458, 485, 514, 544, 577, 611, 647,
83 686, 726 /* for pitch bending, +2 semitones */
86 static void snd_opl3_calc_pitch(unsigned char *fnum, unsigned char *blocknum,
87 int note, struct snd_midi_channel *chan)
89 int block = ((note / 12) & 0x07) - 1;
90 int idx = (note % 12) + 2;
93 if (chan->midi_pitchbend) {
94 int pitchbend = chan->midi_pitchbend;
97 if (pitchbend < -0x2000)
99 if (pitchbend > 0x1FFF)
102 segment = pitchbend / 0x1000;
103 freq = opl3_note_table[idx+segment];
104 freq += ((opl3_note_table[idx+segment+1] - freq) *
105 (pitchbend % 0x1000)) / 0x1000;
107 freq = opl3_note_table[idx];
110 *fnum = (unsigned char) freq;
111 *blocknum = ((freq >> 8) & OPL3_FNUM_HIGH_MASK) |
112 ((block << 2) & OPL3_BLOCKNUM_MASK);
117 static void debug_alloc(struct snd_opl3 *opl3, char *s, int voice)
120 const char *str = "x.24";
121 char buf[MAX_OPL3_VOICES + 1];
123 for (i = 0; i < opl3->max_voices; i++)
124 buf[i] = str[opl3->voices[i].state + 1];
126 dev_dbg(opl3->card->dev, "time %.5i: %s [%.2i]: %s\n",
127 opl3->use_time, s, voice, buf);
132 * Get a FM voice (channel) to play a note on.
134 static int opl3_get_voice(struct snd_opl3 *opl3, int instr_4op,
135 struct snd_midi_channel *chan) {
136 int chan_4op_1; /* first voice for 4op instrument */
137 int chan_4op_2; /* second voice for 4op instrument */
139 struct snd_opl3_voice *vp, *vp2;
140 unsigned int voice_time;
144 char *alloc_type[3] = { "FREE ", "CHEAP ", "EXPENSIVE" };
147 /* This is our "allocation cost" table */
149 FREE = 0, CHEAP, EXPENSIVE, END
152 /* Keeps track of what we are finding */
159 for (i = 0; i < END; i++) {
160 best[i].time = (unsigned int)(-1); /* XXX MAX_?INT really */
164 /* Look through all the channels for the most suitable. */
165 for (i = 0; i < opl3->max_voices; i++) {
166 vp = &opl3->voices[i];
168 if (vp->state == SNDRV_OPL3_ST_NOT_AVAIL)
169 /* skip unavailable channels, allocated by
170 drum voices or by bounded 4op voices) */
173 voice_time = vp->time;
176 chan_4op_1 = ((i < 3) || (i > 8 && i < 12));
177 chan_4op_2 = ((i > 2 && i < 6) || (i > 11 && i < 15));
179 /* allocate 4op voice */
180 /* skip channels unavailable to 4op instrument */
185 /* kill one voice, CHEAP */
187 /* get state of bounded 2op channel
188 to be allocated for 4op instrument */
189 vp2 = &opl3->voices[i + 3];
190 if (vp2->state == SNDRV_OPL3_ST_ON_2OP) {
191 /* kill two voices, EXPENSIVE */
193 voice_time = max(voice_time, vp2->time);
196 /* allocate 2op voice */
197 if ((chan_4op_1) || (chan_4op_2))
198 /* use bounded channels for 2op, CHEAP */
201 /* kill one voice on 2op channel, CHEAP */
203 /* raise kill cost to EXPENSIVE for all channels */
207 if (voice_time < bp->time) {
208 bp->time = voice_time;
213 for (i = 0; i < END; i++) {
214 if (best[i].voice >= 0) {
216 dev_dbg(opl3->card->dev,
217 "%s %iop allocation on voice %i\n",
218 alloc_type[i], instr_4op ? 4 : 2,
221 return best[i].voice;
228 /* ------------------------------ */
231 * System timer interrupt function
233 void snd_opl3_timer_func(struct timer_list *t)
236 struct snd_opl3 *opl3 = from_timer(opl3, t, tlist);
241 spin_lock_irqsave(&opl3->voice_lock, flags);
242 for (i = 0; i < opl3->max_voices; i++) {
243 struct snd_opl3_voice *vp = &opl3->voices[i];
244 if (vp->state > 0 && vp->note_off_check) {
245 if (vp->note_off == jiffies)
246 snd_opl3_note_off_unsafe(opl3, vp->note, 0,
252 spin_unlock_irqrestore(&opl3->voice_lock, flags);
254 spin_lock_irqsave(&opl3->sys_timer_lock, flags);
256 mod_timer(&opl3->tlist, jiffies + 1); /* invoke again */
258 opl3->sys_timer_status = 0;
259 spin_unlock_irqrestore(&opl3->sys_timer_lock, flags);
265 static void snd_opl3_start_timer(struct snd_opl3 *opl3)
268 spin_lock_irqsave(&opl3->sys_timer_lock, flags);
269 if (! opl3->sys_timer_status) {
270 mod_timer(&opl3->tlist, jiffies + 1);
271 opl3->sys_timer_status = 1;
273 spin_unlock_irqrestore(&opl3->sys_timer_lock, flags);
276 /* ------------------------------ */
279 static const int snd_opl3_oss_map[MAX_OPL3_VOICES] = {
280 0, 1, 2, 9, 10, 11, 6, 7, 8, 15, 16, 17, 3, 4 ,5, 12, 13, 14
286 void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
288 struct snd_opl3 *opl3;
292 struct snd_opl3_voice *vp, *vp2;
293 unsigned short connect_mask;
294 unsigned char connection;
295 unsigned char vol_op[4];
299 unsigned short reg_side;
300 unsigned char op_offset;
301 unsigned char voice_offset;
302 unsigned short opl3_reg;
303 unsigned char reg_val;
304 unsigned char prg, bank;
307 unsigned char fnum, blocknum;
310 struct fm_patch *patch;
311 struct fm_instrument *fm;
316 opl3_dbg(opl3, "Note on, ch %i, inst %i, note %i, vel %i\n",
317 chan->number, chan->midi_program, note, vel);
319 /* in SYNTH mode, application takes care of voices */
320 /* in SEQ mode, drum voice numbers are notes on drum channel */
321 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
322 if (chan->drum_channel) {
323 /* percussion instruments are located in bank 128 */
327 bank = chan->gm_bank_select;
328 prg = chan->midi_program;
331 /* Prepare for OSS mode */
332 if (chan->number >= MAX_OPL3_VOICES)
335 /* OSS instruments are located in bank 127 */
337 prg = chan->midi_program;
340 spin_lock_irqsave(&opl3->voice_lock, flags);
342 if (use_internal_drums) {
343 snd_opl3_drum_switch(opl3, note, vel, 1, chan);
344 spin_unlock_irqrestore(&opl3->voice_lock, flags);
349 patch = snd_opl3_find_patch(opl3, prg, bank, 0);
351 spin_unlock_irqrestore(&opl3->voice_lock, flags);
356 switch (patch->type) {
361 if (opl3->hardware >= OPL3_HW_OPL3) {
367 spin_unlock_irqrestore(&opl3->voice_lock, flags);
370 opl3_dbg(opl3, " --> OPL%i instrument: %s\n",
371 instr_4op ? 3 : 2, patch->name);
372 /* in SYNTH mode, application takes care of voices */
373 /* in SEQ mode, allocate voice on free OPL3 channel */
374 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
375 voice = opl3_get_voice(opl3, instr_4op, chan);
377 /* remap OSS voice */
378 voice = snd_opl3_oss_map[chan->number];
382 spin_unlock_irqrestore(&opl3->voice_lock, flags);
386 if (voice < MAX_OPL2_VOICES) {
387 /* Left register block for voices 0 .. 8 */
388 reg_side = OPL3_LEFT;
389 voice_offset = voice;
390 connect_mask = (OPL3_LEFT_4OP_0 << voice_offset) & 0x07;
392 /* Right register block for voices 9 .. 17 */
393 reg_side = OPL3_RIGHT;
394 voice_offset = voice - MAX_OPL2_VOICES;
395 connect_mask = (OPL3_RIGHT_4OP_0 << voice_offset) & 0x38;
398 /* kill voice on channel */
399 vp = &opl3->voices[voice];
401 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
402 reg_val = vp->keyon_reg & ~OPL3_KEYON_BIT;
403 opl3->command(opl3, opl3_reg, reg_val);
406 vp2 = &opl3->voices[voice + 3];
407 if (vp2->state > 0) {
408 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK +
410 reg_val = vp->keyon_reg & ~OPL3_KEYON_BIT;
411 opl3->command(opl3, opl3_reg, reg_val);
415 /* set connection register */
417 if ((opl3->connection_reg ^ connect_mask) & connect_mask) {
418 opl3->connection_reg |= connect_mask;
419 /* set connection bit */
420 opl3_reg = OPL3_RIGHT | OPL3_REG_CONNECTION_SELECT;
421 opl3->command(opl3, opl3_reg, opl3->connection_reg);
424 if ((opl3->connection_reg ^ ~connect_mask) & connect_mask) {
425 opl3->connection_reg &= ~connect_mask;
426 /* clear connection bit */
427 opl3_reg = OPL3_RIGHT | OPL3_REG_CONNECTION_SELECT;
428 opl3->command(opl3, opl3_reg, opl3->connection_reg);
432 opl3_dbg(opl3, " --> setting OPL3 connection: 0x%x\n",
433 opl3->connection_reg);
435 * calculate volume depending on connection
436 * between FM operators (see include/opl3.h)
438 for (i = 0; i < (instr_4op ? 4 : 2); i++)
439 vol_op[i] = fm->op[i].ksl_level;
441 connection = fm->feedback_connection[0] & 0x01;
444 connection |= fm->feedback_connection[1] & 0x01;
446 snd_opl3_calc_volume(&vol_op[3], vel, chan);
447 switch (connection) {
449 snd_opl3_calc_volume(&vol_op[2], vel, chan);
452 snd_opl3_calc_volume(&vol_op[0], vel, chan);
455 snd_opl3_calc_volume(&vol_op[1], vel, chan);
458 snd_opl3_calc_volume(&vol_op[1], vel, chan);
460 snd_opl3_calc_volume(&vol_op[0], vel, chan);
463 /* Program the FM voice characteristics */
464 for (i = 0; i < (instr_4op ? 4 : 2); i++) {
465 opl3_dbg(opl3, " --> programming operator %i\n", i);
466 op_offset = snd_opl3_regmap[voice_offset][i];
468 /* Set OPL3 AM_VIB register of requested voice/operator */
469 reg_val = fm->op[i].am_vib;
470 opl3_reg = reg_side | (OPL3_REG_AM_VIB + op_offset);
471 opl3->command(opl3, opl3_reg, reg_val);
473 /* Set OPL3 KSL_LEVEL register of requested voice/operator */
475 opl3_reg = reg_side | (OPL3_REG_KSL_LEVEL + op_offset);
476 opl3->command(opl3, opl3_reg, reg_val);
478 /* Set OPL3 ATTACK_DECAY register of requested voice/operator */
479 reg_val = fm->op[i].attack_decay;
480 opl3_reg = reg_side | (OPL3_REG_ATTACK_DECAY + op_offset);
481 opl3->command(opl3, opl3_reg, reg_val);
483 /* Set OPL3 SUSTAIN_RELEASE register of requested voice/operator */
484 reg_val = fm->op[i].sustain_release;
485 opl3_reg = reg_side | (OPL3_REG_SUSTAIN_RELEASE + op_offset);
486 opl3->command(opl3, opl3_reg, reg_val);
488 /* Select waveform */
489 reg_val = fm->op[i].wave_select;
490 opl3_reg = reg_side | (OPL3_REG_WAVE_SELECT + op_offset);
491 opl3->command(opl3, opl3_reg, reg_val);
494 /* Set operator feedback and 2op inter-operator connection */
495 reg_val = fm->feedback_connection[0];
496 /* Set output voice connection */
497 reg_val |= OPL3_STEREO_BITS;
498 if (chan->gm_pan < 43)
499 reg_val &= ~OPL3_VOICE_TO_RIGHT;
500 if (chan->gm_pan > 85)
501 reg_val &= ~OPL3_VOICE_TO_LEFT;
502 opl3_reg = reg_side | (OPL3_REG_FEEDBACK_CONNECTION + voice_offset);
503 opl3->command(opl3, opl3_reg, reg_val);
506 /* Set 4op inter-operator connection */
507 reg_val = fm->feedback_connection[1] & OPL3_CONNECTION_BIT;
508 /* Set output voice connection */
509 reg_val |= OPL3_STEREO_BITS;
510 if (chan->gm_pan < 43)
511 reg_val &= ~OPL3_VOICE_TO_RIGHT;
512 if (chan->gm_pan > 85)
513 reg_val &= ~OPL3_VOICE_TO_LEFT;
514 opl3_reg = reg_side | (OPL3_REG_FEEDBACK_CONNECTION +
516 opl3->command(opl3, opl3_reg, reg_val);
520 * Special treatment of percussion notes for fm:
521 * Requested pitch is really program, and pitch for
522 * device is whatever was specified in the patch library.
527 * use transpose if defined in patch library
530 note += (fm->trnsps - 64);
532 snd_opl3_calc_pitch(&fnum, &blocknum, note, chan);
534 /* Set OPL3 FNUM_LOW register of requested voice */
535 opl3_reg = reg_side | (OPL3_REG_FNUM_LOW + voice_offset);
536 opl3->command(opl3, opl3_reg, fnum);
538 opl3->voices[voice].keyon_reg = blocknum;
540 /* Set output sound flag */
541 blocknum |= OPL3_KEYON_BIT;
543 opl3_dbg(opl3, " --> trigger voice %i\n", voice);
544 /* Set OPL3 KEYON_BLOCK register of requested voice */
545 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
546 opl3->command(opl3, opl3_reg, blocknum);
548 /* kill note after fixed duration (in centiseconds) */
550 opl3->voices[voice].note_off = jiffies +
551 (fm->fix_dur * HZ) / 100;
552 snd_opl3_start_timer(opl3);
553 opl3->voices[voice].note_off_check = 1;
555 opl3->voices[voice].note_off_check = 0;
557 /* get extra pgm, but avoid possible loops */
558 extra_prg = (extra_prg) ? 0 : fm->modes;
560 /* do the bookkeeping */
561 vp->time = opl3->use_time++;
566 vp->state = SNDRV_OPL3_ST_ON_4OP;
568 vp2 = &opl3->voices[voice + 3];
569 vp2->time = opl3->use_time++;
572 vp2->state = SNDRV_OPL3_ST_NOT_AVAIL;
574 if (vp->state == SNDRV_OPL3_ST_ON_4OP) {
575 /* 4op killed by 2op, release bounded voice */
576 vp2 = &opl3->voices[voice + 3];
577 vp2->time = opl3->use_time++;
578 vp2->state = SNDRV_OPL3_ST_OFF;
580 vp->state = SNDRV_OPL3_ST_ON_2OP;
584 debug_alloc(opl3, "note on ", voice);
587 /* allocate extra program if specified in patch library */
589 if (extra_prg > 128) {
591 /* percussions start at 35 */
592 prg = extra_prg - 128 + 35 - 1;
597 opl3_dbg(opl3, " *** allocating extra program\n");
600 spin_unlock_irqrestore(&opl3->voice_lock, flags);
603 static void snd_opl3_kill_voice(struct snd_opl3 *opl3, int voice)
605 unsigned short reg_side;
606 unsigned char voice_offset;
607 unsigned short opl3_reg;
609 struct snd_opl3_voice *vp, *vp2;
611 if (snd_BUG_ON(voice >= MAX_OPL3_VOICES))
614 vp = &opl3->voices[voice];
615 if (voice < MAX_OPL2_VOICES) {
616 /* Left register block for voices 0 .. 8 */
617 reg_side = OPL3_LEFT;
618 voice_offset = voice;
620 /* Right register block for voices 9 .. 17 */
621 reg_side = OPL3_RIGHT;
622 voice_offset = voice - MAX_OPL2_VOICES;
626 opl3_dbg(opl3, " --> kill voice %i\n", voice);
627 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
628 /* clear Key ON bit */
629 opl3->command(opl3, opl3_reg, vp->keyon_reg);
631 /* do the bookkeeping */
632 vp->time = opl3->use_time++;
634 if (vp->state == SNDRV_OPL3_ST_ON_4OP) {
635 vp2 = &opl3->voices[voice + 3];
637 vp2->time = opl3->use_time++;
638 vp2->state = SNDRV_OPL3_ST_OFF;
640 vp->state = SNDRV_OPL3_ST_OFF;
642 debug_alloc(opl3, "note off", voice);
648 * Release a note in response to a midi note off.
650 static void snd_opl3_note_off_unsafe(void *p, int note, int vel,
651 struct snd_midi_channel *chan)
653 struct snd_opl3 *opl3;
656 struct snd_opl3_voice *vp;
660 opl3_dbg(opl3, "Note off, ch %i, inst %i, note %i\n",
661 chan->number, chan->midi_program, note);
663 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
664 if (chan->drum_channel && use_internal_drums) {
665 snd_opl3_drum_switch(opl3, note, vel, 0, chan);
668 /* this loop will hopefully kill all extra voices, because
669 they are grouped by the same channel and note values */
670 for (voice = 0; voice < opl3->max_voices; voice++) {
671 vp = &opl3->voices[voice];
672 if (vp->state > 0 && vp->chan == chan && vp->note == note) {
673 snd_opl3_kill_voice(opl3, voice);
677 /* remap OSS voices */
678 if (chan->number < MAX_OPL3_VOICES) {
679 voice = snd_opl3_oss_map[chan->number];
680 snd_opl3_kill_voice(opl3, voice);
685 void snd_opl3_note_off(void *p, int note, int vel,
686 struct snd_midi_channel *chan)
688 struct snd_opl3 *opl3 = p;
691 spin_lock_irqsave(&opl3->voice_lock, flags);
692 snd_opl3_note_off_unsafe(p, note, vel, chan);
693 spin_unlock_irqrestore(&opl3->voice_lock, flags);
697 * key pressure change
699 void snd_opl3_key_press(void *p, int note, int vel, struct snd_midi_channel *chan)
701 opl3_dbg(p, "Key pressure, ch#: %i, inst#: %i\n",
702 chan->number, chan->midi_program);
708 void snd_opl3_terminate_note(void *p, int note, struct snd_midi_channel *chan)
710 opl3_dbg(p, "Terminate note, ch#: %i, inst#: %i\n",
711 chan->number, chan->midi_program);
714 static void snd_opl3_update_pitch(struct snd_opl3 *opl3, int voice)
716 unsigned short reg_side;
717 unsigned char voice_offset;
718 unsigned short opl3_reg;
720 unsigned char fnum, blocknum;
722 struct snd_opl3_voice *vp;
724 if (snd_BUG_ON(voice >= MAX_OPL3_VOICES))
727 vp = &opl3->voices[voice];
728 if (vp->chan == NULL)
729 return; /* not allocated? */
731 if (voice < MAX_OPL2_VOICES) {
732 /* Left register block for voices 0 .. 8 */
733 reg_side = OPL3_LEFT;
734 voice_offset = voice;
736 /* Right register block for voices 9 .. 17 */
737 reg_side = OPL3_RIGHT;
738 voice_offset = voice - MAX_OPL2_VOICES;
741 snd_opl3_calc_pitch(&fnum, &blocknum, vp->note, vp->chan);
743 /* Set OPL3 FNUM_LOW register of requested voice */
744 opl3_reg = reg_side | (OPL3_REG_FNUM_LOW + voice_offset);
745 opl3->command(opl3, opl3_reg, fnum);
747 vp->keyon_reg = blocknum;
749 /* Set output sound flag */
750 blocknum |= OPL3_KEYON_BIT;
752 /* Set OPL3 KEYON_BLOCK register of requested voice */
753 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
754 opl3->command(opl3, opl3_reg, blocknum);
756 vp->time = opl3->use_time++;
760 * Update voice pitch controller
762 static void snd_opl3_pitch_ctrl(struct snd_opl3 *opl3, struct snd_midi_channel *chan)
765 struct snd_opl3_voice *vp;
769 spin_lock_irqsave(&opl3->voice_lock, flags);
771 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
772 for (voice = 0; voice < opl3->max_voices; voice++) {
773 vp = &opl3->voices[voice];
774 if (vp->state > 0 && vp->chan == chan) {
775 snd_opl3_update_pitch(opl3, voice);
779 /* remap OSS voices */
780 if (chan->number < MAX_OPL3_VOICES) {
781 voice = snd_opl3_oss_map[chan->number];
782 snd_opl3_update_pitch(opl3, voice);
785 spin_unlock_irqrestore(&opl3->voice_lock, flags);
789 * Deal with a controller type event. This includes all types of
790 * control events, not just the midi controllers
792 void snd_opl3_control(void *p, int type, struct snd_midi_channel *chan)
794 struct snd_opl3 *opl3;
797 opl3_dbg(opl3, "Controller, TYPE = %i, ch#: %i, inst#: %i\n",
798 type, chan->number, chan->midi_program);
801 case MIDI_CTL_MSB_MODWHEEL:
802 if (chan->control[MIDI_CTL_MSB_MODWHEEL] > 63)
803 opl3->drum_reg |= OPL3_VIBRATO_DEPTH;
805 opl3->drum_reg &= ~OPL3_VIBRATO_DEPTH;
806 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION,
809 case MIDI_CTL_E2_TREMOLO_DEPTH:
810 if (chan->control[MIDI_CTL_E2_TREMOLO_DEPTH] > 63)
811 opl3->drum_reg |= OPL3_TREMOLO_DEPTH;
813 opl3->drum_reg &= ~OPL3_TREMOLO_DEPTH;
814 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION,
817 case MIDI_CTL_PITCHBEND:
818 snd_opl3_pitch_ctrl(opl3, chan);
826 void snd_opl3_nrpn(void *p, struct snd_midi_channel *chan,
827 struct snd_midi_channel_set *chset)
829 opl3_dbg(p, "NRPN, ch#: %i, inst#: %i\n",
830 chan->number, chan->midi_program);
836 void snd_opl3_sysex(void *p, unsigned char *buf, int len,
837 int parsed, struct snd_midi_channel_set *chset)
839 opl3_dbg(p, "SYSEX\n");