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!matt42 wrote:Hi JCJR, sorry if I was explaining the obvious
When to choose a ZDF

JCJR
 KVRAF
 2342 posts since 17 Apr, 2005 from S.E. TN
Re: When to choose a ZDF

stratum
 KVRAF
 1841 posts since 29 May, 2012
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
 1057 posts since 9 Jan, 2006
Re: When to choose a ZDF
Yep, I know this pain too wellJCJR 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!

Max M.
 KVRist
 262 posts since 20 Apr, 2005 from Moscow, Russian Federation
Re: When to choose a ZDF
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`.JCJR wrote:But because at least casually both kinds of filter seem to behave so similer, it comes fullcircle back to, at least in the firstorder case, is there a reason to choose one or the other?
There may be differences in the result only due to an imperfection of the calculating engine itself (i.e. fixedpoint vs. floatingpoint, 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).
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).Maybe one of the filters works better on certain kinds of transients?
Yes, they behave differently.Or maybe one filter is betterbehaved when swept?
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 selfoscillation depending on how big the error is (though for a firstorder filters it's usually not that dramatical as for secondormoreorder stuff).
In general, when considering a timevarying 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 timevarying 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 timevarying stuff (and limitedprecision 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 TPTbased filters (but not "whatever" TPTbased filters) are usually not a bad choice for timevarying case, simply because they already include many (if not most) of the tricks of the said "time varying art". Not a surprise, since the timevarying 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 timevarying case (there're better alternatives for realizing a timevarying allpass filters).

In summary, and as a bonus remark for timevarying and single precision fp cases, I think it's also important to remind that the primary story of the TPTthing as such is (roughly) about simulating electronic circuits (and especially nonlinear circuits where a "preserved topology" is crucial).
And when we don't need a nonlinearity inside our filter (or a nonlinear filter as a whole is not supposed to mimic any circuit at all), a TPTthing is not necessary the best choice.
Though I won't argue to:
(especially when it comes to secondorder 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.)mystran wrote:... you should always choose ZDF unless saving that one extra instruction ...

JCJR
 KVRAF
 2342 posts since 17 Apr, 2005 from S.E. TN
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.
Simpleminded 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.
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.
Simpleminded 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
 1057 posts since 9 Jan, 2006
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

Max M.
 KVRist
 262 posts since 20 Apr, 2005 from Moscow, Russian Federation
Re: When to choose a ZDF
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.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.
In direct forms the b0 route is not delayed.Because in your direct form example, both the feedback and feedforward are delayed one sample ...

JCJR
 KVRAF
 2342 posts since 17 Apr, 2005 from S.E. TN
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 timealign the two copies and they would null perfectly.
Thats what I was thinking "maybe possible" a fractional delay, not a different phase response.
Thats what I was thinking "maybe possible" a fractional delay, not a different phase response.

Max M.
 KVRist
 262 posts since 20 Apr, 2005 from Moscow, Russian Federation
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 naivelp:
b = [1k, 0], a = [1 k];
by one sample, the transfer function of the resulting filter is:
b = [0, 1k], 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 timealigned 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 fractionaldelays, and in this context, you think that an allpassbased LP also gets some extra delay a "normal" LP does not. But no, the "normal" LP has exactly the same groupdelay as the "allpassbased" one.
Like you if you delay a naivelp:
b = [1k, 0], a = [1 k];
by one sample, the transfer function of the resulting filter is:
b = [0, 1k], 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 timealigned 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 fractionaldelays, and in this context, you think that an allpassbased LP also gets some extra delay a "normal" LP does not. But no, the "normal" LP has exactly the same groupdelay as the "allpassbased" one.
Last edited by Max M. on Tue Dec 05, 2017 11:19 pm, edited 2 times in total.

JCJR
 KVRAF
 2342 posts since 17 Apr, 2005 from S.E. TN
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.
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
 1057 posts since 9 Jan, 2006
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
 1057 posts since 9 Jan, 2006
Re: When to choose a ZDF
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 denseJCJR 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.
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
 2342 posts since 17 Apr, 2005 from S.E. TN
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 repeatsample 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.
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 repeatsample 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.