
---> Aftertouch Bug Fix for OSS/light (linux). <---

Stefan Nitschke
Sun Sep 21 01:45:46 CEST 1997

-----------------------------------------------------------------------
Report of cat /dev/sndstat:

Sound Driver:3.5.4-960630 (Sat Aug 9 16:23:43 CEST 1997 root
Linux Kathmandu 2.0.25 #209 Thu Aug 7 21:16:49 CEST 1997 i486)
Kernel: Linux Kathmandu 2.0.25 #223 Sun Sep 21 00:20:27 CEST 1997 i486
Config options: 0

Installed drivers: 
Type 19: MAD16/Mozart (MSS)
Type 20: MAD16/Mozart (MPU)
Type 1: OPL-2/OPL-3 FM
-----------------------------------------------------------------------


***File: midi_synth.h

---line 12:

void midi_synth_panning (int dev, int channel, int pressure);
// SN++
void midi_synth_kaftertouch (int dev, int channel, int note, int pressure);

void midi_synth_aftertouch (int dev, int channel, int pressure);

---line 40:

  midi_synth_hw_control,
  midi_synth_load_patch,
  // SN++
  midi_synth_kaftertouch,
  midi_synth_aftertouch,

***File: midi_synth.cc

---line 586:

void
midi_synth_panning (int dev, int channel, int pressure)
{
}

// SN++ key aftertouch
void
midi_synth_kaftertouch (int dev, int channel, int note, int pressure)
{
  int             orig_dev = synth_devs[dev]->midi_dev;
  int             msg, chn;

  if (pressure < 0 || pressure > 127)
    return;
  if (channel < 0 || channel > 15)
    return;

  leave_sysex (dev);

  msg = prev_out_status[orig_dev] & 0xf0;
  chn = prev_out_status[orig_dev] & 0x0f;

 if (chn == channel && msg == 0xa0)
    {                           /*
                                 * Use running status
                                 */
      if (!prefix_cmd (orig_dev, note))
        return;
      midi_outc (orig_dev, note);
      midi_outc (orig_dev, pressure);
    }
  else
    {
      if (!prefix_cmd (orig_dev, 0xa0 | (channel & 0x0f)))
        return;
      midi_outc (orig_dev, 0xa0 | (channel & 0x0f));    /*
                                                         * Key aftertouch
                                                         */
      midi_outc (orig_dev, note);
      midi_outc (orig_dev, pressure);
    }
}

// SN++ channel aftertouch
void
midi_synth_aftertouch (int dev, int channel, int pressure)
{
  int             orig_dev = synth_devs[dev]->midi_dev;
  int             msg, chn;

  if (pressure < 0 || pressure > 127)
    return;
  if (channel < 0 || channel > 15)
    return;

  leave_sysex (dev);

  msg = prev_out_status[orig_dev] & 0xf0;
  chn = prev_out_status[orig_dev] & 0x0f;

  if (msg != 0xd0 || chn != channel)    /*
                     * Test for running status
                     */
    {
      if (!prefix_cmd (orig_dev, 0xd0 | (channel & 0x0f)))
    return;
      midi_outc (orig_dev, 0xd0 | (channel & 0x0f));    /*
                             * Channel pressure
                             */
    }
  else if (!prefix_cmd (orig_dev, pressure))
    return;

  midi_outc (orig_dev, pressure);
}

***File dev_table.h

---line 206:

    int (*load_patch) (int dev, int format, const char *addr,
         int offs, int count, int pmgr_flag);
    // SN++
    void (*kaftertouch) (int dev, int voice, int note, int pressure);
    void (*aftertouch) (int dev, int voice, int pressure);

***File mpu401.c

---line 966:

  midi_synth_load_patch,
  // SN++
  midi_synth_kaftertouch,
  midi_synth_aftertouch,

***File gus_wave.c

---line 1168:

static void
guswave_aftertouch (int dev, int voice, int pressure)
{
}
// SN++
static void
guswave_kaftertouch (int dev, int voice, int note, int pressure)
{
}

---line 2992

  guswave_load_patch,
  guswave_kaftertouch,
  guswave_aftertouch,


***File opl3.c

---line 896:

static void
opl3_volume_method (int dev, int mode)
{
}

#define SET_VIBRATO(cell) { \
      tmp = instr->operators[(cell-1)+(((cell-1)/2)*OFFS_4OP)]; \
      if (pressure > 110) \
    tmp |= 0x40;        /* Vibrato on */ \
      opl3_command (map->ioaddr, AM_VIB + map->op[cell-1], tmp);}


// SN++
static void
opl3_kaftertouch (int dev, int voice, int note, int pressure)
{
}

---line 1158:

  opl3_load_patch,
  opl3_kaftertouch,
  opl3_aftertouch,
 

***File sequencer.c

---line 400:

    case SEQ_PGMCHANGE:
      synth_devs[dev]->set_instr (dev, q[3], q[4]);
      break;

 // SN++
    case SEQ_AFTERTOUCH:
      synth_devs[dev]->kaftertouch (dev, q[3], q[4], q[5]);
      break;

---line 567:

    case MIDI_NOTEOFF:
      if (voice == -1)
    voice = chn;
      synth_devs[dev]->kill_note (dev, voice, note, parm);
      break;

    case MIDI_KEY_PRESSURE:
// SN++ Bug in OSS/light aftertouch() is channel aftertouch
      if (voice == -1)
    voice = chn;
      synth_devs[dev]->kaftertouch (dev, voice, note, parm);
      break;

    default:;

---line 655:

    case MIDI_PITCH_BEND:
      if (seq_mode == SEQ_2)
    {
      synth_devs[dev]->chn_info[chn].bender_value = w14;

      if ((int) dev < num_synths)
        {           // Handle all playing notes on this channel
          int             i, key;

          key = (chn << 8);
          for (i = 0; i < synth_devs[dev]->alloc.max_voice; i++)
        if ((synth_devs[dev]->alloc.map[i] & 0xff00) == key)
          synth_devs[dev]->bender (dev, i, w14);
        }
      else
        synth_devs[dev]->bender (dev, chn, w14);
    }
      else          // MODE 1
    synth_devs[dev]->bender (dev, chn, w14);
      break;

// SN++ channel aftertouch
    case MIDI_CHN_PRESSURE:
       synth_devs[dev]->aftertouch (dev, chn, p1);
       break;

    default:;

-------------------------------------------------------------------
