Yes, tf2snp takes the same coefficients as tf2s and simply uses a
normalized ladder in place of direct form.

Building on Oleg's test:

import("stdfaust.lib");
F = 20;
w1 = 2*ma.PI*F;
a1s = -2.0*cos((ma.PI)*-1.0 + ma.PI/4.0);
// c1 = no.noise <: fi.highpass(2, F) - fi.svf.hp(F, 1/sqrt(2)) : abs <:
max ~ _;
c1 = no.noise <: fi.tf2s(1,0,0,a1s,1,w1) - fi.svf.hp(F, 1/sqrt(2)) : abs <:
max ~ _;
c2 = no.noise <: fi.tf2snp(1,0,0,a1s,1,w1) - fi.svf.hp(F, 1/sqrt(2)) : abs
<: max ~ _;
c3 = no.noise <: fi.tf2s(1,0,0,a1s,1,w1) - fi.tf2snp(1,0,0,a1s,1,w1) : abs
<: max ~ _;
process = c1,c2,c3;

I get the following, which reveals that tf2snp is only equivalent to near
single-precision:

> faust2plot tfilterforms2.dsp ; tfilterforms2 | head -19 | tail -16
tfilterforms2;
 5.94191363e-13 8.6378257e-13 1.36150856e-13; ...
 3.28873284e-08 8.64758931e-09 6.91990465e-09; ...
 1.0500662e-07 1.39464731e-07 6.91990465e-09; ...
 1.94646418e-07 1.39464731e-07 2.45558056e-07; ...
 6.37024641e-07 9.18652745e-07 1.5576336e-06; ...
 9.01985914e-07 2.73871728e-06 3.63533763e-06; ...
 9.01985914e-07 5.5770879e-06 6.07131096e-06; ...
 1.77370384e-06 9.62469949e-06 1.14093773e-05; ...
 2.31526792e-06 1.46943867e-05 1.69789128e-05; ...
 2.31526792e-06 2.09300233e-05 2.25049243e-05; ...
 3.19257379e-06 2.87696512e-05 3.19220744e-05; ...
 3.19257379e-06 3.81610662e-05 4.1330477e-05; ...
 3.24938446e-06 4.94165179e-05 5.26635486e-05; ...
 3.24938446e-06 6.21273939e-05 6.31934236e-05; ...
 6.71017915e-06 7.67362799e-05 8.33912782e-05; ...
 6.71017915e-06 9.31680188e-05 9.84042126e-05; ...

> faust2plot -double tfilterforms2.dsp ; tfilterforms2 | head -19 | tail -16
tfilterforms2;
 7.5769744109857335e-22 3.640185435972672e-22 5.4241431701395508e-22; ...
 4.1741783640691921e-17 6.4356546496852899e-17 1.3259527835107894e-17; ...
 7.9797279894933126e-17 4.4276174984586505e-12 4.427450453041104e-12; ...
 4.2587461335230614e-16 2.6556460185216514e-07 2.6556460145340977e-07; ...
 4.2587461335230614e-16 1.3304364976463469e-06 1.3304364979947082e-06; ...
 6.3057198351756938e-16 3.4398911646396636e-06 3.4398911652766536e-06; ...
 1.8917159505527081e-15 6.5049579631989668e-06 6.5049579651174685e-06; ...
 1.8917159505527081e-15 1.0891528340514803e-05 1.0891528341963986e-05; ...
 1.8917159505527081e-15 1.6213594965378233e-05 1.6213594966810504e-05; ...
 1.8917159505527081e-15 2.2770536711858402e-05 2.2770536712612905e-05; ...
 1.8917159505527081e-15 3.1038733722214364e-05 3.1038733723747737e-05; ...
 1.8917159505527081e-15 4.0808441228132372e-05 4.080844122917879e-05; ...
 6.1825544683813405e-15 5.2550489812849971e-05 5.255048981899443e-05; ...
 6.1825544683813405e-15 6.5614674219184902e-05 6.5614674221410715e-05; ...
 6.1825544683813405e-15 8.0627352991051102e-05 8.0627352992696636e-05; ...
 6.1825544683813405e-15 9.7344218229664599e-05 9.7344218234831717e-05; ...

> faust2plot -quad tfilterforms2.dsp ; tfilterforms2 | head -19 | tail -16
tfilterforms2;
 6.22001047e-25 8.27180613e-25 1.51773683e-25; ...
 4.81749989e-20 2.71050543e-20 1.66724456e-20; ...
 2.27428346e-19 4.42718778e-12 4.42718778e-12; ...
 4.10387463e-19 2.65564609e-07 2.65564609e-07; ...
 4.10387463e-19 1.33043648e-06 1.33043648e-06; ...
 4.10387463e-19 3.43989109e-06 3.43989109e-06; ...
 4.80267681e-19 6.50495804e-06 6.50495804e-06; ...
 9.88910966e-19 1.08915283e-05 1.08915283e-05; ...
 9.88910966e-19 1.62135948e-05 1.62135948e-05; ...
 9.88910966e-19 2.27705368e-05 2.27705368e-05; ...
 9.88910966e-19 3.10387331e-05 3.10387331e-05; ...
 9.88910966e-19 4.08084416e-05 4.08084416e-05; ...
 1.73133534e-18 5.25504911e-05 5.25504911e-05; ...
 1.73133534e-18 6.56146731e-05 6.56146731e-05; ...
 4.77133659e-18 8.06273529e-05 8.06273529e-05; ...
 4.77133659e-18 9.73442147e-05 9.73442147e-05; ...

The "p" in tf2snp means "protected", meaning that the poles are bounded
away from the unit circle, but that should not be kicking in here, I would
think.  Perhaps more likely is the use of libc functions like tan() which
are always in single precision?

All we can conclude from this test is that tf2s and svf are closer to each
other than either is to tf2snp.

More concerning is how much tf2snp differs from the others after many
samples:

> faust2plot tfilterforms2.dsp ; tfilterforms2 -n 100000 | tail -16
tfilterforms2;
 0.00228387304 0.141309932 0.143120304; ...
 0.00228387304 0.141309932 0.143120304; ...
 0.00228387304 0.141309932 0.143120304; ...
 0.00228387304 0.141309932 0.143120304; ...
 0.00228387304 0.141309932 0.143120304; ...
 0.00228387304 0.141309932 0.143120304; ...
 0.00228387304 0.141309932 0.143120304; ...
 0.00228387304 0.141309932 0.143120304; ...
...

> faust2plot -quad tfilterforms2.dsp ; tfilterforms2 -n 100000 | tail -16
tfilterforms2;
 3.71743109e-15 0.141412452 0.141412452; ...
 3.71743109e-15 0.141412452 0.141412452; ...
 3.71743109e-15 0.141412452 0.141412452; ...
 3.71743109e-15 0.141412452 0.141412452; ...
 3.71743109e-15 0.141412452 0.141412452; ...
 3.71743109e-15 0.141412452 0.141412452; ...
 3.71743109e-15 0.141412452 0.141412452; ...
 3.71743109e-15 0.141412452 0.141412452; ...
...

This could still be normal numerical troubles (as opposed to a bug),
because setting F to ma.SR/4 (maximum pole separation for the highpass)
yields

> faust2plot tfilterforms2.dsp ; tfilterforms2 -n 100000 | tail -16
tfilterforms2;
 3.57627869e-07 2.98023224e-07 1.78813934e-07; ...
 3.57627869e-07 2.98023224e-07 1.78813934e-07; ...
 3.57627869e-07 2.98023224e-07 1.78813934e-07; ...
 3.57627869e-07 2.98023224e-07 1.78813934e-07; ...
 3.57627869e-07 2.98023224e-07 1.78813934e-07; ...
 3.57627869e-07 2.98023224e-07 1.78813934e-07; ...
 3.57627869e-07 2.98023224e-07 1.78813934e-07; ...
 3.57627869e-07 2.98023224e-07 1.78813934e-07; ...
...

> faust2plot -double tfilterforms2.dsp ; tfilterforms2 -n 100000 | tail -16
tfilterforms2;
 7.2164496600635175e-16 7.7715611723760958e-16 4.4408920985006262e-16; ...
 7.2164496600635175e-16 7.7715611723760958e-16 4.4408920985006262e-16; ...
 7.2164496600635175e-16 7.7715611723760958e-16 4.4408920985006262e-16; ...
 7.2164496600635175e-16 7.7715611723760958e-16 4.4408920985006262e-16; ...
 7.2164496600635175e-16 7.7715611723760958e-16 4.4408920985006262e-16; ...
 7.2164496600635175e-16 7.7715611723760958e-16 4.4408920985006262e-16; ...
 7.2164496600635175e-16 7.7715611723760958e-16 4.4408920985006262e-16; ...
 7.2164496600635175e-16 7.7715611723760958e-16 4.4408920985006262e-16; ...
];
...

> faust2plot -quad tfilterforms2.dsp ; tfilterforms2 -n 100000 | tail -16
tfilterforms2;
 4.10099472e-16 3.96926415e-16 1.30158471e-16; ...
 4.10099472e-16 3.96926415e-16 1.30158471e-16; ...
 4.10099472e-16 3.96926415e-16 1.30158471e-16; ...
 4.10099472e-16 3.96926415e-16 1.30158471e-16; ...
 4.10099472e-16 3.96926415e-16 1.30158471e-16; ...
 4.10099472e-16 3.96926415e-16 1.30158471e-16; ...
 4.10099472e-16 3.96926415e-16 1.30158471e-16; ...
 4.10099472e-16 3.96926415e-16 1.30158471e-16; ...
...
which makes all three filter forms look like they are correct to the
expected precision, except that -quad looks like -double.

Maybe a good next step is to compare all three to the "true" response
(beyond quad accuracy), calculated in, e.g., maxima

- Julius

On Sat, Dec 19, 2020 at 2:10 PM Oleg Nesterov <o...@redhat.com> wrote:

> On 12/19, Dario Sanfilippo wrote:
> >
> > I was following this text:
> > http://www.willpirkle.com/Downloads/AN-4VirtualAnalogFilters.pdf.
>
> Thanks! I will read it later... may be ;)
>
> > Julius, would you have a function to calculate the coefficients for
> > fi.tf2snp?
>
> Julius will correct me, but I think the coefficients should be the same.
> IOW, you can simply copy-and-paste the implementation of fi.highpass()
> and replace "tf2s" with "tf2snp".
>
> However it is not clear to me what can we do to check which one is more
> stable wrt quantization. I don't think svf can beat tf2snp, but I don't
> understand this magic enough.
>
> Oleg.
>
>
>
> _______________________________________________
> Faudiostream-users mailing list
> Faudiostream-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/faudiostream-users
>


-- 
"Anybody who knows all about nothing knows everything" -- Leonard Susskind
_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to