| MD_SN76489 Library 1.0 Library for SN76489 sound generator

ADSR Envelope

## Attack, Decay, Sustain, Release (ADSR) Envelope

An ADSR generated sound envelope is a component of many synthesizers and other electronic musical instruments. The sound envelope modulates the sound, often its loudness, over time. In this library the envelope is implemented in software to control the volume of the sound.

ADSR Envelope

Electronic instruments can also implement an inverted ADSR envelope, resulting in the opposite behavior: during the attack phase, the sound fades out from the maximum amplitude to zero, rises up to the value specified by the sustain parameter in the decay phase and continues to rise from the sustain amplitude back to maximum amplitude.

The ADSR envelope can be specified using the following parameters:

- Attack: The time interval (Ta) betwen activation and full loudness (Vmax).
- Decay: The time interval (Td) for Vmax to drop to the sustain level (Vs).
- Sustain: The constant sound volume (Vs) for the note until it is released.
- Release: The time interval (Tr) for the sound to fade from Vs to 0 when a note ends.

An ADSR note cycle is controlled by 2 events - an note on event that triggers the attack phase of the cycle and a note off event that triggers the release phase of the cycle. On a keyboard instrument these would correspond to a key being pressed and then released.

The library initially defines supplies one default ADSR envelope for all channels. These can be changed per channel in real time using the setADSR() method to specify the new envelope parameters. The nomenclature for the parameters follows the labels and explanation above. A flag can be set to invert the specified envelope.

The SN74689 volume controls are limited to 15 steps, so the Attack, Decay or Release phases are implemented as a linear progression changing the sound volume over time.