Skip to content

Envelope Overview

Leandro Nini edited this page Jun 8, 2021 · 2 revisions

The envelope generator alters the waveform amplitude based on four 4-bit parameters (attack, decay, sustain and release) and the gate signal to mimic real instruments sound dynamic. The envelope output is an 8 bit value, clocked up or down depending on the state, which modulates the waveform output through an MDAC. When the gate goes high the volume raises up to $ff linearly then it falls down exponentially to the sustain level. Once the gate is released the volume goes down exponentially to zero. A 15 bit LFSR is used to divide the clock during the attack phase providing 16 different attack rates, ranging from 2ms to 8s. Another 5 bit LFSR further divides the clock during the decay/release phases to approximante an exponential curve, ranging from 6 ms to 24 s. The stop-points for the LFSRs are determined by two LUTs indexed by the ADR values. More details in the technical documentation.

The envelope generator is also afflicted by some "bugs", like the counter wrapping when switching quickly between attack and release or the infamous ADSR-Bug, which may cause the attack of a note to start with quite a few cycles of delay after the gate is set.