Accelerate/vDSP Biquad filter

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

JCJR wrote:* Does the zdf svf have completely complementary hipass, bandpass, and lopass outputs? Long ago tweaking on chamberlin's svf, it seemed that one could try to tweak one of the outputs, but that only made the other two outputs' response shape even less ideal.

* Can the zero delay technique somehow cure sloppy filter curves when IIR filters are tuned above about fs/8? Or would one still need to oversample (assuming source samplerate 44 or 48 k) in order to get good filter shapes in the higher octaves?
Being a form of BLT, ZDF filters give you exactly the same amplitude and phase responses as any other BLT filters (e.g. the DF ones aka "biquads").

@Urs, regarding the ZDF term. I always personally preferred TPT, however everyone kept using ZDF. So, I guess any attempt to change it by now will at least cause more confusion, if not being completely futile :)

Post

Z1202 wrote:@Urs, regarding the ZDF term. I always personally preferred TPT, however everyone kept using ZDF. So, I guess any attempt to change it by now will at least cause more confusion, if not being completely futile :)
Yeah, I guess you're right :hihi:

Post

Unless you work on an academic app to place/visualize/whatsoever poles and zeros, I'd strongly recommend to stay away from biquad filters. They're all over DSP literature but they have not much to offer in modern practical DSP.
That is a quite remarkable statement :)
With biquad filters I assume you mean "direct form implementations of a biquad".

The main problem with biquads filters is that there is no concept of manipulating coefficients, say, to sweep cutoff frequency or resonance, or to warp one filter type into another. There may be unwanted and unpredictable artifacts if you do so (DC offsets, gain changes and more). Other problems are numerical stability (not sure if the Apple ones deploy noise shaping) and exaggerated computation of coefficients. That means, you'd need to go double precision and you'll waste a lot of CPU just to compute the coefficients.
I don't have any experience with time-varying coefficients in a realization of any biquad. That may very well be a good reason to choose an alternative structure over direct form 1.


I
f you want numerical accuracy even in single precision floating point, simple coefficient calculation and sweepable cutoff/resonance/type, have a look at Andy Simper's implementation of State Variable Filters:

http://www.cytomic.com/technical-papers

There's pretty much nothing a cascade of 2-pole biquads can do that a cascade of SVFs can't, at possibly less effort and higher numercial accuracy. However, it hasn't made it into standard DSP literature yet, so no-one has done fancy pole zero plots for it yet, afaik :clown:
I have some experience with the SVF form although the realization is not the same as what can be found in the reference you provided above as far as I can tell from a quick look. By linearly combining the states of the SVF there is a one-2-one mapping from the SVF to the direct form coefficients so in that sense it is true.
But I don't understand how the SVF can possibly require less computational effort than a direct form 1?
Also have you ever tried or at least considered the effort required for a fixed-point implementation of the SVF? It seems to me that it suffers from the same scaling issues as a direct form 2...
Not sure what you mean with fancy pole zero plots for SVF, it is just a particular realization of a biquad.

Just out of curiosity and total lack of music production understanding, but can you give a very simple example where fast time-varying coefficients in a biquad are used?
:)
niarn

Post

niarn wrote:Just out of curiosity and total lack of music production understanding, but can you give a very simple example where fast time-varying coefficients in a biquad are used?
Morphing filters (E-MU Z-plane style)?

Post

niarn wrote:But I don't understand how the SVF can possibly require less computational effort than a direct form 1?
The actual processing may take similar amounts of adds and multiplies. The main computational (and headache-causing) difference is in the calculation of coefficients. While the coefficients of the SVF are independent and easy to calculate, the coefficients of a DF biquad are not. If you sweep, say, the filter frequency of a SVF you only need to update one coefficient. If you do so in a DF biquad, you need to update all of them. Furthermore, LP, HP and BP types always require just 2 coefficients to be calculated.

However, if one takes into account that double precision and/or noise shaping is required for common applications of DF biquads, I'm not sure if processing the filter is really faster than processing a single precision SVF with a chance of twice the vector size in a SIMD environment.

I have not dealt with fixed point implementations and tricks like Rossum's Amadillo technique to make things sweepable. In contemporary DSP for general purpose CPUs I reckon that floating point is the predominant type to care about.
Just out of curiosity and total lack of music production understanding, but can you give a very simple example where fast time-varying coefficients in a biquad are used?
For me it's the other way round. I can't really come up with an example where I'd use a filter that isn't ever time-varying :oops:

Granted, there may be applications where one might want to have this or that filter response *forever*. But even there I see no need to prefer DF biquads over an SVF any time.

But I do know that filters in synthesizers, equalizers, dynamics processors, heck, even in reverbs and what have you are being swept all the time. Also, the OP specifically asked about a feature with respect to coefficient updates.

Now back to the point: It's true that DF biquads aren't worse than SVF if your application does not require the numerical precision or coefficient updates. But they are also not "better". The only thing that makes them preferrable is the amount of literature and off-the-shelf implementations (and also if you want to show off with math skills for coefficient calculation). However, I'm a proponent of "keep it simple, stupid" and "implement and debug once use everywhere", hence even if you don't need the advantages of SVFs today, you might need them tomorrow. So why wait?

- U

Post

The actual processing may take similar amounts of adds and multiplies.
The SVF is about 25% more expensive than DF1 for ARM optimized fixed-point implementation.
The main computational (and headache-causing) difference is in the calculation of coefficients. While the coefficients of the SVF are independent and easy to calculate, the coefficients of a DF biquad are not. If you sweep, say, the filter frequency of a SVF you only need to update one coefficient. If you do so in a DF biquad, you need to update all of them. Furthermore, LP, HP and BP types always require just 2 coefficients to be calculated.
I'm not sure about this. Is coefficient computation for a 2nd order lowpass butterworth filter simpler for the SVF than for the DF? I haven't checked myself but I doubt it. And if you need to change the cutoff for the butterworth filter do you really only have to change one coeffient? Again, I haven't checked but I doubt it.
However, if one takes into account that double precision and/or noise shaping is required for common applications of DF biquads, I'm not sure if processing the filter is really faster than processing a single precision SVF with a chance of twice the vector size in a SIMD environment.
Do you mean double precision for the coefficients or the accumulator? All modern ARM processors and DSPs doesn't require noise shaping. And as SVF has more truncations than DF1 (only has one on the output) there should also be problems with the SVF!
I have not dealt with fixed point implementations and tricks like Rossum's Amadillo technique to make things sweepable. In contemporary DSP for general purpose CPUs I reckon that floating point is the predominant type to care about.
But for embedded systems with RISC processors and DSPs the predominant type is fixed-point.
For me it's the other way round. I can't really come up with an example where I'd use a filter that isn't ever time-varying :oops:
Cool :) I'm still trying to figure out what a morphing filter is and what its useful purpose is :oops:
Now back to the point: It's true that DF biquads aren't worse than SVF if your application does not require the numerical precision or coefficient updates. But they are also not "better". The only thing that makes them preferrable is the amount of literature and off-the-shelf implementations (and also if you want to show off with math skills for coefficient calculation). However, I'm a proponent of "keep it simple, stupid" and "implement and debug once use everywhere", hence even if you don't need the advantages of SVFs today, you might need them tomorrow. So why wait?
I have to disagree. Please don't say that there is no place/room for DF1 in practical DSP :D
There is nothing simpler than the direct forms.
For fixed-point implementations who would ever consider DF2 over DF1? because the SVF has similar issues as with DF2 who would then consider SVF if time-variance is not needed? I wouldn't. The SVF has worse SNR and handling the extreme dynamical range of the states is really annoying.
niarn

Post

Thankfully there are FP DSPs out there that can also be used, no (SHARC)? :)

I really doubt that the likes of John Bowen Solaris would be possible on fixed point DSPs... that's why it's using 6 SHARCs!


Gimme SVF over biquads any day :)

Post

niarn wrote:I haven't checked but I doubt it.
Please read the papers. I'm not talking about naive SVF implementations found in standard literature.

This particular SVF (based on nodal analysis of an analogue prototype, not H(s)->(Hz)) has *independent* and easily calculated coefficients for cutoff, q and output type and is a magnitude more numerically accurate than DF filters. DF filters need either double precision or noise shaping for stability, otherwise rounding/truncation errors will yield DC offsets. Furthermore they compute with 6-8 Multiply-Adds.

Edit: If, after looking at http://www.cytomic.com/files/dsp/SVF-vs-DF1.pdf one still thinks DF biquad filters have anything to offer over the SVF they're compared to... dunno.

Post

Please read the papers. I'm not talking about naive SVF implementations found in standard literature.
Is this the naive implementation ?
https://ccrma.stanford.edu/~jos/svf/svf.pdf

This particular SVF (based on nodal analysis of an analogue prototype, not H(s)->(Hz)) has *independent* and easily calculated coefficients for cutoff, q and output type and is a magnitude more numerically accurate than DF filters. DF filters need either double precision or noise shaping for stability, otherwise rounding/truncation errors will yield DC offsets. Furthermore they compute with 6-8 Multiply-Adds.

Edit: If, after looking at http://www.cytomic.com/files/dsp/SVF-vs-DF1.pdf one still thinks DF biquad filters have anything to offer over the SVF they're compared to... dunno.
I must admit I find those plots hard to believe. Can you explain why the SNR for DF1 is at ~-42 dB?
A DF1 fixed-point implementation should give SNR down at -180 dB. So maybe the problem is not really with the DF1 structure (SNR-wise) but with the floating-point operations which I don't have that much experience with.

Do you agree that there is only one truncation at the output of the DF1 and that there is at least 3 truncations in the SVF, some of them occuring in the feedback path?
niarn

Post

niarn wrote:
Please read the papers. I'm not talking about naive SVF implementations found in standard literature.
Is this the naive implementation ?
https://ccrma.stanford.edu/~jos/svf/svf.pdf
Sorry, I don't know "Faust". If those z-1 blocks in those confusing diagrams are unit delays and if combining Forward Euler and Backward Euler doesn't yield trapezoidal integration, then yes, it's the same old stuff we know since Chamberlin's book.
I must admit I find those plots hard to believe. Can you explain why the SNR for DF1 is at ~-42 dB?
It's very simple: At some frequencies and depending on filter type two DF biquad coefficients can become very small while the other two become very high. Truncation errors occur due to the magnitude of difference in coefficients within the recursion, i.e. they "add up" anymore.

I can't image fixed point implementations to have any advantage.

Post

Z1202 wrote:
JCJR wrote: * Can the zero delay technique somehow cure sloppy filter curves when IIR filters are tuned above about fs/8? Or would one still need to oversample (assuming source samplerate 44 or 48 k) in order to get good filter shapes in the higher octaves?
Being a form of BLT, ZDF filters give you exactly the same amplitude and phase responses as any other BLT filters (e.g. the DF ones aka "biquads").
Thanks!

Post

niarn wrote:Do you agree that there is only one truncation at the output of the DF1 and that there is at least 3 truncations in the SVF, some of them occuring in the feedback path?
What do you mean by "the feedback path" in respect of the SVF based on nodal analysis?

Thing is, in the SVF one feedback coefficient is 1, the other one is something like 0.5. They're pretty much in the same domain, exponent wise. Unlike a DF biquad where one goes like 0.999996 and another like 0.000000001

Post

Urs wrote: I think we shouldn't call it "zero delay feedback" anymore. What Andy does in his papers is simply a different approach to filter design which is automatically without unit delay. Instead of transforming poles and zeros from an s-plane to a z-plane (abstract model) he solves the currents and voltages of the analogue circuit directly using Ohm's law, Kirchhoff's voltage law, some maths and the trapezoidal rule. What started out as "zero delay feedback" back then has become "Topology Preserving Transform" or "implicite circuit discretization based on classic nodal analysis and trapezoidal rule" or whatever. I don't think there's any fancy name yet, but zdf doesn't quite capture it. "Circuit Modeling" might capture it but is too ambiguous...
Thanks Urs

Possibly I would find that approach easier to understand compared to abstract transfer functions. Will read andrew's paper when I can find time.

Post

Urs wrote:I think we shouldn't call it "zero delay feedback" anymore. What Andy does in his papers is simply a different approach to filter design which is automatically without unit delay. Instead of transforming poles and zeros from an s-plane to a z-plane (abstract model) he solves the currents and voltages of the analogue circuit directly using Ohm's law, Kirchhoff's voltage law, some maths and the trapezoidal rule. What started out as "zero delay feedback" back then has become "Topology Preserving Transform" or "implicite circuit discretization based on classic nodal analysis and trapezoidal rule" or whatever. I don't think there's any fancy name yet, but zdf doesn't quite capture it. "Circuit Modeling" might capture it but is too ambiguous...
Actually my POV would be exactly the opposite. I think "circuit modeling" is way too narrow. The method itself doesn't need to bear any relationship to analog electronics. My personal view on ZDF/TPT is to see it as a way to discretize abstract continuous-time mathematical models without any necessary connection to the actual "analog" implementation whatsoever. In that sense ZDF filters are not to be seen as models of some particular electronic circuits, but simply as some abstract filters, same as DF biquads. This is also the approach taken in my book.

In that sense it would also be really cool if this method is used to construct new filters, which do not have any analog prototype. I have been demonstrating some of this in the Native Sessions presentation of Reaktor 6 in Berlin, if you have seen the video ;)

Regards,
{Z}

Post

Urs wrote:
I must admit I find those plots hard to believe. Can you explain why the SNR for DF1 is at ~-42 dB?
It's very simple: At some frequencies and depending on filter type two DF biquad coefficients can become very small while the other two become very high. Truncation errors occur due to the magnitude of difference in coefficients within the recursion, i.e. they "add up" anymore.

I can't image fixed point implementations to have any advantage.
Actually, I think the typical source of precision loss is subtraction of two values which are very close to each other. And this is indeed quite often happening in the DF biquads.

Post Reply

Return to “DSP and Plugin Development”