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

Sample-and-hold rate reducer with clock jitter and a reconstruction filter. More...

#include <lofi_chain.hpp>

Public Member Functions

void set_sample_rate (double sr)
void set_hold_rate_hz (double hz)
 Rate the held samples are clocked at, in Hz.
void set_jitter (double amount)
 Clock jitter as a fraction of the hold period, 0 to 1.
void set_smoothing (double amount)
 Strength of the reconstruction lowpass, 0 (bypassed, raw images) to 1 (corner at the hold rate's Nyquist).
void set_seed (std::uint32_t seed)
void sync_configuration_from (const SampleRateReducerT &other)
 Mirror another reducer's parameter configuration without copying its held sample, clock phase, filter history, or RNG position.
void reset ()
bool has_tail () const noexcept
SampleType process (SampleType input)

Static Public Attributes

static constexpr std::uint32_t default_seed = 0x6A09E667u

Detailed Description

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

Sample-and-hold rate reducer with clock jitter and a reconstruction filter.

Holding a sample for several output samples is a zero-order hold, which mirrors the signal around the hold rate. Those images are the point — they are the grit that a "lo-fi" control is asked for — but they can be more than a caller wants, so the class ends with a one-pole lowpass whose corner tracks the hold rate and thins them out. Callers who want the raw folded spectrum set the smoothing to zero.

The jitter perturbs the hold clock's period rather than its output. Early samplers clocked their converters from free-running oscillators with no phase relationship to the audio, so the hold boundaries drifted; that drift broadens the image skirts and is why an emulation with a perfectly regular hold sounds cleaner than the hardware it models. Jitter is driven by a deterministic generator so a render stays reproducible.

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

Member Function Documentation

◆ has_tail()

template<typename SampleType = float>
bool pulp::signal::SampleRateReducerT< SampleType >::has_tail ( ) const
inlinenoexcept

◆ process()

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

◆ reset()

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

◆ set_hold_rate_hz()

template<typename SampleType = float>
void pulp::signal::SampleRateReducerT< SampleType >::set_hold_rate_hz ( double hz)
inline

Rate the held samples are clocked at, in Hz.

Clamped to the sample rate, at or above which the reducer is transparent. The default is unbounded rather than a fixed number of Hz, so an unconfigured reducer stays transparent at every sample rate instead of quietly decimating whenever the host runs faster than whatever default was chosen.

◆ set_jitter()

template<typename SampleType = float>
void pulp::signal::SampleRateReducerT< SampleType >::set_jitter ( double amount)
inline

Clock jitter as a fraction of the hold period, 0 to 1.

◆ set_sample_rate()

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

◆ set_seed()

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

◆ set_smoothing()

template<typename SampleType = float>
void pulp::signal::SampleRateReducerT< SampleType >::set_smoothing ( double amount)
inline

Strength of the reconstruction lowpass, 0 (bypassed, raw images) to 1 (corner at the hold rate's Nyquist).

One pole is a gentle slope, so this attenuates the images rather than removing them — which is the behaviour of the reconstruction filters the stage models, and leaves enough of the hold's character to still be worth having.

◆ sync_configuration_from()

template<typename SampleType = float>
void pulp::signal::SampleRateReducerT< SampleType >::sync_configuration_from ( const SampleRateReducerT< SampleType > & other)
inline

Mirror another reducer's parameter configuration without copying its held sample, clock phase, filter history, or RNG position.

Member Data Documentation

◆ default_seed

template<typename SampleType = float>
std::uint32_t pulp::signal::SampleRateReducerT< SampleType >::default_seed = 0x6A09E667u
staticconstexpr

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