DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::TransientFollower< T > Class Template Reference

How sudden the signal is, 0..1, whatever its level. More...

#include <EnvelopeFollower.h>

Public Member Functions

 TransientFollower () noexcept
 
void prepare (double sampleRate) noexcept
 Prepares for a sample rate (an invalid one is ignored) and clears.
 
void reset () noexcept
 Clears the followers and the output.
 
void setRange (T dB) noexcept
 Range in dB that maps to the full value, 3 to 40 (default 12).
 
void setHold (T ms) noexcept
 Time the value is held at a peak, 0 to 500 ms (default 20).
 
void setRelease (T ms) noexcept
 Time constant of the fall after the hold, 1 to 2000 ms (default 80).
 
T getRange () const noexcept
 
T getHold () const noexcept
 
T getRelease () const noexcept
 
T getValue () const noexcept
 The value after the last sample (any thread).
 
T processSample (T input) noexcept
 One sample (already the loudest channel's, or mono); returns the value.
 
void processBlock (AudioBufferView< T > buffer, T *out=nullptr) noexcept
 Follows a block (the loudest channel per frame); the audio is not touched.
 

Detailed Description

template<FloatType T>
class dspark::TransientFollower< T >

How sudden the signal is, 0..1, whatever its level.

The loudest channel's analytic magnitude (a zero-latency Hilbert pair: a steady tone reads its amplitude with no ripple) feeds two followers with the same release (100 ms): one with a fast attack (0.5 ms), one with a slow attack (30 ms). On a steady signal the two meet; at an onset the fast one leaves the slow one behind by as many decibels as the onset rises, for as long as the slow attack takes. That distance, less half a decibel, over the range (setRange(), 12 dB by default) is the raw value; the output takes it at once, holds it (setHold(), 20 ms) and then falls with a release (setRelease(), 80 ms). Both followers scale with the signal, so the value does not depend on the level (under -120 dBFS it is 0).

Threading: prepare() and reset() on the setup thread or the stream owner; processBlock() and processSample() on the audio thread; the setters and getValue() from any thread.

Template Parameters
TSample type (float or double).

Definition at line 320 of file EnvelopeFollower.h.

Constructor & Destructor Documentation

◆ TransientFollower()

template<FloatType T>
dspark::TransientFollower< T >::TransientFollower ( )
inlinenoexcept

Definition at line 323 of file EnvelopeFollower.h.

Member Function Documentation

◆ getHold()

template<FloatType T>
T dspark::TransientFollower< T >::getHold ( ) const
inlinenoexcept

Definition at line 365 of file EnvelopeFollower.h.

◆ getRange()

template<FloatType T>
T dspark::TransientFollower< T >::getRange ( ) const
inlinenoexcept

Definition at line 364 of file EnvelopeFollower.h.

◆ getRelease()

template<FloatType T>
T dspark::TransientFollower< T >::getRelease ( ) const
inlinenoexcept

Definition at line 366 of file EnvelopeFollower.h.

◆ getValue()

template<FloatType T>
T dspark::TransientFollower< T >::getValue ( ) const
inlinenoexcept

The value after the last sample (any thread).

Definition at line 369 of file EnvelopeFollower.h.

◆ prepare()

template<FloatType T>
void dspark::TransientFollower< T >::prepare ( double  sampleRate)
inlinenoexcept

Prepares for a sample rate (an invalid one is ignored) and clears.

Definition at line 326 of file EnvelopeFollower.h.

◆ processBlock()

template<FloatType T>
void dspark::TransientFollower< T >::processBlock ( AudioBufferView< T >  buffer,
T *  out = nullptr 
)
inlinenoexcept

Follows a block (the loudest channel per frame); the audio is not touched.

Parameters
bufferThe audio to follow (up to 16 channels are read).
outOptional: receives the value per frame (one per sample of the block).

Definition at line 387 of file EnvelopeFollower.h.

◆ processSample()

template<FloatType T>
T dspark::TransientFollower< T >::processSample ( T  input)
inlinenoexcept

One sample (already the loudest channel's, or mono); returns the value.

Definition at line 372 of file EnvelopeFollower.h.

◆ reset()

template<FloatType T>
void dspark::TransientFollower< T >::reset ( )
inlinenoexcept

Clears the followers and the output.

Definition at line 338 of file EnvelopeFollower.h.

◆ setHold()

template<FloatType T>
void dspark::TransientFollower< T >::setHold ( T  ms)
inlinenoexcept

Time the value is held at a peak, 0 to 500 ms (default 20).

Definition at line 354 of file EnvelopeFollower.h.

◆ setRange()

template<FloatType T>
void dspark::TransientFollower< T >::setRange ( T  dB)
inlinenoexcept

Range in dB that maps to the full value, 3 to 40 (default 12).

Definition at line 349 of file EnvelopeFollower.h.

◆ setRelease()

template<FloatType T>
void dspark::TransientFollower< T >::setRelease ( T  ms)
inlinenoexcept

Time constant of the fall after the hold, 1 to 2000 ms (default 80).

Definition at line 359 of file EnvelopeFollower.h.


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