Contents

class

SushiDSP::SmoothedParameter

First-order (one-pole) parameter smoother with a time constant in milliseconds, derived from the sample rate at prepare() so a knob feels the same at every rate and block size.

Declared in
include/SushiDSP/math/SmoothedParameter.hpp

set_target() is a single float store and is safe to call from the audio thread; all advancing happens on the audio thread.

Public member functions

explicit SmoothedParameter(float initial_value=0.0f)

Parameters

initial_value

Value both current and target start at.

void prepare(double sample_rate, float time_constant_ms)

Derives the per-sample coefficient.

Control thread only.

Parameters

sample_rate

The rate next() will be called at (base or oversampled).

time_constant_ms

Time to reach 63 % of a step.

void set_target(float target)

Sets the value the smoother moves toward.

Parameters

target

The new target.

float next()

Advances one sample.

Returns

The smoothed value after this sample.

float skip(std::uint32_t samples)

Advances samples samples in one step (closed form).

Parameters

samples

Number of samples to advance.

Returns

The smoothed value after those samples.

float current() const

The current smoothed value.

float target() const

The target value.

bool is_settled(float tolerance=1e-6f) const

Whether |current - target| is within tolerance.

Parameters

tolerance

Absolute tolerance.

Returns

True when settled.

void snap(float value)

Sets current and target to value with no ramp.

Parameters

value

The value to snap to.