Accelerate/vDSP Biquad filter

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

Post

niarn wrote:
JCJR wrote:
niarn wrote: One thing that puzzles me now is in what sense the super duper SVF algorithm is better than the naive SVF algorithm.
From a practical standpoint-- Naive chamberlin digital svf goes unstable at a relatively low frequency.
What do you mean by becoming unstable. Do you mean unstable like poles outside the unit circle and output going off to -+inf? But why is this a property of the naive SVF? Any biquad with poles outside the unit circle will at some point do the same thing....
Thanks for your explanation!
Hi niarn

Maybe there are different old variants in which case I can't speak for all. The ones I played with, started with code lifted out of hal chamberlins excellent old book, musical applications of microprocessors.

That book was written when a computer musician's wet dream ideal computer was a pdp-11, and hardly any mere mortal could afford a stong enough computer to do audio at home. Even on the strong expensive computers it was rarely in real time. Typically hours of calculation in order to generate seconds or at best minutes of audio.

Anyway, in the 1990's and maybe early 2000's I played with hal's svf and made a few modifications attempting improvement but I was even more ignorant then than now. Very few folk had good grasp of digital audio, and they tended to be educated electrical engineers, who also tended to explain it differently than you see it explained nowadays. People just know a lot more about digital audio nowadays, though unfortunately I am not among them. :)

I occasionally use naive digital svf's into the current times but typically on low frequency tasks. Wrote an SVF object long long ago and haven't done anything except occasionally instantiate the old object in programs since. That zdf svf sounds quite promising however.

Maybe am remembering wrong, but as best I recall-- Above a certain center frequency the naive svf would just blow up. Unmanagebly loud and distorted or worse. As best I recall, above a certain frequency, the equations used to calculate the filter coefficients, would give results bigger than 1.0 and then it hits the fan of course. Or something with that same practical result. The way coefficients were calculated, bigger Q values allowed higher center frequencies before the coefficients got big enough to blow up the filter.

If you are curious, if you google music-dsp SVF, you ought to find many interesting ancient mailing list discussions about it. A few genuine experts and then many other enthusiastic well-intentioned folks swatting at geese with a rake. :)

Hopefully someone will correct any substantial misstatements I made. It was a few years ago. :)

Post

niarn wrote:I don't really understand this rejection of the definition. Is it really necessary to involve such thing as topology in a definition of the SVF? Why is it not possible to provide a definition based on transfer function?
Maybe it hasn't been stated clearly yet in this thread: the transfer functions which one can obtain from a BLT ZDF SVF are exactly the same that one obtains from DF biquads. That is, SVF is not a filter with a different transfer function. In fact, biquads can cover any 2nd order transfer function (and so can BLT ZDF SVF). However, there are important aspects of filter behavior, not covered by the transfer function, even if we are talking purely linear filters. Hence the whole fuss :wink:

Post

I used biquads in Luftikus and I wouldn't say it was a bad decision. I modelled the transfer functions I got from analog filters which included steps against bandwidth squeezing towards nyquist (peaks get narrower; I know I read a lot about this but I can't think of a term that describes it in one word right now).
The beauty with biquads is that you can easily plot a transfer function and also use other means like MZTi to create the filter.

Of course, Luftikus is special as it only uses fixed filters and adds the weighted filter outputs, so unless the sample rate is changed, the coefficients are constant.
The implementation was done with doubles instead of floats but I don't think that the benefits in CPU usage would have a great impact and the plugin itself isn't very CPU intensive (or at least I never had any complaints).

One other topology I like is the the one from mystran. It seems to perform well enough with floats and is created from biquad coefficients.

Post

EvilDragon wrote:Who's using teensy for a fully fledged virtual analog synth? Haha.
People with better coding skills than you :-)

Post

Z1202 wrote:
niarn wrote:I don't really understand this rejection of the definition. Is it really necessary to involve such thing as topology in a definition of the SVF? Why is it not possible to provide a definition based on transfer function?
Maybe it hasn't been stated clearly yet in this thread: the transfer functions which one can obtain from a BLT ZDF SVF are exactly the same that one obtains from DF biquads. That is, SVF is not a filter with a different transfer function. In fact, biquads can cover any 2nd order transfer function (and so can BLT ZDF SVF). However, there are important aspects of filter behavior, not covered by the transfer function, even if we are talking purely linear filters. Hence the whole fuss :wink:
My definition of SVF does not work for the simple reason that the super duper ninja SVF version does not obey it :) I just checked and it is a different re-parameterization of the biquad. For some reason I thought that the f and q parameters in the naive mickey mouse SVF would also appear the the super duper version but this is not the case.
This probably also mean that the super duper version does not have as nice coefficient quantization behavior as the naive version...

Would you then accept the definition if it was constrained to naive SVF?

Z1202 wrote:
niarn wrote:One thing that puzzles me now is in what sense the super duper SVF algorithm is better than the naive SVF algorithm. Is the naive SVF just as bad as the DF1 from your point of view?
They are bad in two different ways. Naive SVF responds nicely to fast parameter variations but has poor frequency response closer to Nyquist. DF1/2 has nice frequency response curve everywhere but responds poorly to fast parameter variations and has precision issues. ZDF SVF addresses both issues at the same time.
Okay, we have earlier agreed that all the SVF versions can realize any biquad and thereby any frequency response obtainable with a generic biquad. What do you then mean by poor frequency response close to nyquist? If the frequency response can be obtained by the super duper SVF nothing in this world prevents the naive SVF from obtaining the exact same frequency response. Unless of course it is due to some numerical issue.

Post

niarn wrote:Would you then accept the definition if it was constrained to naive SVF?
I'm not sure which definition you mean. The best SVF definition I can give is the continuous-time diagram in the book. What's wrong with that? Why are you looking for a different definition?

niarn wrote:Okay, we have earlier agreed that all the SVF versions can realize any biquad and thereby any frequency response obtainable with a generic biquad.
I'm not sure what are you referring to. I mentioned that BLT ZDF SVF can implement those. Probably other SVF versions can do that as well, but that's less practical and more involved from a mathematical standpoint (regarding the filter parameterization, particularly decoupling the cutoff and resonance controls), so I see little point in pursuing that direction. Again, what is so wrong with the BLT ZDF SVF that you are looking for a different solution?
niarn wrote:What do you then mean by poor frequency response close to nyquist?
It behaves in an "unnatural" way compared to analog SVF (or to an infinite sample rate naive SVF). Difficult to describe. If you plot the amplitude (and phase) response of a naive SVF for various cutoffs and resonance you should be able to easily see what I mean. Also it becomes unstable in a not so useful way.
niarn wrote:If the frequency response can be obtained by the super duper SVF nothing in this world prevents the naive SVF from obtaining the exact same frequency response.
Maybe, but it's more difficult that doing that for a BLT ZDF SVF, where it's absolutely straightforward. Also, as I mentioned, not all important information about a filter is encoded in a transfer function. Having a good or "correct" transfer function doesn't necessarily imply a good usability of the filter (as DF shows).

Post

Z1202 wrote:
niarn wrote:Would you then accept the definition if it was constrained to naive SVF?
I'm not sure which definition you mean. The best SVF definition I can give is the continuous-time diagram in the book. What's wrong with that? Why are you looking for a different definition?
Don't think there is anything wrong. Just curious.

Z1202 wrote:
niarn wrote:Okay, we have earlier agreed that all the SVF versions can realize any biquad and thereby any frequency response obtainable with a generic biquad.
I'm not sure what are you referring to. I mentioned that BLT ZDF SVF can implement those. Probably other SVF versions can do that as well, but that's less practical and more involved from a mathematical standpoint (regarding the filter parameterization, particularly decoupling the cutoff and resonance controls), so I see little point in pursuing that direction. Again, what is so wrong with the BLT ZDF SVF that you are looking for a different solution?
And what is BLT ZDF SVF? Dare I ask for a definition :D
I'm not looking for any solution. But this thread has been thick of directly and indirectly claims/statements that there is this fantastic SVF realization of a biquad, so fantastic that all DSP books should be rewritten and mankind has done wrong in considering using DF realizations (ok I may be exaggerating a bit :D ). And I'm just trying to understand why it is so fantastic because I still don't get it. I must be stupid I know :)
For instance, what about decoupling of cutoff and resonance controls. I don't see how cutoff and resonance in the naive SVF are decoupled for a LP butterworth....I don't think they are. But they are decoupled in the fantastic SVF version?
Z1202 wrote:
niarn wrote:What do you then mean by poor frequency response close to nyquist?
It behaves in an "unnatural" way compared to analog SVF (or to an infinite sample rate naive SVF). Difficult to describe. If you plot the amplitude (and phase) response of a naive SVF for various cutoffs and resonance you should be able to easily see what I mean. Also it becomes unstable in a not so useful way.
Ok, I think I get the point about the responses being 'squeezed' at nyquist. I have questions about this but will leave it for now. However, I don't understand the instability thing. In what sense is it unstable? Is this specific to DF?
But hey, I can keep asking questions. I think I will just back off and at some point look into it.
Roger over and out :)

Post

Naive SVF is just one possible flavor of an SVF. What's the point of considering a particular case as "the" definition?

BLT ZDF SVF is a continuous-time SVF transformed to discrete-time by substituting bilinear integrators and resolving the zero-delay feedback properly. Details can be found in the mentioned book (in an abstract form), or in mentioned papers in a more specific analog modelling setting.

Why BLT ZDF SVF is so fantastic has been explicitly answered before. Okay, I'll try to reformulate again. BLT gives us kind of the best possible transfer function conversion. DF biquads usually do exactly this. However DF topology has poor time-varying behavior and precision issues. Naive SVF doesn't have those issues of DF, but its transfer function is not BLT and is therefore having issues, including the instability (no, the squeezing at Nyquist is a feature of BLT and it is more or less the best we can have, the responses of naive SVF have much much worse issues). With a number of tricks probably naive SVF transfer function can be tweaked into a BLT one but a. that's quite tricky and involved mathematically and b. still raises some questions regarding the time-varying behavior. BLT ZDF SVF doesn't have any of the mentioned issues, thereby combining the benefits of both approaches. Furthermore, DF is not well suitable for nonlinear filters, whereas the SVF topology is way better suitable for that (although it's also not the best).

I don't understand your question about cutoff and resonance decoupling in a Butterworth LP, because there is no resonance parameter in that filter. As for DF/SVF, the cutoff and resonance are coupled in a naive SVF, but are not coupled in BLT DF or ZDF SVF.

PS. The bottom line is, as Urs mentioned closer to the beginning of the thread, other things being equal, the ZDF SVF should be the default go-to 2-pole filter. Some specific reasons might dictate using DFs or other forms instead, but those reasons need to be determined before doing so.

Post

Hi niarn

By way of analogy with adjustable analog filters, as found in crossovers, test gear, parametric equalizer, synthesizer filters, etc--

There are typical single-opamp circuits which can perform fine unless you need unusually good performance. But in those circuits, if you want to make a circuit with two front-panel knobs, one labeled frequency and the other knob labeled Q or bandwidth--

For instance with a sallen-key single opamp circuit, you could calculate combinations of resistors and capacitors to achieve many fixed settings of frequency and Q. But if you try to wire in potentiometers so that you can sweep the sallen-key frequency while independently adjusting Q with another knob, you will become quickly frustrated trying to make it work. To set frequency and Q on such a filter requires the circuit values to change in ways not friendly to simply wiring in a couple of potentiometers. It would be a nightmare. Also, the gain of such a circuit usually changes along with Q, so you would have to wire in gain compensation which works in tandem with the Q control mechanism.

On the other hand, with state variable filter, it is as easy as its gonna get to wire in independent non-interacting frequency and Q knobs, and the four opamp svf version eliminates interaction between Q and gain. Therefore the svf is frequently used in analog when you need a sweepable, adjustable Q filter. Or even if you need a filter which you can easily sweep without screwing up a preferred fixed-Q setting.

Similar advantages apply to digital svf if you eliminate the digital svf "defects".

Re the tuning instability, I was looking up the chamberlin parameter setting formula and discovered that Nigel Redmond wrote a good description a few years ago--

http://www.earlevel.com/main/2003/03/02 ... le-filter/

In the first few paragraphs, he lists the formula and it is easy to see that the frequency coff will exceed 1.0 at a frequency far short of nyquist.

Edit: Nigel also mentions the easiest way to oversample the chamberlin svf, processing each sample multiple times. This can work good for simple uses of the filter. For instance tapping only the lowpass output for an auto-waa effect. But this simple oversample messes up even further the relationship between lp, bp, and hp. So far as I could tell, it isn't good enough to be able to precisely use all outputs simultaneously. I'm not being critical of what Nigel wrote. Just saying that repeat sample oversampling doesn't work good enough for some things that one might want to do with the svf. Maybe help someone avoid spending a few hours finding this out. :)

Post

Z1202 wrote:Naive SVF is just one possible flavor of an SVF. What's the point of considering a particular case as "the" definition?
I'm not sure why you are saying that. I don't think I've said that. Anyway, when you or anyone else write naive SVF then I picture 1+(2-f^2-q)z^-1+(1-q)z^2. That is naive SVF to me.
Z1202 wrote: BLT ZDF SVF is a continuous-time SVF transformed to discrete-time by substituting bilinear integrators and resolving the zero-delay feedback properly. Details can be found in the mentioned book (in an abstract form), or in mentioned papers in a more specific analog modelling setting.
Thanks I will definitely have a look.
Z1202 wrote:Why BLT ZDF SVF is so fantastic has been explicitly answered before. Okay, I'll try to reformulate again. BLT gives us kind of the best possible transfer function conversion. DF biquads usually do exactly this. However DF topology has poor time-varying behavior and precision issues. Naive SVF doesn't have those issues of DF, but its transfer function is not BLT and is therefore having issues, including the instability (no, the squeezing at Nyquist is a feature of BLT and it is more or less the best we can have, the responses of naive SVF have much much worse issues). With a number of tricks probably naive SVF transfer function can be tweaked into a BLT one but a. that's quite tricky and involved mathematically and b. still raises some questions regarding the time-varying behavior. BLT ZDF SVF doesn't have any of the mentioned issues, thereby combining the benefits of both approaches. Furthermore, DF is not well suitable for nonlinear filters, whereas the SVF topology is way better suitable for that (although it's also not the best).
Okay, now I understand the response distortion. I was not really aware that naive SVF is not a BLT of the analog SVF transfer function because it has no role in the reason why I have used it.
Z1202 wrote: I don't understand your question about cutoff and resonance decoupling in a Butterworth LP, because there is no resonance parameter in that filter. As for DF/SVF, the cutoff and resonance are coupled in a naive SVF, but are not coupled in BLT DF or ZDF SVF.
Sorry I messed it up. What I meant was that changing the butterworth cutoff changes both f and q parameters in the naive SVF, there is no decoupling. But I'm not sure if that is the type of decoupling your are talking about. Most likely not.
Z1202 wrote: PS. The bottom line is, as Urs mentioned closer to the beginning of the thread, other things being equal, the ZDF SVF should be the default go-to 2-pole filter. Some specific reasons might dictate using DFs or other forms instead, but those reasons need to be determined before doing so.
I almost couldn't disagree more. DF1 is simpler to understand, cheaper to implement and has higher SNR. DSP text books (at least the ones I've seen) does not consider time-varying coefficients and simulation of analog curcuits. The starting point is normally realization of a given discrete-time transfer function. That is why I think you and Urs won't see many DSP text books being rewritten. But I could be wrong of course.

Post

niarn wrote:
Z1202 wrote:Naive SVF is just one possible flavor of an SVF. What's the point of considering a particular case as "the" definition?
I'm not sure why you are saying that. I don't think I've said that. Anyway, when you or anyone else write naive SVF then I picture 1+(2-f^2-q)z^-1+(1-q)z^2. That is naive SVF to me.
The idea of SVF is bound to the topology, not to the transfer function. Naive and ZDF SVF have different transfer functions (the latter has the same one as "biquads"), but both are considered SVFs. At least that's how people usually understand SVF.
niarn wrote:[
Z1202 wrote: PS. The bottom line is, as Urs mentioned closer to the beginning of the thread, other things being equal, the ZDF SVF should be the default go-to 2-pole filter. Some specific reasons might dictate using DFs or other forms instead, but those reasons need to be determined before doing so.
I almost couldn't disagree more. DF1 is simpler to understand, cheaper to implement and has higher SNR. DSP text books (at least the ones I've seen) does not consider time-varying coefficients and simulation of analog curcuits. The starting point is normally realization of a given discrete-time transfer function. That is why I think you and Urs won't see many DSP text books being rewritten. But I could be wrong of course.
Simpler to understand -- maybe, although it's also questionable. I have a feeling that people claim that DFs are easier to understand because they *already* understood them, while ZDF requires to learn something new. Also a complete understanding of DF also should include understanding the process of deriving the coefficients. And I think this process is simpler in ZDF.

Cheaper to implement - maybe a bit, but not that much. IIRC, e.g. a ZDF SVF LP with predefined coefficients can be done in 7 math operations (adds and muls) and 2 state variables. Edit: or maybe it's something like 10, I don't have the reference right now and don't remember exactly.

Higher SNR - do you have any references? So far I'm not aware of SNR comparison between DF and ZDF. And I somehow doubt that DF performs better. Quantization noise is exactly one of the problems of DF which shows in 32 bit floats sometimes.

Simulation of analog circuits is an option. You can think of ZDF SVF as an abstract filter. Same transfer functions as biquad.

Realization of a given transfer function? Even easier than with DF. Because you don't need to convert an analog transfer function into the digital form (the bilinear transform which you do in classical DSP texts). It happens automatically.

Also the analog transfer functions (which are used as prototypes for the majority of the digital transfer functions in DSP texts) are simpler and more intuitive. And in ZDF you deal with those rather than with digital ones.

DSP text books not considering time-varying coefficients - that's exactly one of the points. In music DSP usually you need to vary the coefficients.

So yes, if you don't need to vary the coefficients or vary them very slowly and if you work in the range where the precision losses are tolerable, or use double precision, while you want an absolute minimum of the CPU cycles, yes DF can be *sometimes* a better solution. But if you use DF, you need to check *each time* whether those issues can be critical for you or not. That's what I meant by saying that the default go-to filter should be ZDF SVF, not DF, because the former works for granted in a much wider range of conidtions.
Last edited by Z1202 on Sun Jan 10, 2016 11:24 pm, edited 2 times in total.

Post

niarn wrote:I almost couldn't disagree more. DF1 is simpler to understand, cheaper to implement and has higher SNR.
Sorry to be a pain in the ass, but...

... are you certain this is true for the single precision floating point version of the vDSP Biquad filter the original poster asked about? What do you think the vDSP implementation does, the "v" in vDSP being short for "vector"? - It certainly loads and multiplies coefficient and state variables in parallel, only to add them in succession. Which is pretty much the opposite of what this fabled MAC does for biquads (I don't even think there is a MAC on the target CPU...). And isn't modern DSP all about vectorization hence about risk of loss of precision! Everything is different now, isn't it, no 80 bit floating point registers no more.

Did you furthermore realize that the thread starter asked about an implementation that can sweep parameters? And isn't exactly that something that the DF biquad model does not have a concept for?

And who in the context of musical applications really needs to mock about with poles and zeros, when there's less abstract concepts like frequency and q. And what if those could be calculated directly, independently and without formulas one needs a reference for?

Nevermind.

Post

Z1202 wrote:
niarn wrote:My personal understanding of an SVF filter is a filter that realizes the IIR part of a biquad using two coefficients f and q such that the denominator is given by 1 + (2-f^2-q)z^-1 + (1-q)z^-2
Nope. SVF effectively implements the entire biquad, both IIR and FIR parts. But you can't really think of it this way, because the FIR and IIR parts are not separated like in DF. It's a different topology.
Wait—isn't the state-variable filter structure inherently "all-pole" (zeros fixed at the origin)? I think that's what niarn was getting at.
My audio DSP blog: earlevel.com

Post

earlevel wrote:
Z1202 wrote:
niarn wrote:My personal understanding of an SVF filter is a filter that realizes the IIR part of a biquad using two coefficients f and q such that the denominator is given by 1 + (2-f^2-q)z^-1 + (1-q)z^-2
Nope. SVF effectively implements the entire biquad, both IIR and FIR parts. But you can't really think of it this way, because the FIR and IIR parts are not separated like in DF. It's a different topology.
Wait—isn't the state-variable filter structure inherently "all-pole" (zeros fixed at the origin)? I think that's what niarn was getting at.
I'm not sure what's the TF of a naive SVF (and I don't much care anymore), while for a ZDF SVF it's definitely not true. However, I guess I see your point. Although, this POV makes way more sense in the analog domain, where the basic structure of an SVF is indeed a direct counterpart of a DF2's IIR part. The three outputs correspond to the three different terms of the TF's numerator and by mixing them you can obtain arbitrary "FIR" parts.

Post

Z1202 wrote:I'm not sure what's the TF of a naive SVF (and I don't much care anymore), while for a ZDF SVF it's definitely not true. However, I guess I see your point. Although, this POV makes way more sense in the analog domain, where the basic structure of an SVF is indeed a direct counterpart of a DF2's IIR part. The three outputs correspond to the three different terms of the TF's numerator and by mixing them you can obtain arbitrary "FIR" parts.
Yes, I don't think it's important—just shedding a little light on niarn's comment. Good point on the outputs.
My audio DSP blog: earlevel.com

Post Reply

Return to “DSP and Plugin Development”