DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
LadderFilter.h
1// DSPark - Professional Audio DSP Framework
2// Copyright (c) 2026 Cristian Moresi - MIT License
3
4#pragma once
5
32#include "DspMath.h"
33#include "AudioSpec.h"
34#include "AudioBuffer.h"
35#include "DenormalGuard.h"
36#include "StateBlob.h"
37#include "detail/LadderZdf.h"
38
39#include <algorithm>
40#include <array>
41#include <atomic>
42#include <cmath>
43#include <cstddef>
44#include <cstdint>
45#include <vector>
46
47namespace dspark {
48
119template <FloatType T>
121{
122public:
124 enum class Mode
125 {
126 LP6,
127 LP12,
128 LP18,
129 LP24,
130 BP12,
131 HP24
132 };
133
135 enum class Saturation
136 {
137 Feedback,
138 Stages,
139 Input
140 };
141
143 static constexpr double kMaxResonance = 1.2;
144
145 ~LadderFilter() = default;
146
147 // -- Lifecycle --------------------------------------------------------------
148
157 void prepare(const AudioSpec& spec) noexcept
158 {
159 if (!(spec.sampleRate > 0.0)) return;
160 spec_ = spec;
161 updateCoefficients();
162 reset();
163 }
164
175 void processBlock(AudioBufferView<T> buffer) noexcept
176 {
177 DenormalGuard guard;
178 const int nCh = std::min(buffer.getNumChannels(), kMaxChannels);
179 const int nS = buffer.getNumSamples();
180
181 // Local snapshot to guarantee thread-safety and avoid mid-block changes
182 const T currentG = g_.load(std::memory_order_relaxed);
183 const T storedRes = resonance_.load(std::memory_order_relaxed);
184 const T currentDrive = drive_.load(std::memory_order_relaxed);
185 const Mode currentMode = mode_.load(std::memory_order_relaxed);
186 const Saturation model = saturation_.load(std::memory_order_relaxed);
187
188 if (model == Saturation::Input)
189 {
190 processBlockInput(buffer, nCh, nS,
191 inputCoeffs(cutoff_.load(std::memory_order_relaxed), storedRes, currentDrive),
192 currentMode);
193 return;
194 }
195 // The other models take the integrator states back from the Input model.
196 for (int ch = 0; ch < nCh; ++ch) leaveInput(state_[ch]);
197
198 if (model == Saturation::Stages)
199 {
200 processBlockStages(buffer, nCh, nS,
201 detail::makeLadderStageCoeffs(currentG, storedRes, currentDrive),
202 currentMode);
203 return;
204 }
205
206 // The Feedback model stops at the self-oscillation boundary.
207 const T currentRes = std::min(storedRes, T(1));
208
209 // Template dispatch to eliminate per-sample branching
210 switch (currentMode)
211 {
212 case Mode::LP6: processBlockInternal<Mode::LP6>(buffer, nCh, nS, currentG, currentRes, currentDrive); break;
213 case Mode::LP12: processBlockInternal<Mode::LP12>(buffer, nCh, nS, currentG, currentRes, currentDrive); break;
214 case Mode::LP18: processBlockInternal<Mode::LP18>(buffer, nCh, nS, currentG, currentRes, currentDrive); break;
215 case Mode::LP24: processBlockInternal<Mode::LP24>(buffer, nCh, nS, currentG, currentRes, currentDrive); break;
216 case Mode::BP12: processBlockInternal<Mode::BP12>(buffer, nCh, nS, currentG, currentRes, currentDrive); break;
217 case Mode::HP24: processBlockInternal<Mode::HP24>(buffer, nCh, nS, currentG, currentRes, currentDrive); break;
218 }
219 }
220
237 [[nodiscard]] T processSample(T input, int channel) noexcept
238 {
239 if (channel < 0 || channel >= kMaxChannels) return input;
240
241 const T g = g_.load(std::memory_order_relaxed);
242 const T res = resonance_.load(std::memory_order_relaxed);
243 const T drive = drive_.load(std::memory_order_relaxed);
244 ChannelState& s = state_[channel];
245 const Saturation model = saturation_.load(std::memory_order_relaxed);
246
247 if (model == Saturation::Input)
248 {
249 const auto& ic = inputCoeffs(cutoff_.load(std::memory_order_relaxed), res, drive);
250 switch (mode_.load(std::memory_order_relaxed))
251 {
252 case Mode::LP6: return inputSample<detail::LadderTap::LP6>(input, s, ic);
253 case Mode::LP12: return inputSample<detail::LadderTap::LP12>(input, s, ic);
254 case Mode::LP18: return inputSample<detail::LadderTap::LP18>(input, s, ic);
255 case Mode::LP24: return inputSample<detail::LadderTap::LP24>(input, s, ic);
256 case Mode::BP12: return inputSample<detail::LadderTap::BP12>(input, s, ic);
257 case Mode::HP24: return inputSample<detail::LadderTap::HP24>(input, s, ic);
258 }
259 return input;
260 }
261 leaveInput(s);
262
263 if (model == Saturation::Stages)
264 {
265 const auto sc = detail::makeLadderStageCoeffs(g, res, drive);
266 switch (mode_.load(std::memory_order_relaxed))
267 {
268 case Mode::LP6: return detail::ladderStepStages<detail::LadderTap::LP6>(input, s.z, sc);
269 case Mode::LP12: return detail::ladderStepStages<detail::LadderTap::LP12>(input, s.z, sc);
270 case Mode::LP18: return detail::ladderStepStages<detail::LadderTap::LP18>(input, s.z, sc);
271 case Mode::LP24: return detail::ladderStepStages<detail::LadderTap::LP24>(input, s.z, sc);
272 case Mode::BP12: return detail::ladderStepStages<detail::LadderTap::BP12>(input, s.z, sc);
273 case Mode::HP24: return detail::ladderStepStages<detail::LadderTap::HP24>(input, s.z, sc);
274 }
275 return input;
276 }
277
278 const BlockCoeffs c = makeBlockCoeffs(g, std::min(res, T(1)));
279
280 switch (mode_.load(std::memory_order_relaxed))
281 {
282 case Mode::LP6: return processSampleInternal<Mode::LP6>(input, s, c, drive);
283 case Mode::LP12: return processSampleInternal<Mode::LP12>(input, s, c, drive);
284 case Mode::LP18: return processSampleInternal<Mode::LP18>(input, s, c, drive);
285 case Mode::LP24: return processSampleInternal<Mode::LP24>(input, s, c, drive);
286 case Mode::BP12: return processSampleInternal<Mode::BP12>(input, s, c, drive);
287 case Mode::HP24: return processSampleInternal<Mode::HP24>(input, s, c, drive);
288 }
289 return input;
290 }
291
298 void reset() noexcept
299 {
300 for (auto& s : state_)
301 {
302 s.z.fill(T(0));
303 s.input = {};
304 s.inputLive = false;
305 }
306 }
307
308 // -- Parameters -------------------------------------------------------------
309
321 void setCutoff(T hz) noexcept
322 {
323 if (!std::isfinite(hz)) return;
324 cutoff_.store(std::max(hz, T(0)), std::memory_order_relaxed);
325 updateCoefficients();
326 }
327
338 void setResonance(T amount) noexcept
339 {
340 if (!std::isfinite(amount)) return; // NaN would poison the loop via k
341 resonance_.store(std::clamp(amount, T(0), static_cast<T>(kMaxResonance)),
342 std::memory_order_relaxed);
343 }
344
354 void setDrive(T amount) noexcept
355 {
356 if (!std::isfinite(amount)) return; // Inf turns 0 * drive into NaN
357 drive_.store(std::max(amount, T(0.1)), std::memory_order_relaxed);
358 }
359
364 void setMode(Mode mode) noexcept
365 {
366 mode_.store(mode, std::memory_order_relaxed);
367 }
368
395 void setSaturation(Saturation model) noexcept
396 {
397 const bool known = model == Saturation::Stages || model == Saturation::Input;
398 saturation_.store(known ? model : Saturation::Feedback, std::memory_order_relaxed);
399 }
400
401 // -- State (setup/UI thread) ------------------------------------------------
402
404 [[nodiscard]] std::vector<uint8_t> getState() const
405 {
406 // The blob stores float: the casts keep the double instantiation
407 // compiling (a double matches no StateWriter overload unambiguously).
408 StateWriter w(stateId("LADR"), 1);
409 w.write("cutoff", static_cast<float>(cutoff_.load(std::memory_order_relaxed)));
410 w.write("resonance", static_cast<float>(resonance_.load(std::memory_order_relaxed)));
411 w.write("drive", static_cast<float>(drive_.load(std::memory_order_relaxed)));
412 w.write("mode", static_cast<int32_t>(mode_.load(std::memory_order_relaxed)));
413 w.write("saturation", static_cast<int32_t>(saturation_.load(std::memory_order_relaxed)));
414 return w.blob();
415 }
416
423 bool setState(const uint8_t* data, size_t size)
424 {
425 StateReader r(data, size);
426 if (!r.isValid() || r.processorId() != stateId("LADR")) return false;
427 setCutoff(static_cast<T>(r.read("cutoff", 1000.0f)));
428 setResonance(static_cast<T>(r.read("resonance", 0.0f)));
429 setDrive(static_cast<T>(r.read("drive", 1.0f)));
430 const int mode = std::clamp(r.read("mode", static_cast<int32_t>(Mode::LP24)),
431 0, static_cast<int32_t>(Mode::HP24));
432 setMode(static_cast<Mode>(mode));
433 setSaturation(static_cast<Saturation>(r.read("saturation", 0)));
434 return true;
435 }
436
437 [[nodiscard]] T getCutoff() const noexcept { return cutoff_.load(std::memory_order_relaxed); }
438 [[nodiscard]] T getResonance() const noexcept { return resonance_.load(std::memory_order_relaxed); }
439 [[nodiscard]] T getDrive() const noexcept { return drive_.load(std::memory_order_relaxed); }
440 [[nodiscard]] Mode getMode() const noexcept { return mode_.load(std::memory_order_relaxed); }
441 [[nodiscard]] Saturation getSaturation() const noexcept { return saturation_.load(std::memory_order_relaxed); }
442
443protected:
444 static constexpr int kMaxChannels = 16;
445
446 // Scalar per-channel state - no SIMD kernel ever touches it, and adjacent
447 // channels sharing a cache line is better locality than padded isolation,
448 // so it is deliberately not over-aligned. The stage tap outputs are NOT
449 // state (each sample overwrites all of them), so they live in registers
450 // inside processSampleInternal().
452 {
453 std::array<T, 4> z {}; // TPT integrator states (z^-1 equivalents)
454 detail::LadderInputState input {}; // Input model: its own state, in double
455 bool inputLive = false; // whether the Input model holds the stream
456 };
457
458 std::array<ChannelState, kMaxChannels> state_ {};
460
461 // Coefficients of the Input model, rebuilt on the audio thread when a
462 // parameter it was derived from changes.
464 {
465 T cutoff = T(-1), resonance = T(-1), drive = T(-1);
466 double sampleRate = 0.0;
468 };
470
471 // Atomic variables for thread-safety between Audio Thread and UI/Main Thread
472 std::atomic<T> cutoff_ {T(1000)};
473 std::atomic<T> resonance_ {T(0)};
474 std::atomic<T> drive_ {T(1)};
475 std::atomic<T> g_ {T(0)};
476 std::atomic<Mode> mode_ {Mode::LP24};
477 std::atomic<Saturation> saturation_ {Saturation::Feedback};
478
479private:
486 void updateCoefficients() noexcept
487 {
488 if (!(spec_.sampleRate > 0.0)) return;
489 const T clamped = std::clamp(cutoff_.load(std::memory_order_relaxed),
490 T(20), static_cast<T>(spec_.sampleRate) * T(0.499));
491 cutoff_.store(clamped, std::memory_order_relaxed);
492 const T preWarpedGain = static_cast<T>(std::tan(pi<double> * static_cast<double>(clamped) / spec_.sampleRate));
493 g_.store(preWarpedGain, std::memory_order_relaxed);
494 }
495
497 using BlockCoeffs = detail::LadderCoeffs<T>;
498
500 [[nodiscard]] static BlockCoeffs makeBlockCoeffs(T g, T res) noexcept
501 {
502 return detail::makeLadderCoeffs(g, res);
503 }
504
506 template <Mode FilterMode>
507 void processBlockInternal(AudioBufferView<T> buffer, int nCh, int nS, T g, T res, T drive) noexcept
508 {
509 // Precompute the block-constant coefficients ONCE (previously these two
510 // divisions ran for every sample of every channel).
511 const BlockCoeffs c = makeBlockCoeffs(g, res);
512
513 for (int ch = 0; ch < nCh; ++ch)
514 {
515 auto* channelData = buffer.getChannel(ch);
516 // Integrators in a local: the sample pointer cannot alias it, so it
517 // stays in registers (11.3 -> 9.8 ns/sample measured, same output).
518 std::array<T, 4> z = state_[ch].z;
519
520 for (int i = 0; i < nS; ++i)
521 channelData[i] = detail::ladderStep<tapOf(FilterMode)>(channelData[i], z, c, drive);
522
523 // A NaN or Inf sample that reached the recursion is cleared once
524 // per block, so the channel recovers instead of staying NaN.
525 if (!std::isfinite(z[0] + z[1] + z[2] + z[3])) z.fill(T(0));
526 state_[ch].z = z;
527 }
528 }
529
536 [[nodiscard]] const detail::LadderInputCoeffs& inputCoeffs(T cutoff, T res, T drive) noexcept
537 {
538 InputCache& cache = inputCache_;
539 const bool same = cutoff == cache.cutoff && res == cache.resonance && drive == cache.drive
540 && spec_.sampleRate == cache.sampleRate;
541 if (!same)
542 {
543 cache.coeffs = detail::makeLadderInputCoeffs(static_cast<double>(cutoff) / spec_.sampleRate, res, drive);
544 for (auto& s : state_)
545 if (s.inputLive) detail::ladderInputRefresh(s.input, cache.coeffs);
546 cache.cutoff = cutoff;
547 cache.resonance = res;
548 cache.drive = drive;
549 cache.sampleRate = spec_.sampleRate;
550 }
551 return cache.coeffs;
552 }
553
555 static void leaveInput(ChannelState& s) noexcept
556 {
557 if (!s.inputLive) return;
558 for (size_t i = 0; i < 4; ++i) s.z[i] = static_cast<T>(s.input.q[i]);
559 s.inputLive = false;
560 }
561
573 template <detail::LadderTap Tap>
574 [[nodiscard]] T inputSample(T input, ChannelState& s, const detail::LadderInputCoeffs& c) noexcept
575 {
576 const bool first = !s.inputLive;
577 if (first) [[unlikely]]
578 {
579 s.input = {};
580 for (size_t i = 0; i < 4; ++i) s.input.q[i] = static_cast<double>(s.z[i]);
581 detail::ladderInputRefresh(s.input, c);
582 s.input.input = static_cast<double>(input);
583 s.inputLive = true;
584 }
585 T y = detail::ladderStepInput<Tap>(input, s.input, c);
586 if (first) [[unlikely]]
587 {
588 const double mean = s.input.output / (1.0 + c.post);
589 s.input.output = mean;
590 y = static_cast<T>(mean);
591 }
592 return y;
593 }
594
596 void processBlockInput(AudioBufferView<T> buffer, int nCh, int nS,
597 const detail::LadderInputCoeffs& c, Mode mode) noexcept
598 {
599 switch (mode)
600 {
601 case Mode::LP6: inputLoop<detail::LadderTap::LP6>(buffer, nCh, nS, c); break;
602 case Mode::LP12: inputLoop<detail::LadderTap::LP12>(buffer, nCh, nS, c); break;
603 case Mode::LP18: inputLoop<detail::LadderTap::LP18>(buffer, nCh, nS, c); break;
604 case Mode::LP24: inputLoop<detail::LadderTap::LP24>(buffer, nCh, nS, c); break;
605 case Mode::BP12: inputLoop<detail::LadderTap::BP12>(buffer, nCh, nS, c); break;
606 case Mode::HP24: inputLoop<detail::LadderTap::HP24>(buffer, nCh, nS, c); break;
607 }
608 }
609
611 static void recoverInput(detail::LadderInputState& h) noexcept
612 {
613 if (!std::isfinite(((h.q[0] + h.q[1]) + (h.q[2] + h.q[3])) + ((h.input + h.output) + h.ahead)
614 + (h.loopStates + h.loopDrive)))
615 h = {};
616 }
617
618 template <detail::LadderTap Tap>
619 void inputLoop(AudioBufferView<T> buffer, int nCh, int nS, const detail::LadderInputCoeffs& c) noexcept
620 {
621 if (nS <= 0) return;
622 int ch = 0;
623 // Channel pairs advance together, sub-step by sub-step: the two
624 // solves are independent, so their dependency chains overlap (same
625 // arithmetic per channel, identical output).
626 for (; ch + 1 < nCh; ch += 2)
627 {
628 auto* a = buffer.getChannel(ch);
629 auto* b = buffer.getChannel(ch + 1);
630 ChannelState& sa = state_[ch];
631 ChannelState& sb = state_[ch + 1];
632 int i = 0;
633 if (!sa.inputLive || !sb.inputLive)
634 {
635 a[0] = inputSample<Tap>(a[0], sa, c);
636 b[0] = inputSample<Tap>(b[0], sb, c);
637 i = 1;
638 }
639 // The states in locals: the sample pointers cannot alias them.
640 detail::LadderInputState ha = sa.input, hb = sb.input;
641 for (; i < nS; ++i)
642 detail::ladderStepInputPair<Tap>(a[i], b[i], ha, hb, c);
643 // Same per-block NaN recovery as the other models.
644 recoverInput(ha);
645 recoverInput(hb);
646 sa.input = ha;
647 sb.input = hb;
648 }
649 for (; ch < nCh; ++ch)
650 {
651 auto* channelData = buffer.getChannel(ch);
652 ChannelState& s = state_[ch];
653 int i = 0;
654 if (!s.inputLive)
655 {
656 channelData[0] = inputSample<Tap>(channelData[0], s, c);
657 i = 1;
658 }
659 detail::LadderInputState h = s.input;
660 for (; i < nS; ++i)
661 channelData[i] = detail::ladderStepInput<Tap>(channelData[i], h, c);
662 recoverInput(h);
663 s.input = h;
664 }
665 }
666
668 void processBlockStages(AudioBufferView<T> buffer, int nCh, int nS,
669 const detail::LadderStageCoeffs& c, Mode mode) noexcept
670 {
671 switch (mode)
672 {
673 case Mode::LP6: stagesLoop<detail::LadderTap::LP6>(buffer, nCh, nS, c); break;
674 case Mode::LP12: stagesLoop<detail::LadderTap::LP12>(buffer, nCh, nS, c); break;
675 case Mode::LP18: stagesLoop<detail::LadderTap::LP18>(buffer, nCh, nS, c); break;
676 case Mode::LP24: stagesLoop<detail::LadderTap::LP24>(buffer, nCh, nS, c); break;
677 case Mode::BP12: stagesLoop<detail::LadderTap::BP12>(buffer, nCh, nS, c); break;
678 case Mode::HP24: stagesLoop<detail::LadderTap::HP24>(buffer, nCh, nS, c); break;
679 }
680 }
681
682 template <detail::LadderTap Tap>
683 void stagesLoop(AudioBufferView<T> buffer, int nCh, int nS, const detail::LadderStageCoeffs& c) noexcept
684 {
685 int ch = 0;
686 // Channel pairs advance together, one sample of each per iteration:
687 // the two solves are independent, so their dependency chains overlap
688 // (same arithmetic per channel, identical output).
689 for (; ch + 1 < nCh; ch += 2)
690 {
691 auto* a = buffer.getChannel(ch);
692 auto* b = buffer.getChannel(ch + 1);
693 std::array<T, 4> za = state_[ch].z, zb = state_[ch + 1].z;
694 for (int i = 0; i < nS; ++i)
695 {
696 a[i] = detail::ladderStepStages<Tap>(a[i], za, c);
697 b[i] = detail::ladderStepStages<Tap>(b[i], zb, c);
698 }
699 if (!std::isfinite(za[0] + za[1] + za[2] + za[3])) za.fill(T(0));
700 if (!std::isfinite(zb[0] + zb[1] + zb[2] + zb[3])) zb.fill(T(0));
701 state_[ch].z = za;
702 state_[ch + 1].z = zb;
703 }
704 for (; ch < nCh; ++ch)
705 {
706 auto* channelData = buffer.getChannel(ch);
707 std::array<T, 4> z = state_[ch].z;
708 for (int i = 0; i < nS; ++i)
709 channelData[i] = detail::ladderStepStages<Tap>(channelData[i], z, c);
710 // Same per-block NaN recovery as the Feedback loop.
711 if (!std::isfinite(z[0] + z[1] + z[2] + z[3])) z.fill(T(0));
712 state_[ch].z = z;
713 }
714 }
715
717 [[nodiscard]] static constexpr detail::LadderTap tapOf(Mode mode) noexcept
718 {
719 switch (mode)
720 {
727 }
729 }
730
737 template <Mode FilterMode>
738 [[nodiscard]] T processSampleInternal(T input, ChannelState& s, const BlockCoeffs& c, T drive) noexcept
739 {
740 return detail::ladderStep<tapOf(FilterMode)>(input, s.z, c, drive);
741 }
742};
743
744} // namespace dspark
Non-owning view over audio channel data.
Definition AudioBuffer.h:53
RAII scope guard to disable denormalised (subnormal) floating-point numbers.
4-pole resonant ladder filter (Moog topology, TPT discretization).
std::atomic< T > drive_
void processBlock(AudioBufferView< T > buffer) noexcept
Processes an audio buffer in-place (thread-safe vs. setters).
std::atomic< Saturation > saturation_
std::atomic< T > cutoff_
Saturation getSaturation() const noexcept
T getCutoff() const noexcept
void setDrive(T amount) noexcept
Sets the nonlinear drive amount (thread-safe, lock-free).
Mode
Defines the frequency response mode of the filter output.
@ LP24
4-pole lowpass (24 dB/oct) - classic Moog style.
@ HP24
4-pole highpass (24 dB/oct).
@ LP6
1-pole lowpass (6 dB/oct).
@ BP12
Bandpass (6 dB/oct per side).
@ LP12
2-pole lowpass (12 dB/oct).
@ LP18
3-pole lowpass (18 dB/oct).
T getResonance() const noexcept
void setMode(Mode mode) noexcept
Sets the filter output mode (thread-safe, lock-free).
std::vector< uint8_t > getState() const
Serializes the parameters (setup/UI threads; allocates).
T getDrive() const noexcept
void setCutoff(T hz) noexcept
Sets the cutoff frequency (thread-safe, lock-free).
std::atomic< Mode > mode_
std::array< ChannelState, kMaxChannels > state_
Mode getMode() const noexcept
void prepare(const AudioSpec &spec) noexcept
Prepares the filter with the current audio environment.
std::atomic< T > resonance_
bool setState(const uint8_t *data, size_t size)
Restores parameters from a blob (tolerant; rejects foreign ids).
void setSaturation(Saturation model) noexcept
Selects the saturation model (thread-safe, lock-free).
std::atomic< T > g_
static constexpr int kMaxChannels
Saturation
Where the filter saturates (see the class notes).
@ Input
Linear stages, tanh on the loop input; sub-stepped.
@ Stages
Every stage saturates; implicit per-sample solve.
@ Feedback
Linear stages, tanh on the resonance feedback (default).
static constexpr double kMaxResonance
Highest resonance setResonance() accepts (Feedback uses at most 1).
void reset() noexcept
Clears the internal integrator state.
void setResonance(T amount) noexcept
Sets resonance amount (thread-safe, lock-free).
T processSample(T input, int channel) noexcept
Processes a single sample on one channel.
Tolerant reader: missing keys yield defaults, unknown keys are skipped.
Definition StateBlob.h:171
float read(const char *key, float defaultValue) const
Reads a float, or defaultValue when the key is absent.
Definition StateBlob.h:214
bool isValid() const noexcept
Definition StateBlob.h:209
uint32_t processorId() const noexcept
Definition StateBlob.h:210
Serializes key/value parameters into a versioned blob.
Definition StateBlob.h:53
std::vector< uint8_t > blob() const
Finalizes and returns the blob.
Definition StateBlob.h:112
void write(const char *key, float value)
Writes a float parameter.
Definition StateBlob.h:71
void ladderInputRefresh(LadderInputState &h, const LadderInputCoeffs &c) noexcept
Recomputes the carried sums after the states or the coefficients changed.
Definition LadderZdf.h:443
LadderInputCoeffs makeLadderInputCoeffs(double cutoffRatio, T res, T drive) noexcept
Derives the coefficients of the input-saturating ladder.
Definition LadderZdf.h:465
T ladderStep(T input, std::array< T, 4 > &z, const LadderCoeffs< T > &c, T drive) noexcept
Advances the four TPT one-pole stages and the resolved feedback loop by one sample.
Definition LadderZdf.h:71
LadderStageCoeffs makeLadderStageCoeffs(T g, T res, T drive) noexcept
Derives the coefficients of the per-stage saturating ladder.
Definition LadderZdf.h:153
LadderCoeffs< T > makeLadderCoeffs(T g, T res) noexcept
Derives the ladder coefficients.
Definition LadderZdf.h:48
LadderTap
Output tap mix of the four-stage cascade.
Definition LadderZdf.h:28
Main namespace for the DSPark framework.
constexpr uint32_t stateId(const char(&tag)[5]) noexcept
Builds a FOURCC processor id, e.g. dspark::stateId("COMP").
Definition StateBlob.h:672
Describes the audio environment for a DSP processor.
Definition AudioSpec.h:37
double sampleRate
Sample rate in Hz.
Definition AudioSpec.h:45
detail::LadderInputState input
detail::LadderInputCoeffs coeffs
Coefficients derived from g and the resonance.
Definition LadderZdf.h:39
Coefficients of ladderStepInput(), derived by makeLadderInputCoeffs().
Definition LadderZdf.h:412
State of ladderStepInput(), in double whatever the sample type is.
Definition LadderZdf.h:433