Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Public Member Functions | List of all members
sbl::dsp::EnvelopeFollower Class Reference

#include <envelope_follower.hpp>

Collaboration diagram for sbl::dsp::EnvelopeFollower:

Public Member Functions

void set_times (float attack_ms, float release_ms, uint32_t sample_rate)
 Set attack and release times in milliseconds.
 
void set_coefficients (float attack, float release)
 Set attack and release coefficients directly.
 
float process (float sample)
 Process a single sample, return envelope value.
 
void process (const float *in, float *out, uint16_t frames)
 Process a block, write envelope to output buffer.
 
float value () const
 Current envelope value (can be read without processing)
 
void reset ()
 Reset envelope state to zero.
 
void reset (float initial)
 Reset envelope state to a specific value.
 

Detailed Description

Definition at line 23 of file envelope_follower.hpp.

Member Function Documentation

◆ process() [1/2]

void sbl::dsp::EnvelopeFollower::process ( const float *  in,
float *  out,
uint16_t  frames 
)
inline

Process a block, write envelope to output buffer.

Input and output can be the same buffer (in-place).

Parameters
inInput audio buffer
outOutput envelope buffer (always >= 0)
framesNumber of samples

Definition at line 105 of file envelope_follower.hpp.

References process().

Here is the call graph for this function:

◆ process() [2/2]

float sbl::dsp::EnvelopeFollower::process ( float  sample)
inline

Process a single sample, return envelope value.

Full-wave rectifies the input, then applies asymmetric smoothing: if |input| > state: use attack coefficient (rise fast) if |input| < state: use release coefficient (fall slow)

Parameters
sampleInput audio sample
Returns
Current envelope value (always >= 0)

Definition at line 85 of file envelope_follower.hpp.

Referenced by process().

Here is the caller graph for this function:

◆ reset() [1/2]

void sbl::dsp::EnvelopeFollower::reset ( )
inline

Reset envelope state to zero.

Definition at line 115 of file envelope_follower.hpp.

◆ reset() [2/2]

void sbl::dsp::EnvelopeFollower::reset ( float  initial)
inline

Reset envelope state to a specific value.

Definition at line 118 of file envelope_follower.hpp.

◆ set_coefficients()

void sbl::dsp::EnvelopeFollower::set_coefficients ( float  attack,
float  release 
)
inline

Set attack and release coefficients directly.

Coefficient range [0.0, 1.0). Higher = faster response. 0.0 = no change (hold forever), approaching 1.0 = instant.

Parameters
attackAttack coefficient
releaseRelease coefficient

Definition at line 70 of file envelope_follower.hpp.

◆ set_times()

void sbl::dsp::EnvelopeFollower::set_times ( float  attack_ms,
float  release_ms,
uint32_t  sample_rate 
)
inline

Set attack and release times in milliseconds.

Note
All public methods are ISR-safe — bounded computation, no I/O.

Computes one-pole coefficients from time constants. Attack: how fast the follower rises to meet a transient. Release: how fast it falls after the signal drops.

Parameters
attack_msAttack time in milliseconds (typically 0.1–10)
release_msRelease time in milliseconds (typically 50–500)
sample_rateAudio sample rate (e.g. 48000)

Definition at line 38 of file envelope_follower.hpp.

◆ value()

float sbl::dsp::EnvelopeFollower::value ( ) const
inline

Current envelope value (can be read without processing)

Definition at line 112 of file envelope_follower.hpp.


The documentation for this class was generated from the following file: