Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
envelope.hpp File Reference

The envelope family — AR, AD, AHD, DAHDSR, and a trigger-driven modulation envelope — plus a level-independent transient detector. More...

#include <pulp/signal/ballistics_filter.hpp>
#include <pulp/signal/mod_tools.hpp>
#include <algorithm>
#include <cmath>
#include <cstdint>

Go to the source code of this file.

Classes

struct  pulp::signal::detail::EnvelopeStageClock
 Sample counter for one envelope stage. More...
class  pulp::signal::detail::EnvelopeEngine< SampleType >
 The DAHDSR superset state machine. More...
class  pulp::signal::ArT< SampleType >
 Attack-Release, gate-driven. More...
class  pulp::signal::AdT< SampleType >
 Attack-Decay one-shot, trigger-driven. More...
class  pulp::signal::AhdT< SampleType >
 Attack-Hold-Decay one-shot, trigger-driven. More...
class  pulp::signal::DahdsrT< SampleType >
 Delay-Attack-Hold-Decay-Sustain-Release with per-stage curves and velocity. More...
class  pulp::signal::ModEnvT< SampleType >
 Delay-Attack-Hold-Decay modulation envelope with a signed depth. More...
class  pulp::signal::TransientDetectorT< SampleType >
 Level-independent transient detector: the normalized excess of a fast envelope follower over a slow one. More...

Namespaces

namespace  pulp
namespace  pulp::signal
namespace  pulp::signal::detail
 Round-2 effect-wave vocabulary.

Typedefs

using pulp::signal::Ar = ArT<float>
using pulp::signal::Ar64 = ArT<double>
using pulp::signal::Ad = AdT<float>
using pulp::signal::Ad64 = AdT<double>
using pulp::signal::Ahd = AhdT<float>
using pulp::signal::Ahd64 = AhdT<double>
using pulp::signal::Dahdsr = DahdsrT<float>
using pulp::signal::Dahdsr64 = DahdsrT<double>
using pulp::signal::ModEnv = ModEnvT<float>
using pulp::signal::ModEnv64 = ModEnvT<double>
using pulp::signal::TransientDetector = TransientDetectorT<float>
using pulp::signal::TransientDetector64 = TransientDetectorT<double>

Enumerations

enum class  pulp::signal::EnvelopeStage : std::uint8_t {
  pulp::signal::idle , pulp::signal::delay , pulp::signal::attack , pulp::signal::hold ,
  pulp::signal::decay , pulp::signal::sustain , pulp::signal::release
}
 Stage of any envelope in this header. More...

Functions

long long pulp::signal::detail::envelope_ms_to_samples (double ms, double sample_rate)

Detailed Description

The envelope family — AR, AD, AHD, DAHDSR, and a trigger-driven modulation envelope — plus a level-independent transient detector.

AdsrT (adsr.hpp) is the existing keyboard envelope and stays exactly as it is. Everything here is additive: the shapes it does not cover, and the one superset to reach for when it is not enough.

RT contract: every type here holds fixed scalar state and owns no memory. prepare() and the set_*() setters are control-side calls; trigger(), gate(), note_on(), note_off(), next(), reset(), and the accessors allocate nothing and are audio-thread safe.

USE — the whole point of having five of these is that reaching for the right one is cheaper than configuring the wrong one:

  • ArT is the sustained-gate workhorse: pad and drone VCAs, gate-CV amplitude, sidechain duck-and-recover shapes (invert it with an AttenuverterT). When a sound has no decay stage, use this, not an ADSR with sustain pinned to 1.
  • AdT is percussion and plucks from triggers, and modulation blips like filter pings — anything fired by an event rather than held by a key.
  • AhdT is drum voices and sample playback: the hold keeps the transient and body at full level for a defined window before the tail. It is also how you get gate-length-independent chopped shapes, with the hold as the chop length.
  • AdsrT (existing) is keyboard and sustain instruments — the note-length-aware classic. Do not extend it; reach for DahdsrT.
  • DahdsrT is the superset for layered and orchestral patches. The delay staggers layers (a swell pad under a pluck), the hold shapes the pre-decay plateau, and per-stage curves match sampled-instrument contours. When in doubt in a mod matrix, this is the mod source.
  • Looping on AdT / AhdT / DahdsrT gives envelope-as-LFO hybrids: rhythmic swells that are shaped rather than symmetric. With synced stage times it is a groove-locked modulation sequence from one primitive.
  • ModEnvT is per-hit modulation shaping — filter sweep depth per drum hit, pitch-drop envelopes. Trigger-driven, ignores gates, signed depth.
  • TransientDetectorT is level-independent attack detection: input duckers, adaptive transient shapers, "how hard was that hit" as a mod source.