AGCAttackHoldRelease - Dynamics
Overview
Multi-channel envelope detector with programmable attack, hold, and release times
Discussion
The AGCAttackHoldRelease is an envelope detector implemented as an exponential moving averaging filter. The module accepts multichannel signals and applies the processing independently to each channel. An N-channel input signal will produce an output signal with the same block size as the input.
Unlike the AGCAttackRelease module, the AGCAttackHoldRelease module does not rectify the input signal with an absolute value operation. This allows the AGCAttackHoldRelease to follow negative signals. Watch out for this distinction!
The module can be configured to hold either the peak value (default) or the minimum value. This is set through the hold module parameter:
“MaxHold” = 0 = hold the peak
“MinHold” = 1 = hold the minimum value
An envelope detector is applied to the input, which has programmable attack and release filter smoothing times. The attack time applies when the current input value is larger than the state of the envelope detector. Similarly, the release time applies when the current input value is smaller than the state of the envelope detector. The hold time determines how long the output value will be held constant before either attacking or releasing, depending on the holdMode parameter setting.
The MaxHold option allows the envelope detector to attack without hesitation. At any time-step for which the envelope detector is attacking, the hold timer is reset to the value of the holdTime parameter. When the input signal value drops below the current envelope detector state the current state will be held. This hold behavior will continue for the duration of the holdTime, or if the input value rises above the current state, whichever occurs first. After the hold timer has elapsed, the envelope detector can begin releasing.
The MinHold option can be thought of as the opposite behavioral mode as the MaxHold option. The MinHold option allows the envelope detector to release without hesitation. At any time-step for which the envelope detector is releasing, the hold timer is reset to the value of the holdTime parameter. When the input signal value rises above the current envelope detector state the current state will be held. This hold behavior will continue for the duration of the holdTime, or if the input value drops below the current state, whichever occurs first. After the hold timer has elapsed, the envelope detector can begin attacking.
With the hold time set to 0, the AGCAttackHoldRelease module applies attack and release filtering freely as the AGCAttackRelease module does. The one key difference between the AGCAttackRelease and the AGCAttackHoldRelease module is that the former applies an absolute value operation to the input signal internally while the latter does not. This allows the AGCAttackHoldRelease module to filter both positive and negative valued input signals, giving it more flexibility.
The behavior of the AGCAttackHoldRelease module will become clearer with a few visual examples. The following examples show a plot of the overlaid single-channel input signal and resulting output signal of the module, as displayed by a sink module. The input signal is a 200ms rectangular pulse with unity amplitude, displayed as a black trace. The output signal is displayed in blue.
Example #1 - MaxHold
Note the settings in the AGCAttackHoldRelease module’s inspector panel. Specifically, the holdTime is set to 50ms.

The input signal rises at 100 msec and the module tracks the signal using the attack time. Then when the signal falls at 300 msec, the module holds for 50 msec and then starts releasing at 350 msec. The decay rate at 350 msec is based on the release time. This demonstrates the “MaxHold” behavior as the output signal’s maximum value is held.
The attack and release behaviors are implemented using first order filters. When attacking the module follows the curve.

After one attack time period, the module has reached


It takes multiple attack time periods for the level to approach 1.0
| Attack time periods | Level |
|---|---|
| 1 | 0.632 |
| 2 | 0.865 |
| 3 | 0.950 |
| 4 | 0.982 |
| 5 | 0.993 |
When releasing, the level follows the curve.

and this can be quantified as
| Release time periods | Level |
|---|---|
| 1 | 0.368 |
| 2 | 0.135 |
| 3 | 0.050 |
| 4 | 0.018 |
| 5 | 0.007 |
Example #2 - MinHold
With the exception of the holdMode, all settings in this example are the same as the previous.

The input signal rises at 100 msec and the module tracks the minimum value (=0) for another 50 msec. Then at 150 msec, the module starts attacking and follows the pulse based on the attack time. At 300 msec, the pulse drops to zero and the module starts decaying based on the release time. This demonstrates the “MinHold” behavior as the output signal’s minimum value is held.
Example #3 – “No Hold”
The AGCAttackHoldRelease module’s holdMode parameter does not explicitly have a “NoHold” option. Instead, the user can simply set the holdTime value to 0ms which effectively turns off the hold behavior of the module. This applies independently of the holdMode setting.

At the input signal rising edge and falling edge of 100ms and 300ms, respectively, the output value both attacks and releases without any holding behavior. This matches the behavior of the AGCAttackRelease module.
Module Pack
Advanced
ClassID
classID = 1443
Type Definition
typedef struct _ModuleAGCAttackHoldRelease
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 attackTime; // Speed at which the detector reacts to increasing levels.
FLOAT32 releaseTime; // Speed at which the detector reacts to decreasing levels.
FLOAT32 holdTime; // Time for which the peak output is held before decaying.
INT32 holdMode; // Mode of operation for holding envelope value.
FLOAT32 attackCoeff; // Internal coefficient realizing the attack time.
FLOAT32 releaseCoeff; // Internal coefficient realizing the release time.
INT32 holdSamples; // Number of samples to hold peak output.
FLOAT32* envStates; // Vector of sample-by-sample states of the envelope detectors; each column is the state for a channel.
INT32* holdCounters; // Vector of per-channel hold counters to determine.
} ModuleAGCAttackHoldReleaseClass;
Variables
Properties
| Name | Type | Usage | isHidden | Default Value | Range | Units |
|---|---|---|---|---|---|---|
| attackTime | float | parameter | 0 | 2 | 0:1000 | msec |
| releaseTime | float | parameter | 0 | 100 | 0:1000 | msec |
| holdTime | float | parameter | 0 | 0 | 0:1000 | msec |
| holdMode | int | parameter | 0 | 0 | 0:1 | |
| attackCoeff | float | derived | 1 | 0.01036 | Unrestricted | |
| releaseCoeff | float | derived | 1 | 0.0002083 | Unrestricted | |
| holdSamples | int | derived | 1 | 0 | Unrestricted | |
| envStates | float* | state | 1 | [1 x 1] | Unrestricted | |
| holdCounters | int* | state | 1 | [1 x 1] | Unrestricted |
Pins
Input Pins
| Name | in |
| Description | audio input |
| Data type | float |
| Channel range | Unrestricted |
| 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: agc_attack_hold_release_module.m
M=agc_attack_hold_release_module(NAME)
Envelope detector with programmable attack and release time constants.
Arguments:
NAME - name of the module.
Copyright 2009-2024. DSP Concepts, Inc. All Rights Reserved.
Copyright (c) 2026 DSP Concepts, Inc.