Skip to content

Commit 8c8459c

Browse files
committed
fix: add damping to resonance feedback to prevent infinite oscillation and make resonance knob adjustable
1 parent 1f39b7b commit 8c8459c

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

patches/apcEffectsProcessor.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ class apcEffectsProcessor {
4848
}
4949

5050
float processResonantLowpass(float input, float &band, float &low, float cutoff, float resonance) {
51-
// Simple one-pole lowpass with direct resonance feedback
51+
// State-variable filter with damped resonance
5252
float f = cutoff;
53-
// Direct resonance: feed bandpass back through the input
54-
float resonanceAmount = resonance * 2.0f;
55-
56-
band = band + f * (input - low);
57-
low = low + f * (band + band * resonanceAmount);
53+
float dampedRes = 1.0f - resonance * 0.8f; // resonance reduces damping: 1.0 at res=0, 0.2 at res=1
54+
55+
// Highpass: input minus lowpass
56+
float high = input - low;
57+
// Bandpass: integrate highpass with damping
58+
band = band * dampedRes + f * high;
59+
// Lowpass: integrate bandpass
60+
low = low + f * band;
5861

5962
return low;
6063
}

0 commit comments

Comments
 (0)