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

Latch a value on a clock's rising edge, with optional glide to the new value instead of a step. More...

#include <mod_tools.hpp>

Public Member Functions

void prepare (SampleType sample_rate)
void set_threshold (SampleType threshold)
void set_glide_ms (SampleType ms)
 0 disables the glide entirely (the output steps).
void set_glide_mode (typename SlewLimiterT< SampleType >::Mode m)
void reset (SampleType value=SampleType{0})
SampleType process (SampleType input, bool clock)
SampleType process_signal (SampleType input, SampleType trigger)
 Explicit signal-threshold spelling used by the Round-2 sequencing kit.
SampleType held () const
 The latched value before any glide — what the last clock actually saw.
SampleType value () const

Static Public Attributes

static constexpr double kDefaultThreshold = 0.5

Detailed Description

template<typename SampleType = float>
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.

RT contract: prepare() and setters are control-side; process() and reset() allocate nothing.

USE: the classic random-step patch (a clock plus a noise source is a sequencer nobody has to write); freezing an LFO or envelope value at note-on so a per-note variation stays put for the note's duration; turning a continuous controller into a stepped one. The glide is what separates "S&H on a filter cutoff" from "S&H on a filter cutoff that does not click".

Member Function Documentation

◆ held()

template<typename SampleType = float>
SampleType pulp::signal::SampleHoldT< SampleType >::held ( ) const
inline

The latched value before any glide — what the last clock actually saw.

◆ prepare()

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

◆ process()

template<typename SampleType = float>
SampleType pulp::signal::SampleHoldT< SampleType >::process ( SampleType input,
bool clock )
inline
Parameters
inputthe value to latch when the clock rises.
clocka gate; the rising edge is the sample instant.

◆ process_signal()

template<typename SampleType = float>
SampleType pulp::signal::SampleHoldT< SampleType >::process_signal ( SampleType input,
SampleType trigger )
inline

Explicit signal-threshold spelling used by the Round-2 sequencing kit.

Keeping a different name avoids ambiguous calls such as process(input, 1) between the bool and signal domains.

◆ reset()

template<typename SampleType = float>
void pulp::signal::SampleHoldT< SampleType >::reset ( SampleType value = SampleType{0})
inline

◆ set_glide_mode()

template<typename SampleType = float>
void pulp::signal::SampleHoldT< SampleType >::set_glide_mode ( typename SlewLimiterT< SampleType >::Mode m)
inline

◆ set_glide_ms()

template<typename SampleType = float>
void pulp::signal::SampleHoldT< SampleType >::set_glide_ms ( SampleType ms)
inline

0 disables the glide entirely (the output steps).

◆ set_threshold()

template<typename SampleType = float>
void pulp::signal::SampleHoldT< SampleType >::set_threshold ( SampleType threshold)
inline

◆ value()

template<typename SampleType = float>
SampleType pulp::signal::SampleHoldT< SampleType >::value ( ) const
inline

Member Data Documentation

◆ kDefaultThreshold

template<typename SampleType = float>
double pulp::signal::SampleHoldT< SampleType >::kDefaultThreshold = 0.5
staticconstexpr

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