Login / Register  0 items | $0.00 New#KVRDeals

When to choose a ZDF

JCJR
KVRAF
 
2199 posts since 17 Apr, 2005, from S.E. TN

Postby JCJR; Sun Dec 03, 2017 8:23 am Re: When to choose a ZDF

matt42 wrote:Hi JCJR, sorry if I was explaining the obvious

Hi Matt. I don't think that was the case. Anyway obvious is good. One never knows what is obvious. Drove me nuts in some math texts-- The chapter begins with a few simple equations, then the famous words, "Therefore it is obvious that--" followed by a huge unintelligible equation having scant resemblance to the precedents. :) Shake the book-- Maybe a page is stuck together or a page fell out-- Nope. Oh well, it was obvious to the author anyway!
stratum
KVRian
 
1360 posts since 29 May, 2012

Postby stratum; Sun Dec 03, 2017 10:03 am Re: When to choose a ZDF

My understanding is that most of the time an unexplained 'obvious' that actually isn't so is a hint that the author wasn't there when the related concept was discovered (therefore he can't explain it) or that what you are reading wasn't intended to be teaching materal at all (therefore no such attempt is made.)
~stratum~
matt42
KVRian
 
944 posts since 9 Jan, 2006

Postby matt42; Mon Dec 04, 2017 11:37 am Re: When to choose a ZDF

JCJR wrote:Drove me nuts in some math texts-- The chapter begins with a few simple equations, then the famous words, "Therefore it is obvious that--" followed by a huge unintelligible equation having scant resemblance to the precedents. :) Shake the book-- Maybe a page is stuck together or a page fell out-- Nope. Oh well, it was obvious to the author anyway!

Yep, I know this pain too well :cry:
Max M.
KVRist
 
207 posts since 20 Apr, 2005, from Moscow, Evil Empire

Postby Max M.; Tue Dec 05, 2017 12:27 pm Re: When to choose a ZDF

JCJR wrote:But because at least casually both kinds of filter seem to behave so similer, it comes full-circle back to, at least in the first-order case, is there a reason to choose one or the other?

Just think of them as "the same filter" done via the same (or very similar) arithmetic expressions just in different order: it's literally no more difference than for example in `a*(b + c) = a*b + a*c` or even in `2+2=2*2=3+1=4`.
There may be differences in the result only due to an imperfection of the calculating engine itself (i.e. fixed-point vs. floating-point, 16 vs. 32 vs. 64 bits etc., e.g. same `a*(b + c) = a*b + a*c` snippet may fail with a limited arithmetics depending on the actual values of abc).

Maybe one of the filters works better on certain kinds of transients?

No. As soon as we know their transfer functions are equal, we also know they have the same outputs for whatever kind of inputs (yet again not counting ALU precision/limits).

Or maybe one filter is better-behaved when swept?

Yes, they behave differently.
In simple words: since the difference in topology is (roughly) the difference in the order of arithmetic operations, it's expected that when we change some coefficients there, while [1/z] unit value remains unchanged, the result will be different depending on where exactly that [1/z] value is used within these arithmetic operations. And then since this (always wrong) result is also fed back one way or another, we can get all sort of weirdness including self-oscillation depending on how big the error is (though for a first-order filters it's usually not that dramatical as for second-or-more-order stuff).
In general, when considering a time-varying stuff, it's important to concentrate on "what" topology we get instead of "how" ("bilinear", "trapezoidal", "whatever") we came to it.
Or, in other words, when it comes to practical implementations (of time-varying filters), what really matters is the understanding of the signal flow in the particular topology, while the transform or whatever strategy used to get the topology is absolutely irrelevant. Though, adopting/optimizing a topology for time-varying stuff (and limited-precision arithmetics) is an art on its own and it still waits for a dedicated book to be written yet (there're a lot of paper with a lot of math in though :), so to get back on topic:
Some TPT-based filters (but not "whatever" TPT-based filters) are usually not a bad choice for time-varying case, simply because they already include many (if not most) of the tricks of the said "time varying art". Not a surprise, since the time-varying behavior is taken into account here and there (within the VA book fo example) when making this or that decision there (just follow the text of the corresponding chapters).
In contrast, the direct form topology (you used for allpass above) is known to be quite bad for time-varying case (there're better alternatives for realizing a time-varying allpass filters).

---

In summary, and as a bonus remark for time-varying and single precision fp cases, I think it's also important to remind that the primary story of the TPT-thing as such is (roughly) about simulating electronic circuits (and especially non-linear circuits where a "preserved topology" is crucial).
And when we don't need a non-linearity inside our filter (or a non-linear filter as a whole is not supposed to mimic any circuit at all), a TPT-thing is not necessary the best choice.
Though I won't argue to:
mystran wrote:... you should always choose ZDF unless saving that one extra instruction ...
(especially when it comes to second-order filters) because this will immediately obligate me to point to some papers/examples, and I'm not ready for this kind discussion right now. (But someday I will argue :) The exact number instructions used in the end may not matter at all, but the very fact that we normally don't need any legacy circuits to construct a proper discrete filter may.)
JCJR
KVRAF
 
2199 posts since 17 Apr, 2005, from S.E. TN

Postby JCJR; Tue Dec 05, 2017 6:35 pm Re: When to choose a ZDF

Thanks very much Max for taking the time to explain so well. I think I get most of what you are saying.

A question which may lead to throwing up of hands, "Oh no, he doesn't understand anything even now"--

Before doing the comparison test, one result that seemed to me "might happen"-- The transfer functions would be real close or identical, but the direct form might have a slight fractional sample delay compared to the trapezoid filter.

Simple-minded ignorant reasoning-- Because in your direct form example, both the feedback and feedforward are delayed one sample, but the trapezoid implicit calc tries to "split the difference" a little closer to realtime-- I thought maybe the direct form filter output might turn out to have a slightly larger fractional sample delay.

I did not observe obvious evidence of such-- At high frequencies where the sine wave periods are only a few samples long, any extra fractional delay would probably have been obvious to the eye, looking at one filter output in Left, the other filter output in Right, in the stereo editor.

Is there a glib explanation why the two filters DO NOT seem to have fractional sample offsets from each other? Thanks.
matt42
KVRian
 
944 posts since 9 Jan, 2006

Postby matt42; Tue Dec 05, 2017 7:31 pm Re: When to choose a ZDF

If the transfer functions are the same then so are time domain artefacts such as group/phase delay. Therefore it should be obvious that... sorry can't think of any impenetrable equation to add :oops:
Max M.
KVRist
 
207 posts since 20 Apr, 2005, from Moscow, Evil Empire

Postby Max M.; Tue Dec 05, 2017 10:10 pm Re: When to choose a ZDF

JCJR wrote:The transfer functions would be real close or identical, but the direct form might have a slight fractional sample delay compared to the trapezoid filter.

No, as matt42 already noted, the transfer function determines both magnitude and phase responses (and phase response determines phase and group delay). So for filters with equal TFs all of this is identical.

Because in your direct form example, both the feedback and feedforward are delayed one sample ...

In direct forms the b0 route is not delayed.
JCJR
KVRAF
 
2199 posts since 17 Apr, 2005, from S.E. TN

Postby JCJR; Tue Dec 05, 2017 10:28 pm Re: When to choose a ZDF

I'm probably thinking about it wrong. If you delay a filter output by N samples then it has the same transfer function, except for the delay. All you have to do is time-align the two copies and they would null perfectly.

Thats what I was thinking "maybe possible" a fractional delay, not a different phase response.
Max M.
KVRist
 
207 posts since 20 Apr, 2005, from Moscow, Evil Empire

Postby Max M.; Tue Dec 05, 2017 10:39 pm Re: When to choose a ZDF

In a strict sense, when you delay a filter output you create a new filter with new transfer function.
Like you if you delay a naive-lp:
b = [1-k, 0], a = [1 k];
by one sample, the transfer function of the resulting filter is:
b = [0, 1-k], a = [1 k];
etc. Sure it can be easily seen it's still the same filter just delayed by one sample.

Though I can't see how this is related to our TPT vs. DF comparison... They are already perfectly time-aligned to each other, no need to delay one or another, thus they are really equivalent in all aspects (otherwise we cannot say their TFs are really equal, we would have to say something like: "as you can see the filters are equal but the latter or the former is delayed by N samples").

---
Edit: probably I can guess what your confusion is. You know that allpass filters are used for fractional-delays, and in this context, you think that an allpass-based LP also gets some extra delay a "normal" LP does not. But no, the "normal" LP has exactly the same group-delay as the "allpass-based" one.
Last edited by Max M. on Tue Dec 05, 2017 11:19 pm, edited 2 times in total.
JCJR
KVRAF
 
2199 posts since 17 Apr, 2005, from S.E. TN

Postby JCJR; Tue Dec 05, 2017 10:51 pm Re: When to choose a ZDF

Thanks Max. Obviously it works so I'll maybe have to stare at the flow charts awhile and try to figure out why they work identical.

For instance, a highly artificial way of two filters, identical transfer function half sample delay-- Feed sine sweep thru filter. Oversample 2X. Then downsample with a 1 sample offset. Two "identical" filter outputs amplitude and phase, except one of them trails the other by a half sample.
matt42
KVRian
 
944 posts since 9 Jan, 2006

Postby matt42; Tue Dec 05, 2017 11:19 pm Re: When to choose a ZDF

Or another way of looking at it. We can rearrange difference equations to transfer functions. So if we have a direct form difference equation that can be rearranged to a transfer function and a TPT difference equation that can also be rearranged to the same transfer function then it follows that we could rearrange the direct form difference equation to the TPT difference equation.
matt42
KVRian
 
944 posts since 9 Jan, 2006

Postby matt42; Wed Dec 06, 2017 3:20 am Re: When to choose a ZDF

JCJR wrote:For instance, a highly artificial way of two filters, identical transfer function half sample delay-- Feed sine sweep thru filter. Oversample 2X. Then downsample with a 1 sample offset. Two "identical" filter outputs amplitude and phase, except one of them trails the other by a half sample.

Not sure I follow. If you mean upsame by ratio of 2 then delay one signal by a sample at the higher ratio then downsample both signals then that would create a half sample delay over all. How does it relate to TPT vs direct form? Sorry if I'm being dense

Edit:

Maybe this helps? A delay of n samples is the same as multiplying by z^-n in the z plane. So a non shifted signal has a transfer function of 1, but a half sample delayed signal has a transfer function of z^-0.5. They are not the same

Edit 2

Allpass fractional delay isn't really fractional, it just approximates the phase shift of a real fractional delay
JCJR
KVRAF
 
2199 posts since 17 Apr, 2005, from S.E. TN

Postby JCJR; Wed Dec 06, 2017 10:37 am Re: When to choose a ZDF

Thanks Matt and Max for trying to help. I shouldn't have mentioned the curiosity question as it has led to the flogging of inconsequentials. Tis my fault for drifting the thread too weird.

Agreed, the allpass fractional delays I've read about seem to work "pretty good" except the top couple of octaves, where they converge toward the equivalent of repeat-sample interpolation. So to use a simple allpass for audio band fractional delay one might see success at 192 k or higher samplerate, where most of the allpass delay high frequency bad performance would be moved above 20 kHz.

Viewing a transfer function as a chart of input vs output, of course any delay would change the response. But taking a "known constant" input signal and comparing various filter results, you can have filter results "similar or identical" differing only in time offset. (This way of looking at it seems common in some applications, such as room acoustic analysis, where one might compare different room measurements by eliminating the delay differences as good possible).

If you master a song thru an EQ last week then listen today, then that week delay did not change the harmonic content of the EQ result. It just added a week delay between identical filter outputs.

Send a test signal thru black box A and black box B-- If at some delay alignment both outputs will null, then it is the same filter response, except for the delay difference. I was just thinking it perhaps possible that different filter topologies might turn out to skin the cat in entirely identical fashion, except for differing output time offsets. Perhaps a silly idea. :)
Previous

Moderator: Moderators (Main)

Return to DSP and Plug-in Development