Class thl::dsp::sampler::FadeCurve#

class FadeCurve#

Quarter-sine crossfade table.

at(k) = sin(k / length * pi / 2) for integer k in [0, length]. Because cos(t * pi/2) == sin((1 - t) * pi/2), one table serves the fade in and the fade out exactly: no interpolation and no sin/cos on the audio thread.

Real-Time Safety

prepare() allocates; every other member is real-time safe.

Public Functions

inline void prepare(size_t length)#

Build the table for a fade of length steps (at least 1).

inline size_t length() const#
inline float at(double t) const#

Gain at fade position t in [0, 1] (nearest step): 0 -> 0, 1 -> 1.

inline float in_gain(size_t remaining) const#

Fade-in gain with remaining of length() steps left (0 left = 1).

inline float out_gain(size_t remaining) const#

Fade-out gain with remaining of length() steps left.