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

The small modular utilities every patch reaches for between a modulation source and its destination: slew, sample-and-hold, attenuversion, rectification, comparison, quantization, and response shaping. More...

#include <pulp/signal/denormal.hpp>
#include <pulp/signal/units.hpp>
#include <algorithm>
#include <cmath>
#include <cstdint>

Go to the source code of this file.

Classes

class  pulp::signal::SlewLimiterT< SampleType >
class  pulp::signal::ConstantTimeSlewLimiterT< SampleType >
 Distance-independent portamento used by the Round-2 effect and sequencing lane. More...
class  pulp::signal::SampleHoldT< SampleType >
 Latch a value on a clock's rising edge, with optional glide to the new value instead of a step. More...
class  pulp::signal::AttenuverterT< SampleType >
 y = x * gain + offset, with gain allowed to go negative. More...
class  pulp::signal::RectifierT< SampleType >
 Full- or half-wave rectification. More...
class  pulp::signal::ComparatorT< SampleType >
 Threshold comparator with hysteresis — the bridge from the signal domain to the event domain. More...
class  pulp::signal::SignalComparatorT< SampleType >
 Signal-valued comparator from the Round-2 patching lane. More...
class  pulp::signal::QuantizerT< SampleType >
 Snap a control value to N equally spaced levels across a range. More...
class  pulp::signal::CurveT< SampleType >
 Response shaper for a unit control: the stage-curve law, or smoothstep. More...

Namespaces

namespace  pulp
namespace  pulp::signal

Typedefs

using pulp::signal::SlewLimiter = SlewLimiterT<float>
using pulp::signal::SlewLimiter64 = SlewLimiterT<double>
using pulp::signal::ConstantTimeSlewLimiter = ConstantTimeSlewLimiterT<float>
using pulp::signal::ConstantTimeSlewLimiter64 = ConstantTimeSlewLimiterT<double>
using pulp::signal::SampleHold = SampleHoldT<float>
using pulp::signal::SampleHold64 = SampleHoldT<double>
using pulp::signal::Attenuverter = AttenuverterT<float>
using pulp::signal::Attenuverter64 = AttenuverterT<double>
using pulp::signal::Rectifier = RectifierT<float>
using pulp::signal::Rectifier64 = RectifierT<double>
using pulp::signal::Comparator = ComparatorT<float>
using pulp::signal::Comparator64 = ComparatorT<double>
using pulp::signal::SignalComparator = SignalComparatorT<float>
using pulp::signal::SignalComparator64 = SignalComparatorT<double>
using pulp::signal::Quantizer = QuantizerT<float>
using pulp::signal::Quantizer64 = QuantizerT<double>
using pulp::signal::Curve = CurveT<float>
using pulp::signal::Curve64 = CurveT<double>

Enumerations

enum class  pulp::signal::SlewMode : std::uint8_t { pulp::signal::linear , pulp::signal::exponential }
 Rate limiter with independent rise and fall speeds. More...

Functions

float pulp::signal::stage_curve (float p, float curve)
 The shared stage-shaping law:
float pulp::signal::curve_rise (float p, float curve)
 Shape a rising stage: 0 -> 1 over p, with curve in [-1, +1].
float pulp::signal::curve_fall (float p, float curve)
 Shape a falling stage: 1 -> 0 over p.
float pulp::signal::smoothstep (float p)
 Cubic smoothstep, 3t^2 - 2t^3.
float pulp::signal::bi_to_uni (float x)
 Bipolar [-1, 1] to unipolar [0, 1].
float pulp::signal::uni_to_bi (float x)
 Unipolar [0, 1] to bipolar [-1, 1].

Variables

constexpr float pulp::signal::kCurveSpan = 8.0f
 Curve span for the shared stage-shaping law.

Detailed Description

The small modular utilities every patch reaches for between a modulation source and its destination: slew, sample-and-hold, attenuversion, rectification, comparison, quantization, and response shaping.

Plus the stage-curve law the envelope and burst families share.

RT contract: every type here holds fixed scalar state and owns no memory. prepare() and the set_*() setters recompute coefficients and are control-side calls; process(), next(), reset(), and the accessors allocate nothing and are audio-thread safe. All free functions are pure.

USE: these are the wires, not the sources. A modulation routing that reads lfo -> slew -> attenuverter -> destination is one that can be reasoned about and tested; the same behavior open-coded into a process() loop is three magic constants nobody will dare change later.