AttackDecaySustainRelease
Overview
Multi-channel envelope detector with programmable attack time, decay time, sustain level and release time
Discussion
Envelope detector used in dynamics processor. The module accepts an N-channel buffer of input signal and produces an output buffer the same size as the input. An envelope detector is applied to the input that has programmable attack, decay and release times along with sustain level. These programmable times are time constants for an exponential envelope. The attack time applies when the startAttack flag is active and will be in attack stage untill the level reaches maxLevel. When the level reached the maxLevel then the stage changed to decay state. In the decay state if the level reaches sustainLevel then it stays at the sustainLevel untill the startRelease flag is active. The release time applies when the startRelease flag is active. The level is smoothed to 0 from sustainLevel. Detector will be in release state untill startAttack flag is active. This is an exponential envelope.
Type Definition
typedef struct _ModuleAttackDecaySustainRelease
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 attackTime; // Time taken for initial run-up level from nill peak, beginning when the key is first pressed.
FLOAT32 decayTime; // Time taken for the subsequent run down from the attack level to the designated sustain level.
FLOAT32 sustainLevel; // Level during the main sequence of the sound duration, until the key is released.
FLOAT32 releaseTime; // Time taken for the level to decay from the sustain level to zero after the key is released.
FLOAT32 maxLevel; // Maximum level to which attack phase reach from zero to this level.
INT32 startAttack; // Flag indicates start of attack phase. This is a trigger control.
INT32 startRelease; // Flag indicates start release phase. This is a trigger control.
FLOAT32 attackCoeff; // Internal coefficient realizing the attack time.
FLOAT32 decayCoeff; // Internal coefficient realizing the decay time.
FLOAT32 releaseCoeff; // Internal coefficient realizing the release time.
INT32 adsrState; // Internal state to switch between Attack, Decay, Sustain and Release states.
FLOAT32* envStates; // Vector of sample-by-sample states of the envelope detectors; each column is the state for a channel.
} ModuleAttackDecaySustainReleaseClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
attackTime | float | parameter | 0 | 2 | 0.01:1000 | msec |
decayTime | float | parameter | 0 | 1 | 0.01:1000 | msec |
sustainLevel | float | parameter | 0 | 0.5 | 0:1 | linear |
releaseTime | float | parameter | 0 | 100 | 0.01:1000 | msec |
maxLevel | float | parameter | 0 | 1 | 0:1 | |
startAttack | int | parameter | 0 | 0 | 0:1 | |
startRelease | int | parameter | 0 | 0 | 0:1 | |
attackCoeff | float | derived | 1 | 0.01036 | Unrestricted | |
decayCoeff | float | derived | 1 | 0.02062 | Unrestricted | |
releaseCoeff | float | derived | 1 | 0.0002083 | Unrestricted | |
adsrState | int | state | 1 | 3 | Unrestricted | |
envStates | float* | state | 1 | [1 x 1] | Unrestricted |
Pins
Input Pins
Name: in
Description: audio input
Data type: float
Channel range: 1
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: audio output
Data type: float
MATLAB Usage
File Name: attack_decay_sustain_release_module.m
M=attack_decay_sustain_release_module(NAME, NCHAN)
Envelope detector with programmable attack, decay, sustain level and release time constants.
Arguments:
NAME - name of the module.
NCHAN - initial number of channels.
Copyright 2016. DSP Concepts, Inc. All Rights Reserved.
Author: mmohan