The Konami Software Envelope

For MSX developers, the AY-3-8910 (PSG) hardware envelope had limitations — global across channels and restricted to a few repeating shapes. Konami’s legendary sound team bypassed these limitations by shifting envelope logic into the VDP interrupts, creating a per-channel, software-defined ADSR profile.

The "Konami Sound" uses the 60Hz NTSC (50Hz on PAL) interrupt cycle. Instead of relying on the PSG's internal envelope generator, the driver manually updates the Volume Registers (Registers 8, 9, and 10) every time the VDP triggers an interrupt. By updating the volume every 16.6ms, Konami could simulate a sophisticated ADSR curve that gave their music a distinct percussive texture.

ADSR

ADSR stands for “Attack, Decay, Sustain, Release”, is the most common type of envelope generator used by synthesizers. The basic idea is to mimic the volume progression that occurs when you press a real-life piano key. ADSR illustration

For most of the Konami games, the phases of a typical "piano" sound consist of:

The exact amount of time taken by each phase could vary depending on the game.

The graph below illustrates a typical envelope pattern in notes from the game Knightmare. Press play to hear an A4 note using that envelope.

The following Javascript code snippet provides a generic envelope generator parameterized to allow generating the envelope patterns of most Konami game sounds.
    function* konamiEnvelope(volume, decayRate, sustainVolume, totalDurationTicks, noteOnDurationTicks) {
      for (ticks = 0; ticks < totalDurationTicks; ticks++) {
        yield Math.round(volume);
        if (volume > 0 && (volume > sustainVolume || ticks >= noteOnDurationTicks)) {
          volume -= decayRate;
        }
      }
    }
  

Demo

Below you can see the difference in sound when using the Konami envelope. This is the Knightmare intro song. Select the envelope pattern and press play.

See the source code at: https://github.com/mrbubble/music