A matrix approach to the Moog ladder filter

DSP, Plug-in and Host development discussion.
RELATED
PRODUCTS
JCJR
KVRAF
3080 posts since 17 Apr, 2005 from S.E. TN

Post Wed Oct 07, 2015 1:14 pm

One thing of interest was discussion of the wave digital filter for electronics, a network grid of "reflection nodes". Which may be incredibly old info for all I know.

Am typically ignorant, but had seen references about its use in reverb emulation, and acoustic room simulation. For room simulation as best I recall, every node in the grid might represent a cube of air in the room, and each cube would follow rules interacting with all its neighbors.

Mr Yeh in the introduction tries to limit his discussion to subsystems bounded by high impedance input and low impedance output.

Maybe some commercial modelers do very detailed emulation of power tube <-> transformer <-> speaker <-> air + cabinet. Dunno.

But that chain is a big ball of components, and each component is complicated in its own right. The air and cabinet affects the speaker, the speaker affects the transformer, the transformer affects the power tubes. The signal isn't going only one way from high impedance to low.

Had wondered how one would try to model such a complicated interaction. Perhaps that wave digital filter would be a valuable notion in trying to model the complicated interaction.

User avatar
aciddose
KVRAF
12518 posts since 7 Dec, 2004

Post Wed Oct 07, 2015 5:42 pm

To the best of my understanding of modern circuit simulators, they essentially break down to large matrices or "networks" and operations on those matrices.

E.g. http://www.linear.com/solutions/5739
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Miles1981
KVRian
1379 posts since 26 Apr, 2004 from UK

Post Thu Oct 08, 2015 1:35 am

That's when you want model everything. The issue is that these simulations cannot be made real time...
So then, you can have to compare the full system with smaller subsystems that are easier to solve, and see if you can make the assumption, the split being made on high imp/low imp "barriers".

User avatar
mystran
KVRAF
7287 posts since 12 Feb, 2006 from Helsinki, Finland

Post Fri Oct 09, 2015 7:45 am

JCJR wrote:One thing of interest was discussion of the wave digital filter for electronics, a network grid of "reflection nodes". Which may be incredibly old info for all I know.
While WDF is kinda cool formulation, it turns out that a standard MNA is basically equivalent (or rather, your MNA matrix becomes a general N-port scattering junction) if you apply a simple trick: encode the integration rule into your capacitor/inductor "stamps" and your state variables become pure delays just like in WDF. This is probably the most useful contribution of the WDF approach, since it saves you from a separate integration step (which can translate into slight computational speedup in practice). That said, it works perfectly fine with a generic matrix solver too.

The process of calculating scattering coefficients is almost exactly like the process of LU factoring a matrix. Your reflection free port then is the bottom row of the matrix: after forward substitution, before you solve backwards this node does not depend on anything else and you can order your matrix to put your non-linearities there (and in fact, you can also order multiple non-linearities to the bottom rows to iterate a reduced order system).

Whether you find it easier to formulate circuits into parallel series connections (such that you can use the WDF connection rules) or simply to stamp it all into a general matrix is up to you. For simple circuits WDF might be slightly less error-prone when done manually, where as for complex circuits you'll probably want to automate it either way, and it is generally easier to do this working with MNA directly (since you can just build it from a generic netlist, without having to worry about what to connect where).
Preferred pronouns would be "it/it" because according to this country, I'm a piece of human trash.

User avatar
Smashed Transistors
KVRist
142 posts since 10 Oct, 2014

Post Sat Oct 17, 2015 7:06 am

Surely, all these studies will converge to some real time audio Spice solver.
By the way, how far from real time are Spice or gnucap ?

Back to the initial topic. here is some java code for the step invariant linear 24 dB filter. It implements an iterative method that uses many simplifications for squaring the transition matrix.
It's slightly simpler than the analytic version. Six iterations provide a nice result.

Code: Select all

   public class MExpon {
            /*
      Step invariant 24dB filter        T.Rochebois oct15
            Transition matrix
            x  yA  yB  yC  yD
            
    new yA  a   e  -kh -kg -kf
    new yB  b   f   e  -kh -kg
    new yC  c   g   f   e  -kh
    new yD  d   h   g   f   e
            */

        double yA, yB, yC, yD;
        double nyA, nyB, nyC, nyD;

        double a, b, c, d, e, f, g, h;

        double proc(double x, double ff, double k, int iter) {
            //_____________________________________________________
            //                              CONTROL
            double ne, nf, ng, nh;
            double w = PI * ff * pow(2, -iter);
            // init with open loop step invariant coefs
            e = exp(-w);
            f = w * e;
            g = 0.5 * w * f;
            h = (1/3.0) * w * g;

            for (int i = 0; i < iter; i++) {

                ne = k * (-2 * f * h - g * g) + e * e;
                nf = 2 * (e * f - g * h * k);
                ng = -h * h * k + 2 * e * g + f * f;
                nh = 2 * (e * h + f * g);

                e = ne;
                f = nf;
                g = ng;
                h = nh;
            }

            d = (1 - e - f - g - h) / (k + 1);
            c = d + h;
            b = c + g;
            a = b + f;
            //_____________________________________________________
            //                                    AUDIO
            nyA = e * yA + a * x - k * (f * yD + g * yC + h * yB);
            nyB = e * yB + f * yA + b * x - k * (g * yD + h * yC);
            nyC = e * yC + f * yB + g * yA + c * x - k * h * yD;
            nyD = e * yD + f * yC + g * yB + h * yA + d * x;
            yA = nyA;
            yB = nyB;
            yC = nyC;
            yD = nyD;
            return yD;
        }  
    }
Last edited by Smashed Transistors on Sat Oct 17, 2015 2:54 pm, edited 1 time in total.
See you here and there... Youtube, Google Play, SoundCloud...

Miles1981
KVRian
1379 posts since 26 Apr, 2004 from UK

Post Sat Oct 17, 2015 8:22 am

Non linear equation solving is a rich field, but I don't think we will see a real time simulation of say a full amplifier in the near future. That would require lots of processing power. And the SPU speed is stagnating...

Return to “DSP and Plug-in Development”