6#ifndef SBL_DSP_FILTERS_SVF_HPP_
7#define SBL_DSP_FILTERS_SVF_HPP_
81 static constexpr float Q_MIN = 0.5f;
82 static constexpr float Q_MAX = 32.0f;
135 const float hp = (x - (g + damping) * s1_ - s2_) / (1.0f + g * (g + damping));
136 const float bp = g * hp + s1_;
138 const float lp = g * bp + s2_;
152 static float allpass_mix(
float x,
float bp,
float damping,
float mix) {
return x - 2.0f * mix * damping * bp; }
193 response_ =
static_cast<Response>(
static_cast<uint8_t
>(i + 0.5f));
223 template<
class... Ports>
224 void process(
const float* in,
float* out, uint16_t frames, Ports... ports) {
226 "SBL ERROR: Svf's buffer form takes cutoff and q, each a block or a scalar");
227 const auto cutoff = transport::arg<0>(ports...);
228 const auto q = transport::arg<1>(ports...);
229 if constexpr (transport::is_scalar_v<
decltype(cutoff)>) {
232 if constexpr (transport::is_scalar_v<
decltype(q)>) {
237 float damping = 0.0f;
238 for (uint16_t i = 0; i < frames; ++i) {
239 if constexpr (transport::is_block_v<
decltype(cutoff)>) {
244 if constexpr (transport::is_block_v<
decltype(q)>) {
247 damping = damping_.
step();
249 const float x = in[i];
253 if constexpr (transport::is_block_v<
decltype(cutoff)>) {
256 if constexpr (transport::is_block_v<
decltype(q)>) {
257 damping_.
jump(damping);
A linear ramp to a target over a fixed number of frames.
float target() const
The value the ramp heads for.
void head(float target)
set(), except that the first value given since construction, by head() or jump(), is arrived at at on...
void jump(float value)
Arrive at a value at once.
void set_length(uint16_t frames)
Set how many frames a ramp takes.
A trapezoidal state-variable filter with five responses from one section.
Response
What the buffer form renders.
static float response(Response which, float x, const Taps &taps, float damping)
A response from a frame: its input, its taps and the damping it ran at.
void set_response(Response which)
Parameter: the response the buffer form renders. The low-pass until set.
static constexpr float Q_MIN
void set_response_index(float index)
set_response() by number, for a tool's flag.
static constexpr float CUTOFF_MIN
static constexpr transport::Parameter< Svf > PARAMETERS[]
The parameters, for tools.
static float damping_for(float q)
The damping k = 1 / Q.
static constexpr float Q_MAX
Response response() const
The response the buffer form renders.
Svf()
Integrators at rest; the buffer form renders the low-pass and ramps its scalar ports over RAMP_FRAMES...
static float allpass_mix(float x, float bp, float damping, float mix)
The all-pass mix of a frame: x - 2 mix damping bp.
static constexpr uint16_t RAMP_FRAMES
static constexpr transport::Port PORTS[]
The ports of the buffer form, in the order it takes them.
static float integrator_gain_for(float cutoff_cycles_per_frame)
The integrator gain g = tan(pi cutoff) for a center.
static constexpr float CUTOFF_MAX
void process(const float *in, float *out, uint16_t frames, Ports... ports)
The chosen response over a buffer, the ports in PORTS' order, both given.
static constexpr float CUTOFF_ERROR_CENTS
Taps process(float x, float g, float damping)
One frame.
void reset()
Both integrators at rest, and the buffer form's coefficients at their targets.
Fast analytical approximations of sin, tan, 2^x and tanh.
Finiteness of a float, read from its bits, and a fallback for a value that is not finite.
float fast_tan_pif(float f)
Fast tan(pi f) for normalized frequency f in [0, 0.497].
constexpr T clamp(T x, T lo, T hi)
x held to [lo, hi]; a NaN goes to lo.
A linear ramp to a target over a fixed number of frames.
One frame's taps. bp peaks at Q; damping * bp peaks at 1.
The processing call's shape as a checked contract.