Mitigating clicks in modulated DSP filters

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

Z1202 wrote: Fri Aug 05, 2022 4:47 pm
mystran wrote: Fri Aug 05, 2022 4:31 pm We need to stop calling direct form filters "biquads" because that just gives the false impression that you should actually use direct form filters at all.
I totally agree that "biquad" used instead of the term "direct form" is a huge misnomer. However the amount of such misusage is such, that I'm not sure it's a good idea even to try to correct this, as this will simply be causing prolonged confusion.
This is a holy quest. Confusion lies on the path to enlightenment.

edit: Also in the analog form there is a "biquad topology" which is really at least about 3 different topologies, so perhaps we should start calling trapezoidal versions of these "biquads" as well... and I've yet to figure out why you'd want to use one since with 3 opamps you can just as well build an SVF instead.

Post

mystran wrote: Fri Aug 05, 2022 4:51 pm edit: Also in the analog form there is a "biquad topology" which is really at least about 3 different topologies, so perhaps we should start calling trapezoidal versions of these "biquads" as well... and I've yet to figure out why you'd want to use one since with 3 opamps you can just as well build an SVF instead.
I'm not sure which specific topologies you're referring to, but for one Sallen-Key has a different time-varying behavior of resonance, compared to SVF (putting nonlinearities aside for a moment). Arguably this is more natural behavior, because it can be seen as a 2-pole ladder filter (in the sense of Moog ladder), the resonance being generated by a feedback around the entire filter. Now you could argue that in the SVF case the resonance is also natural, because it acts as damping in a harmonic oscillator, but, besides being damping rather than the resonance, in the time-varying case it doesn't exactly map to natural parameters of a harmonic oscillator such as a mass on a spring, but always (or mostly) combinations thereof.

So one reason for different topologies (besides nonlinearities) is time-varying resonance behavior.

Post

Z1202 wrote: Fri Aug 05, 2022 5:40 pm
mystran wrote: Fri Aug 05, 2022 4:51 pm edit: Also in the analog form there is a "biquad topology" which is really at least about 3 different topologies, so perhaps we should start calling trapezoidal versions of these "biquads" as well... and I've yet to figure out why you'd want to use one since with 3 opamps you can just as well build an SVF instead.
I'm not sure which specific topologies you're referring to
https://en.wikipedia.org/wiki/Electroni ... r_topology

Post

Hi everyone and sorry for the late response! Happy to see that the topic has created such lively discussion!

I'm actually pretty late in the product cycle so changing the filter topology now isn't possible. It seems however I have to read up quite a lot on the stuff that was mentioned in this thread to be better prepared for the next project.

The filters I'm using are an adapted version of the Moog-Ladder from Will Pirkles Synth Book. I'm pretty sure they use trapezoidal integrators in their internal VA one-pole filters. I'm not sure however if they're zero delay or not. I don't think the topology can be represented by a biquad either.

Post

I think Pirkle's synth book (but not the FX book, AFAIK!) is using ZDF filters. This means the filters are already having kinda maximum possible cutoff modulation click tolerance (a bold unproven claim, but at least it should be reasonably good :D ), and this tolerance is still insufficient in your case. The clicks themselves are presumably coming from your modulation signals, like e.g. unsmoothed knobs (assuming your implementation is correct). The knobs are different from other modulation sources (such as LFOs) in that their jumps are largely irregular, and also by their very nature, they are not supposed to produce clicks (while for e.g. LFOs, as mystran put it, it can be an artistic decision).

Post

After rereading your original post, where you explicitly say that the clicks come from modulation curves, I guess this is the kind of artistic decision mystran mentioned, whether you want to keep the clicks. The same clicks (more or less) would be also present in case of analog filters, unless the control path contains some kind of bandlimiting (lowpass filtering), or the details of CV generation would effectively produce bandlimited curves. So either smooth/bandlimit, or pregenerate smooth/bandlimited curves, or just keep them as they are.

Maybe it's also possible to tweak the filter topology to further reduce the clicks somehow (not sure, since I think ZDF is already pretty good there, at least similar to analog), but you said you don't want to redesign the filters. Also such redesigned filters might be worth at least one conference paper (just to give you an idea of the amount of thought it might require). Any kind of state tweaking (which, AFAIK, esp. with direct forms is sometimes used as a way to reduce clicks) IMHO would also be a kind of filter redesign.

Post

Z1202 wrote: Mon Aug 08, 2022 7:05 pm I think Pirkle's synth book (but not the FX book, AFAIK!) is using ZDF filters. This means the filters are already having kinda maximum possible cutoff modulation click tolerance (a bold unproven claim, but at least it should be reasonably good :D ), and this tolerance is still insufficient in your case. The clicks themselves are presumably coming from your modulation signals, like e.g. unsmoothed knobs (assuming your implementation is correct). The knobs are different from other modulation sources (such as LFOs) in that their jumps are largely irregular, and also by their very nature, they are not supposed to produce clicks (while for e.g. LFOs, as mystran put it, it can be an artistic decision).
IIRC, Pirkle referenced your book for the ZDF trapezoidal integration one pole filter and built most of his synth book analog filter models by using it as a primary building block. His diode ladder had the most extra added to it because of the more complex feedback arrangement amongst the stages.

Anyhow, regarding OP's clicks...would I be correct in saying that modulating by an LFO Sine (or Triangle?) should be smooth whilst doing so with an LFO Sawtooth would produce clicks because of the discontinuity? OP mentioned curves but I don't see how that would be a problem if the curves are the ramps of an envelope or MSEG and they're not narrow enough to essentially be a hard discontinuity.

Maybe OP could be a bit more specific about the modulation shapes that are causing the clicks.

Post

JustinJ wrote: Tue Aug 09, 2022 10:46 pm Anyhow, regarding OP's clicks...would I be correct in saying that modulating by an LFO Sine (or Triangle?) should be smooth whilst doing so with an LFO Sawtooth would produce clicks because of the discontinuity? OP mentioned curves but I don't see how that would be a problem if the curves are the ramps of an envelope or MSEG and they're not narrow enough to essentially be a hard discontinuity.

Maybe OP could be a bit more specific about the modulation shapes that are causing the clicks.
IIUC, OP was specifically referring to jumps in the curves, but yeah, a bit more information might help.

Post

Other filter topologies are your friend yes. I like Digital SVF a lot (https://www.earlevel.com/main/2003/03/0 ... le-filter/), it's very stable overall, calculating parameters is very easy, and you can modulate it till kingdom come without creating any clicks or blowups.

If you need to keep Direct Form topology (usually when you're making an EQ or something like that), this can be rearranged to make it much, much less clicky. The key insight is that your "current energy level" is stored in your [sample -1] memory, and in the difference between your [sample -2][sample -1] memories. And when you modulate cutoff in direct form, this difference is reinterpreted as very different energy levels, leading to large pops. For instance, if you had a difference of 0.1, and you suddenly halve the cutoff, then what you really want is for the next sample to step by 0.05 (you want the same sine to keep going but twice as slow), but what you instead get is that it keeps going with a step of 0.1, effectively doubling the amount of stored energy, which gives you a pop (and blowups with very fast cutoff modulation). Due to how direct form filters are calculated, generally your [gain for sample -2] will be very close to your effective cutoff.

The solution is that instead of storing [sample -1] and [sample -2], you store [sample -1] and [difference of sample -2 from sample -1]. And instead of having gain factors calculated as [gain for sample -1] and [gain for sample -2], you rearrange so that the old [gain for sample -2], which is very close to the cutoff you want, becomes the factor for [difference of sample -2 from sample -1], which makes it so that the stored energy changes much less when filter settings change. You will need to change the other filter parameter to match (since the first parameter adds a mix of sample -2 and negative sample -1 instead of just sample -2 now), so that in the end you'll end up with the old [gain for sample -1 plus also the gain for sample -2] becoming the new factor for [sample -1].

In other words this:

Code: Select all

float generate(float in) {
	float out = in * i0 + in_d1 * i1 + in_d2 * i2 + out_d1 * o1 + out_d2 * o2;
	in_d2 = in_d1; in_d1 = in; out_d2 = out_d1; out_d1 = out;
	return out;
}
becomes this:

Code: Select all

float generate(float in) {
	float out = in * i0 + in_d1 * i1 + in_d2 * i2 + out_d1 * (o1+o2) + out_d2_minus_d1 * o2;
	in_d2 = in_d1; in_d1 = in; out_d2_minus_d1 = out_d1 - out; out_d1 = out;
	return out;
}

Post Reply

Return to “DSP and Plugin Development”