Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::DecayEnvelopeT< SampleType > Class Template Reference

A one-shot percussion envelope: linear attack ramp, optional hold, then exponential decay. More...

#include <decay_envelope.hpp>

Public Member Functions

 DecayEnvelopeT ()
 A default-constructed envelope has usable coefficients at 44.1 kHz, so triggering one before any setter runs produces the documented default contour rather than instant silence.
void set_sample_rate (double sr)
void set_attack_ms (double ms)
 Length of the anti-click ramp.
void set_hold_ms (double ms)
 Time at full scale between the attack and the decay.
void set_decay_time_constant_ms (double ms)
 Decay expressed as an RC time constant (1/e after ms).
void set_decay_t60_ms (double ms)
 Decay expressed as a T60 (-60 dB after ms).
double attack_ms () const
double hold_ms () const
double decay_ms () const
void trigger (SampleType peak=SampleType{1})
 Starts the envelope from silence.
void reset ()
 Silences the envelope immediately without a release ramp.
bool is_active () const
SampleType process ()
 Next envelope sample in [0, peak].
SampleType value () const
 Current level without advancing, scaled by the trigger peak.

Static Public Attributes

static constexpr double silence_floor = 1e-5
 Level below which the envelope is treated as finished.

Detailed Description

template<typename SampleType = float>
class pulp::signal::DecayEnvelopeT< SampleType >

A one-shot percussion envelope: linear attack ramp, optional hold, then exponential decay.

The attack ramp exists to stop a click. Starting an envelope at full scale puts a step edge into the signal, which is broadband and lands on top of whatever transient the voice was designed to have. A ramp of a fraction of a millisecond removes the step without softening the attack audibly, so the default is deliberately short rather than musically chosen.

The decay is exponential and never reaches zero analytically, so the envelope declares itself finished once it falls below silence_floor and then outputs exact zero. A voice polls is_active() to know when it can stop rendering, which is what keeps an idle drum kit off the CPU.

The decay time may be expressed either as an RC time constant (set_decay_time_constant_ms) or as a T60 (set_decay_t60_ms); the two setters are alternatives, and the most recent call wins.

RT contract: every member allocates nothing and takes no locks.

Constructor & Destructor Documentation

◆ DecayEnvelopeT()

template<typename SampleType = float>
pulp::signal::DecayEnvelopeT< SampleType >::DecayEnvelopeT ( )
inline

A default-constructed envelope has usable coefficients at 44.1 kHz, so triggering one before any setter runs produces the documented default contour rather than instant silence.

Member Function Documentation

◆ attack_ms()

template<typename SampleType = float>
double pulp::signal::DecayEnvelopeT< SampleType >::attack_ms ( ) const
inline

◆ decay_ms()

template<typename SampleType = float>
double pulp::signal::DecayEnvelopeT< SampleType >::decay_ms ( ) const
inline

◆ hold_ms()

template<typename SampleType = float>
double pulp::signal::DecayEnvelopeT< SampleType >::hold_ms ( ) const
inline

◆ is_active()

template<typename SampleType = float>
bool pulp::signal::DecayEnvelopeT< SampleType >::is_active ( ) const
inline

◆ process()

template<typename SampleType = float>
SampleType pulp::signal::DecayEnvelopeT< SampleType >::process ( )
inline

Next envelope sample in [0, peak].

◆ reset()

template<typename SampleType = float>
void pulp::signal::DecayEnvelopeT< SampleType >::reset ( )
inline

Silences the envelope immediately without a release ramp.

Used by reset() paths and by a hard choke where the caller supplies its own fade.

◆ set_attack_ms()

template<typename SampleType = float>
void pulp::signal::DecayEnvelopeT< SampleType >::set_attack_ms ( double ms)
inline

Length of the anti-click ramp.

Clamped at zero; a zero-length attack makes the envelope jump to full scale on the first sample.

◆ set_decay_t60_ms()

template<typename SampleType = float>
void pulp::signal::DecayEnvelopeT< SampleType >::set_decay_t60_ms ( double ms)
inline

Decay expressed as a T60 (-60 dB after ms).

◆ set_decay_time_constant_ms()

template<typename SampleType = float>
void pulp::signal::DecayEnvelopeT< SampleType >::set_decay_time_constant_ms ( double ms)
inline

Decay expressed as an RC time constant (1/e after ms).

◆ set_hold_ms()

template<typename SampleType = float>
void pulp::signal::DecayEnvelopeT< SampleType >::set_hold_ms ( double ms)
inline

Time at full scale between the attack and the decay.

◆ set_sample_rate()

template<typename SampleType = float>
void pulp::signal::DecayEnvelopeT< SampleType >::set_sample_rate ( double sr)
inline

◆ trigger()

template<typename SampleType = float>
void pulp::signal::DecayEnvelopeT< SampleType >::trigger ( SampleType peak = SampleType{1})
inline

Starts the envelope from silence.

peak scales the whole contour, which is how velocity reaches the amplitude path.

◆ value()

template<typename SampleType = float>
SampleType pulp::signal::DecayEnvelopeT< SampleType >::value ( ) const
inline

Current level without advancing, scaled by the trigger peak.

Voices that need the same envelope value on more than one path read it once through process() and reuse it; this accessor is for the cases where a caller genuinely wants to observe without consuming.

Member Data Documentation

◆ silence_floor

template<typename SampleType = float>
double pulp::signal::DecayEnvelopeT< SampleType >::silence_floor = 1e-5
staticconstexpr

Level below which the envelope is treated as finished.

-100 dB is far under the noise floor of any format Pulp renders to.


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