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>
14 static void snd_opl3_note_off_unsafe(void *p, int note, int vel,
15 struct snd_midi_channel *chan);
17 * The next table looks magical, but it certainly is not. Its values have
18 * been calculated as table[i]=8*log(i/64)/log(2) with an obvious exception
19 * for i=0. This log-table converts a linear volume-scaling (0..127) to a
20 * logarithmic scaling as present in the FM-synthesizer chips. so : Volume
21 * 64 = 0 db = relative volume 0 and: Volume 32 = -6 db = relative
22 * volume -8 it was implemented as a table because it is only 128 bytes and
23 * it saves a lot of log() calculations. (Rob Hooft <hooft@chem.ruu.nl>)
26 static const char opl3_volume_table[128] =
28 -63, -48, -40, -35, -32, -29, -27, -26,
29 -24, -23, -21, -20, -19, -18, -18, -17,
30 -16, -15, -15, -14, -13, -13, -12, -12,
31 -11, -11, -10, -10, -10, -9, -9, -8,
32 -8, -8, -7, -7, -7, -6, -6, -6,
33 -5, -5, -5, -5, -4, -4, -4, -4,
34 -3, -3, -3, -3, -2, -2, -2, -2,
35 -2, -1, -1, -1, -1, 0, 0, 0,
36 0, 0, 0, 1, 1, 1, 1, 1,
37 1, 2, 2, 2, 2, 2, 2, 2,
38 3, 3, 3, 3, 3, 3, 3, 4,
39 4, 4, 4, 4, 4, 4, 4, 5,
40 5, 5, 5, 5, 5, 5, 5, 5,
41 6, 6, 6, 6, 6, 6, 6, 6,
42 6, 7, 7, 7, 7, 7, 7, 7,
43 7, 7, 7, 8, 8, 8, 8, 8
46 void snd_opl3_calc_volume(unsigned char *volbyte, int vel,
47 struct snd_midi_channel *chan)
49 int oldvol, newvol, n;
52 volume = (vel * chan->gm_volume * chan->gm_expression) / (127*127);
56 oldvol = OPL3_TOTAL_LEVEL_MASK - (*volbyte & OPL3_TOTAL_LEVEL_MASK);
58 newvol = opl3_volume_table[volume] + oldvol;
59 if (newvol > OPL3_TOTAL_LEVEL_MASK)
60 newvol = OPL3_TOTAL_LEVEL_MASK;
64 n = OPL3_TOTAL_LEVEL_MASK - (newvol & OPL3_TOTAL_LEVEL_MASK);
66 *volbyte = (*volbyte & OPL3_KSL_MASK) | (n & OPL3_TOTAL_LEVEL_MASK);
70 * Converts the note frequency to block and fnum values for the FM chip
72 static const short opl3_note_table[16] =
74 305, 323, /* for pitch bending, -2 semitones */
75 343, 363, 385, 408, 432, 458, 485, 514, 544, 577, 611, 647,
76 686, 726 /* for pitch bending, +2 semitones */
79 static void snd_opl3_calc_pitch(unsigned char *fnum, unsigned char *blocknum,
80 int note, struct snd_midi_channel *chan)
82 int block = ((note / 12) & 0x07) - 1;
83 int idx = (note % 12) + 2;
86 if (chan->midi_pitchbend) {
87 int pitchbend = chan->midi_pitchbend;
90 if (pitchbend < -0x2000)
92 if (pitchbend > 0x1FFF)
95 segment = pitchbend / 0x1000;
96 freq = opl3_note_table[idx+segment];
97 freq += ((opl3_note_table[idx+segment+1] - freq) *
98 (pitchbend % 0x1000)) / 0x1000;
100 freq = opl3_note_table[idx];
103 *fnum = (unsigned char) freq;
104 *blocknum = ((freq >> 8) & OPL3_FNUM_HIGH_MASK) |
105 ((block << 2) & OPL3_BLOCKNUM_MASK);
110 static void debug_alloc(struct snd_opl3 *opl3, char *s, int voice) {
114 printk(KERN_DEBUG "time %.5i: %s [%.2i]: ", opl3->use_time, s, voice);
115 for (i = 0; i < opl3->max_voices; i++)
116 printk(KERN_CONT "%c", *(str + opl3->voices[i].state + 1));
117 printk(KERN_CONT "\n");
122 * Get a FM voice (channel) to play a note on.
124 static int opl3_get_voice(struct snd_opl3 *opl3, int instr_4op,
125 struct snd_midi_channel *chan) {
126 int chan_4op_1; /* first voice for 4op instrument */
127 int chan_4op_2; /* second voice for 4op instrument */
129 struct snd_opl3_voice *vp, *vp2;
130 unsigned int voice_time;
134 char *alloc_type[3] = { "FREE ", "CHEAP ", "EXPENSIVE" };
137 /* This is our "allocation cost" table */
139 FREE = 0, CHEAP, EXPENSIVE, END
142 /* Keeps track of what we are finding */
149 for (i = 0; i < END; i++) {
150 best[i].time = (unsigned int)(-1); /* XXX MAX_?INT really */
154 /* Look through all the channels for the most suitable. */
155 for (i = 0; i < opl3->max_voices; i++) {
156 vp = &opl3->voices[i];
158 if (vp->state == SNDRV_OPL3_ST_NOT_AVAIL)
159 /* skip unavailable channels, allocated by
160 drum voices or by bounded 4op voices) */
163 voice_time = vp->time;
166 chan_4op_1 = ((i < 3) || (i > 8 && i < 12));
167 chan_4op_2 = ((i > 2 && i < 6) || (i > 11 && i < 15));
169 /* allocate 4op voice */
170 /* skip channels unavailable to 4op instrument */
175 /* kill one voice, CHEAP */
177 /* get state of bounded 2op channel
178 to be allocated for 4op instrument */
179 vp2 = &opl3->voices[i + 3];
180 if (vp2->state == SNDRV_OPL3_ST_ON_2OP) {
181 /* kill two voices, EXPENSIVE */
183 voice_time = max(voice_time, vp2->time);
186 /* allocate 2op voice */
187 if ((chan_4op_1) || (chan_4op_2))
188 /* use bounded channels for 2op, CHEAP */
191 /* kill one voice on 2op channel, CHEAP */
193 /* raise kill cost to EXPENSIVE for all channels */
197 if (voice_time < bp->time) {
198 bp->time = voice_time;
203 for (i = 0; i < END; i++) {
204 if (best[i].voice >= 0) {
206 printk(KERN_DEBUG "%s %iop allocation on voice %i\n",
207 alloc_type[i], instr_4op ? 4 : 2,
210 return best[i].voice;
217 /* ------------------------------ */
220 * System timer interrupt function
222 void snd_opl3_timer_func(struct timer_list *t)
225 struct snd_opl3 *opl3 = from_timer(opl3, t, tlist);
230 spin_lock_irqsave(&opl3->voice_lock, flags);
231 for (i = 0; i < opl3->max_voices; i++) {
232 struct snd_opl3_voice *vp = &opl3->voices[i];
233 if (vp->state > 0 && vp->note_off_check) {
234 if (vp->note_off == jiffies)
235 snd_opl3_note_off_unsafe(opl3, vp->note, 0,
241 spin_unlock_irqrestore(&opl3->voice_lock, flags);
243 spin_lock_irqsave(&opl3->sys_timer_lock, flags);
245 mod_timer(&opl3->tlist, jiffies + 1); /* invoke again */
247 opl3->sys_timer_status = 0;
248 spin_unlock_irqrestore(&opl3->sys_timer_lock, flags);
254 static void snd_opl3_start_timer(struct snd_opl3 *opl3)
257 spin_lock_irqsave(&opl3->sys_timer_lock, flags);
258 if (! opl3->sys_timer_status) {
259 mod_timer(&opl3->tlist, jiffies + 1);
260 opl3->sys_timer_status = 1;
262 spin_unlock_irqrestore(&opl3->sys_timer_lock, flags);
265 /* ------------------------------ */
268 static const int snd_opl3_oss_map[MAX_OPL3_VOICES] = {
269 0, 1, 2, 9, 10, 11, 6, 7, 8, 15, 16, 17, 3, 4 ,5, 12, 13, 14
275 void snd_opl3_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
277 struct snd_opl3 *opl3;
281 struct snd_opl3_voice *vp, *vp2;
282 unsigned short connect_mask;
283 unsigned char connection;
284 unsigned char vol_op[4];
288 unsigned short reg_side;
289 unsigned char op_offset;
290 unsigned char voice_offset;
291 unsigned short opl3_reg;
292 unsigned char reg_val;
293 unsigned char prg, bank;
296 unsigned char fnum, blocknum;
299 struct fm_patch *patch;
300 struct fm_instrument *fm;
306 snd_printk(KERN_DEBUG "Note on, ch %i, inst %i, note %i, vel %i\n",
307 chan->number, chan->midi_program, note, vel);
310 /* in SYNTH mode, application takes care of voices */
311 /* in SEQ mode, drum voice numbers are notes on drum channel */
312 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
313 if (chan->drum_channel) {
314 /* percussion instruments are located in bank 128 */
318 bank = chan->gm_bank_select;
319 prg = chan->midi_program;
322 /* Prepare for OSS mode */
323 if (chan->number >= MAX_OPL3_VOICES)
326 /* OSS instruments are located in bank 127 */
328 prg = chan->midi_program;
331 spin_lock_irqsave(&opl3->voice_lock, flags);
333 if (use_internal_drums) {
334 snd_opl3_drum_switch(opl3, note, vel, 1, chan);
335 spin_unlock_irqrestore(&opl3->voice_lock, flags);
340 patch = snd_opl3_find_patch(opl3, prg, bank, 0);
342 spin_unlock_irqrestore(&opl3->voice_lock, flags);
347 switch (patch->type) {
352 if (opl3->hardware >= OPL3_HW_OPL3) {
358 spin_unlock_irqrestore(&opl3->voice_lock, flags);
362 snd_printk(KERN_DEBUG " --> OPL%i instrument: %s\n",
363 instr_4op ? 3 : 2, patch->name);
365 /* in SYNTH mode, application takes care of voices */
366 /* in SEQ mode, allocate voice on free OPL3 channel */
367 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
368 voice = opl3_get_voice(opl3, instr_4op, chan);
370 /* remap OSS voice */
371 voice = snd_opl3_oss_map[chan->number];
375 spin_unlock_irqrestore(&opl3->voice_lock, flags);
379 if (voice < MAX_OPL2_VOICES) {
380 /* Left register block for voices 0 .. 8 */
381 reg_side = OPL3_LEFT;
382 voice_offset = voice;
383 connect_mask = (OPL3_LEFT_4OP_0 << voice_offset) & 0x07;
385 /* Right register block for voices 9 .. 17 */
386 reg_side = OPL3_RIGHT;
387 voice_offset = voice - MAX_OPL2_VOICES;
388 connect_mask = (OPL3_RIGHT_4OP_0 << voice_offset) & 0x38;
391 /* kill voice on channel */
392 vp = &opl3->voices[voice];
394 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
395 reg_val = vp->keyon_reg & ~OPL3_KEYON_BIT;
396 opl3->command(opl3, opl3_reg, reg_val);
399 vp2 = &opl3->voices[voice + 3];
400 if (vp2->state > 0) {
401 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK +
403 reg_val = vp->keyon_reg & ~OPL3_KEYON_BIT;
404 opl3->command(opl3, opl3_reg, reg_val);
408 /* set connection register */
410 if ((opl3->connection_reg ^ connect_mask) & connect_mask) {
411 opl3->connection_reg |= connect_mask;
412 /* set connection bit */
413 opl3_reg = OPL3_RIGHT | OPL3_REG_CONNECTION_SELECT;
414 opl3->command(opl3, opl3_reg, opl3->connection_reg);
417 if ((opl3->connection_reg ^ ~connect_mask) & connect_mask) {
418 opl3->connection_reg &= ~connect_mask;
419 /* clear connection bit */
420 opl3_reg = OPL3_RIGHT | OPL3_REG_CONNECTION_SELECT;
421 opl3->command(opl3, opl3_reg, opl3->connection_reg);
426 snd_printk(KERN_DEBUG " --> setting OPL3 connection: 0x%x\n",
427 opl3->connection_reg);
430 * calculate volume depending on connection
431 * between FM operators (see include/opl3.h)
433 for (i = 0; i < (instr_4op ? 4 : 2); i++)
434 vol_op[i] = fm->op[i].ksl_level;
436 connection = fm->feedback_connection[0] & 0x01;
439 connection |= fm->feedback_connection[1] & 0x01;
441 snd_opl3_calc_volume(&vol_op[3], vel, chan);
442 switch (connection) {
444 snd_opl3_calc_volume(&vol_op[2], vel, chan);
447 snd_opl3_calc_volume(&vol_op[0], vel, chan);
450 snd_opl3_calc_volume(&vol_op[1], vel, chan);
453 snd_opl3_calc_volume(&vol_op[1], vel, chan);
455 snd_opl3_calc_volume(&vol_op[0], vel, chan);
458 /* Program the FM voice characteristics */
459 for (i = 0; i < (instr_4op ? 4 : 2); i++) {
461 snd_printk(KERN_DEBUG " --> programming operator %i\n", i);
463 op_offset = snd_opl3_regmap[voice_offset][i];
465 /* Set OPL3 AM_VIB register of requested voice/operator */
466 reg_val = fm->op[i].am_vib;
467 opl3_reg = reg_side | (OPL3_REG_AM_VIB + op_offset);
468 opl3->command(opl3, opl3_reg, reg_val);
470 /* Set OPL3 KSL_LEVEL register of requested voice/operator */
472 opl3_reg = reg_side | (OPL3_REG_KSL_LEVEL + op_offset);
473 opl3->command(opl3, opl3_reg, reg_val);
475 /* Set OPL3 ATTACK_DECAY register of requested voice/operator */
476 reg_val = fm->op[i].attack_decay;
477 opl3_reg = reg_side | (OPL3_REG_ATTACK_DECAY + op_offset);
478 opl3->command(opl3, opl3_reg, reg_val);
480 /* Set OPL3 SUSTAIN_RELEASE register of requested voice/operator */
481 reg_val = fm->op[i].sustain_release;
482 opl3_reg = reg_side | (OPL3_REG_SUSTAIN_RELEASE + op_offset);
483 opl3->command(opl3, opl3_reg, reg_val);
485 /* Select waveform */
486 reg_val = fm->op[i].wave_select;
487 opl3_reg = reg_side | (OPL3_REG_WAVE_SELECT + op_offset);
488 opl3->command(opl3, opl3_reg, reg_val);
491 /* Set operator feedback and 2op inter-operator connection */
492 reg_val = fm->feedback_connection[0];
493 /* Set output voice connection */
494 reg_val |= OPL3_STEREO_BITS;
495 if (chan->gm_pan < 43)
496 reg_val &= ~OPL3_VOICE_TO_RIGHT;
497 if (chan->gm_pan > 85)
498 reg_val &= ~OPL3_VOICE_TO_LEFT;
499 opl3_reg = reg_side | (OPL3_REG_FEEDBACK_CONNECTION + voice_offset);
500 opl3->command(opl3, opl3_reg, reg_val);
503 /* Set 4op inter-operator connection */
504 reg_val = fm->feedback_connection[1] & OPL3_CONNECTION_BIT;
505 /* Set output voice connection */
506 reg_val |= OPL3_STEREO_BITS;
507 if (chan->gm_pan < 43)
508 reg_val &= ~OPL3_VOICE_TO_RIGHT;
509 if (chan->gm_pan > 85)
510 reg_val &= ~OPL3_VOICE_TO_LEFT;
511 opl3_reg = reg_side | (OPL3_REG_FEEDBACK_CONNECTION +
513 opl3->command(opl3, opl3_reg, reg_val);
517 * Special treatment of percussion notes for fm:
518 * Requested pitch is really program, and pitch for
519 * device is whatever was specified in the patch library.
524 * use transpose if defined in patch library
527 note += (fm->trnsps - 64);
529 snd_opl3_calc_pitch(&fnum, &blocknum, note, chan);
531 /* Set OPL3 FNUM_LOW register of requested voice */
532 opl3_reg = reg_side | (OPL3_REG_FNUM_LOW + voice_offset);
533 opl3->command(opl3, opl3_reg, fnum);
535 opl3->voices[voice].keyon_reg = blocknum;
537 /* Set output sound flag */
538 blocknum |= OPL3_KEYON_BIT;
541 snd_printk(KERN_DEBUG " --> trigger voice %i\n", voice);
543 /* Set OPL3 KEYON_BLOCK register of requested voice */
544 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
545 opl3->command(opl3, opl3_reg, blocknum);
547 /* kill note after fixed duration (in centiseconds) */
549 opl3->voices[voice].note_off = jiffies +
550 (fm->fix_dur * HZ) / 100;
551 snd_opl3_start_timer(opl3);
552 opl3->voices[voice].note_off_check = 1;
554 opl3->voices[voice].note_off_check = 0;
556 /* get extra pgm, but avoid possible loops */
557 extra_prg = (extra_prg) ? 0 : fm->modes;
559 /* do the bookkeeping */
560 vp->time = opl3->use_time++;
565 vp->state = SNDRV_OPL3_ST_ON_4OP;
567 vp2 = &opl3->voices[voice + 3];
568 vp2->time = opl3->use_time++;
571 vp2->state = SNDRV_OPL3_ST_NOT_AVAIL;
573 if (vp->state == SNDRV_OPL3_ST_ON_4OP) {
574 /* 4op killed by 2op, release bounded voice */
575 vp2 = &opl3->voices[voice + 3];
576 vp2->time = opl3->use_time++;
577 vp2->state = SNDRV_OPL3_ST_OFF;
579 vp->state = SNDRV_OPL3_ST_ON_2OP;
583 debug_alloc(opl3, "note on ", voice);
586 /* allocate extra program if specified in patch library */
588 if (extra_prg > 128) {
590 /* percussions start at 35 */
591 prg = extra_prg - 128 + 35 - 1;
597 snd_printk(KERN_DEBUG " *** allocating extra program\n");
601 spin_unlock_irqrestore(&opl3->voice_lock, flags);
604 static void snd_opl3_kill_voice(struct snd_opl3 *opl3, int voice)
606 unsigned short reg_side;
607 unsigned char voice_offset;
608 unsigned short opl3_reg;
610 struct snd_opl3_voice *vp, *vp2;
612 if (snd_BUG_ON(voice >= MAX_OPL3_VOICES))
615 vp = &opl3->voices[voice];
616 if (voice < MAX_OPL2_VOICES) {
617 /* Left register block for voices 0 .. 8 */
618 reg_side = OPL3_LEFT;
619 voice_offset = voice;
621 /* Right register block for voices 9 .. 17 */
622 reg_side = OPL3_RIGHT;
623 voice_offset = voice - MAX_OPL2_VOICES;
628 snd_printk(KERN_DEBUG " --> kill voice %i\n", voice);
630 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
631 /* clear Key ON bit */
632 opl3->command(opl3, opl3_reg, vp->keyon_reg);
634 /* do the bookkeeping */
635 vp->time = opl3->use_time++;
637 if (vp->state == SNDRV_OPL3_ST_ON_4OP) {
638 vp2 = &opl3->voices[voice + 3];
640 vp2->time = opl3->use_time++;
641 vp2->state = SNDRV_OPL3_ST_OFF;
643 vp->state = SNDRV_OPL3_ST_OFF;
645 debug_alloc(opl3, "note off", voice);
651 * Release a note in response to a midi note off.
653 static void snd_opl3_note_off_unsafe(void *p, int note, int vel,
654 struct snd_midi_channel *chan)
656 struct snd_opl3 *opl3;
659 struct snd_opl3_voice *vp;
664 snd_printk(KERN_DEBUG "Note off, ch %i, inst %i, note %i\n",
665 chan->number, chan->midi_program, note);
668 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
669 if (chan->drum_channel && use_internal_drums) {
670 snd_opl3_drum_switch(opl3, note, vel, 0, chan);
673 /* this loop will hopefully kill all extra voices, because
674 they are grouped by the same channel and note values */
675 for (voice = 0; voice < opl3->max_voices; voice++) {
676 vp = &opl3->voices[voice];
677 if (vp->state > 0 && vp->chan == chan && vp->note == note) {
678 snd_opl3_kill_voice(opl3, voice);
682 /* remap OSS voices */
683 if (chan->number < MAX_OPL3_VOICES) {
684 voice = snd_opl3_oss_map[chan->number];
685 snd_opl3_kill_voice(opl3, voice);
690 void snd_opl3_note_off(void *p, int note, int vel,
691 struct snd_midi_channel *chan)
693 struct snd_opl3 *opl3 = p;
696 spin_lock_irqsave(&opl3->voice_lock, flags);
697 snd_opl3_note_off_unsafe(p, note, vel, chan);
698 spin_unlock_irqrestore(&opl3->voice_lock, flags);
702 * key pressure change
704 void snd_opl3_key_press(void *p, int note, int vel, struct snd_midi_channel *chan)
707 snd_printk(KERN_DEBUG "Key pressure, ch#: %i, inst#: %i\n",
708 chan->number, chan->midi_program);
715 void snd_opl3_terminate_note(void *p, int note, struct snd_midi_channel *chan)
718 snd_printk(KERN_DEBUG "Terminate note, ch#: %i, inst#: %i\n",
719 chan->number, chan->midi_program);
723 static void snd_opl3_update_pitch(struct snd_opl3 *opl3, int voice)
725 unsigned short reg_side;
726 unsigned char voice_offset;
727 unsigned short opl3_reg;
729 unsigned char fnum, blocknum;
731 struct snd_opl3_voice *vp;
733 if (snd_BUG_ON(voice >= MAX_OPL3_VOICES))
736 vp = &opl3->voices[voice];
737 if (vp->chan == NULL)
738 return; /* not allocated? */
740 if (voice < MAX_OPL2_VOICES) {
741 /* Left register block for voices 0 .. 8 */
742 reg_side = OPL3_LEFT;
743 voice_offset = voice;
745 /* Right register block for voices 9 .. 17 */
746 reg_side = OPL3_RIGHT;
747 voice_offset = voice - MAX_OPL2_VOICES;
750 snd_opl3_calc_pitch(&fnum, &blocknum, vp->note, vp->chan);
752 /* Set OPL3 FNUM_LOW register of requested voice */
753 opl3_reg = reg_side | (OPL3_REG_FNUM_LOW + voice_offset);
754 opl3->command(opl3, opl3_reg, fnum);
756 vp->keyon_reg = blocknum;
758 /* Set output sound flag */
759 blocknum |= OPL3_KEYON_BIT;
761 /* Set OPL3 KEYON_BLOCK register of requested voice */
762 opl3_reg = reg_side | (OPL3_REG_KEYON_BLOCK + voice_offset);
763 opl3->command(opl3, opl3_reg, blocknum);
765 vp->time = opl3->use_time++;
769 * Update voice pitch controller
771 static void snd_opl3_pitch_ctrl(struct snd_opl3 *opl3, struct snd_midi_channel *chan)
774 struct snd_opl3_voice *vp;
778 spin_lock_irqsave(&opl3->voice_lock, flags);
780 if (opl3->synth_mode == SNDRV_OPL3_MODE_SEQ) {
781 for (voice = 0; voice < opl3->max_voices; voice++) {
782 vp = &opl3->voices[voice];
783 if (vp->state > 0 && vp->chan == chan) {
784 snd_opl3_update_pitch(opl3, voice);
788 /* remap OSS voices */
789 if (chan->number < MAX_OPL3_VOICES) {
790 voice = snd_opl3_oss_map[chan->number];
791 snd_opl3_update_pitch(opl3, voice);
794 spin_unlock_irqrestore(&opl3->voice_lock, flags);
798 * Deal with a controller type event. This includes all types of
799 * control events, not just the midi controllers
801 void snd_opl3_control(void *p, int type, struct snd_midi_channel *chan)
803 struct snd_opl3 *opl3;
807 snd_printk(KERN_DEBUG "Controller, TYPE = %i, ch#: %i, inst#: %i\n",
808 type, chan->number, chan->midi_program);
812 case MIDI_CTL_MSB_MODWHEEL:
813 if (chan->control[MIDI_CTL_MSB_MODWHEEL] > 63)
814 opl3->drum_reg |= OPL3_VIBRATO_DEPTH;
816 opl3->drum_reg &= ~OPL3_VIBRATO_DEPTH;
817 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION,
820 case MIDI_CTL_E2_TREMOLO_DEPTH:
821 if (chan->control[MIDI_CTL_E2_TREMOLO_DEPTH] > 63)
822 opl3->drum_reg |= OPL3_TREMOLO_DEPTH;
824 opl3->drum_reg &= ~OPL3_TREMOLO_DEPTH;
825 opl3->command(opl3, OPL3_LEFT | OPL3_REG_PERCUSSION,
828 case MIDI_CTL_PITCHBEND:
829 snd_opl3_pitch_ctrl(opl3, chan);
837 void snd_opl3_nrpn(void *p, struct snd_midi_channel *chan,
838 struct snd_midi_channel_set *chset)
841 snd_printk(KERN_DEBUG "NRPN, ch#: %i, inst#: %i\n",
842 chan->number, chan->midi_program);
849 void snd_opl3_sysex(void *p, unsigned char *buf, int len,
850 int parsed, struct snd_midi_channel_set *chset)
853 snd_printk(KERN_DEBUG "SYSEX\n");