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

Two decorrelated OU walks presented as the two things drift is actually wired to: a pitch ratio and a unit fraction. More...

#include <rng.hpp>

Public Member Functions

void prepare (double sample_rate)
void set_cents (double cents)
 Peak-ish pitch excursion in cents, scaled by the walk's unit output.
void set_theta (double theta_per_second)
void set_sigma (double sigma)
void seed (std::uint32_t s)
 The two walks are seeded from one user-facing seed through mix64 so they are decorrelated by construction; seeding them s and s + 1 would leave them visibly related for the first few draws.
void set_seed (std::uint32_t s)
void set_depth_percent (double percent)
void set_correlation_time (double seconds)
void reset ()
SampleType next ()
 Advance one audio sample. Call once per sample; read the outputs after.
SampleType pitch_factor () const
 Multiplicative pitch ratio: 2 ^ (cents * x / 1200).
SampleType fraction () const
 Signed unit drift, independent of the pitch walk.

Static Public Attributes

static constexpr int kDecimation = 32
 Control-rate decimation.
static constexpr double kDefaultDepthPercent = 0.1
static constexpr double kDefaultCorrelationSeconds = 2.0

Detailed Description

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

Two decorrelated OU walks presented as the two things drift is actually wired to: a pitch ratio and a unit fraction.

The walks are stepped once every kDecimation samples and interpolated between control points. An OU walk's spectrum is already low-pass — running it per sample costs a log, a sqrt, and a sincos for detail far above where drift lives — so the decimation is free in character and 32x in cost. The interpolation matters: without it the stepped control is a staircase, and a staircase on a delay length or an oscillator frequency is audible as zipper noise, not as drift.

RT contract: prepare() is control-side. next(), reset(), and the accessors allocate nothing.

USE: pitch_factor() multiplies an oscillator frequency or a resampling ratio; fraction() is a signed unit control for anything else (filter cutoff in cents, a delay-time percentage, a stereo width). Set set_cents(3) for "this is a good tape machine", 15 for "this one needs service", 40 for seasick.

Member Function Documentation

◆ fraction()

template<typename SampleType = float>
SampleType pulp::signal::DriftT< SampleType >::fraction ( ) const
inline

Signed unit drift, independent of the pitch walk.

Clamped to [-1, 1]: the underlying walk is allowed out to OuWalkT::kClamp for pitch headroom, but the unit contract is what downstream consumers — delay percentages, cutoff offsets — size against.

◆ next()

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

Advance one audio sample. Call once per sample; read the outputs after.

◆ pitch_factor()

template<typename SampleType = float>
SampleType pulp::signal::DriftT< SampleType >::pitch_factor ( ) const
inline

Multiplicative pitch ratio: 2 ^ (cents * x / 1200).

◆ prepare()

template<typename SampleType = float>
void pulp::signal::DriftT< SampleType >::prepare ( double sample_rate)
inline

◆ reset()

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

◆ seed()

template<typename SampleType = float>
void pulp::signal::DriftT< SampleType >::seed ( std::uint32_t s)
inline

The two walks are seeded from one user-facing seed through mix64 so they are decorrelated by construction; seeding them s and s + 1 would leave them visibly related for the first few draws.

◆ set_cents()

template<typename SampleType = float>
void pulp::signal::DriftT< SampleType >::set_cents ( double cents)
inline

Peak-ish pitch excursion in cents, scaled by the walk's unit output.

◆ set_correlation_time()

template<typename SampleType = float>
void pulp::signal::DriftT< SampleType >::set_correlation_time ( double seconds)
inline

◆ set_depth_percent()

template<typename SampleType = float>
void pulp::signal::DriftT< SampleType >::set_depth_percent ( double percent)
inline

◆ set_seed()

template<typename SampleType = float>
void pulp::signal::DriftT< SampleType >::set_seed ( std::uint32_t s)
inline

◆ set_sigma()

template<typename SampleType = float>
void pulp::signal::DriftT< SampleType >::set_sigma ( double sigma)
inline

◆ set_theta()

template<typename SampleType = float>
void pulp::signal::DriftT< SampleType >::set_theta ( double theta_per_second)
inline

Member Data Documentation

◆ kDecimation

template<typename SampleType = float>
int pulp::signal::DriftT< SampleType >::kDecimation = 32
staticconstexpr

Control-rate decimation.

32 samples is 0.67 ms at 48 kHz — two orders of magnitude faster than the fastest drift anyone wants.

◆ kDefaultCorrelationSeconds

template<typename SampleType = float>
double pulp::signal::DriftT< SampleType >::kDefaultCorrelationSeconds = 2.0
staticconstexpr

◆ kDefaultDepthPercent

template<typename SampleType = float>
double pulp::signal::DriftT< SampleType >::kDefaultDepthPercent = 0.1
staticconstexpr

The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/signal/include/pulp/signal/rng.hpp