A SOMEWHAT UNUSUAL APPROACH TO LUMPED ELEMENT MODELING: TIME DOMAIN IMPLEMENTATION OF COMPUTER-AIDED POLYNOMIAL SOLUTIONS TO LTI SYSTEMS VIA THE BILINEAR TRANSFORM (LUMPED ELEMENT TRANSDUCER EDITION)

INTRO

Imagine you want to simulate a speaker, utilizing Thiele-Small parameters. It’s traditional and “easy” to obtain a Frequency Response, but we live in the time domain, and you can’t hear a graph. I’ve stumbled into a method for directly translating any lumped element model of an LTI system into a set of filters which allow you to model the system’s response in time! Not only can we obtain the frequency response of a driver, but we can listen to it directly. Imagine being able to simulate a few speakers and select the one that sounds best!

In addition to an efficient means for auralization directly from the lumped-elements, I offer a unique solution to simulating the impedance of a loudspeaker.

THE LUMPED ELEMENTS

In the basic assumption of a lumped element model for a loudspeaker, where the 3 domains of a speaker are “analogized” to circuit elements, coupled via a gyrators (transformer shown due to Kicad limitations), the above circuit can be simulated (choose your poison) to examine transducer behavior in any of the three domains. The trick here is that the behavior of a speaker in the time domain is a mess of differential equations but circuit elements themselves have very nice solutions once you flip over to the frequency domain. Let’s start with a simple example.

A SIMPLE EXAMPLE AS A JUSTIFICATION FOR USING FREQUENCY DOMAIN

For example, for an RLC circuit ((R=0Ω for simplicity, resistance is not differential with frequency)

The time domain analysis looks something like this, where I is current and V is voltage.

written in keynote because LaTex

The main issue here is that to calculate current you must evaluate an expression which itself requires knowledge of the derivative of the current. This is a differential equation! It’s not impossible to compute this numerically (that is, assume a small δ and step through time little by little) but obtaining an “analytical” solution to the equation requires a special set of skills.

If instead you instead do some clever stuff with frequency, based on 1) Euler’s Identity and 2) the understanding from the Fourier Theorem that any signal may be represented by an infinite series of sine waves, there are some very handy and very useful solutions to differential equations. (warning: I’m using j notation for imaginary numbers)

Here’s my mini proof, where j is the square root of negative 1, ω is frequency, and t is time:

By taking advantage of the Euler identity and the very special property of e that it’s derivative is itself, we can evaluate the differential equations and reduce them to simple polynomial math (more on that later).

Since we now know the complex impedance of these circuit elements, the series circuit can be “solved” as such:

The final expression is a fully accurate solution to the circuit, and it tells us a lot about the behavior of the circuit. For instance: for a given current and frequency, increasing capacitance will lower voltage (the capacitor will proportionately charge less) and lowering frequency will increase voltage (capacitor will charge more!) but this is counteracted by the decreasing impeance of the inductor. Makes sense, but let’s visualize it to get the wholes story!

If the poison you so choose is a frequency domain analysis, you can easily plot the frequency domain response by substituting s = j*2*pi*f where f is an vector of sample points in Herz (e.g. f=[1,2,3…48kHz]). Here’s some simple Matlab code to do this:

f = 1:fs; %sample points
omega = 2*pi.*f; %convert to angular frequency
s = 1i*omega;
C=100e-6; %Farads
L=10e-4; %Henries
R=1; %Ohms
Z=1./(s*C)+s*L+R; %series circuit impedance

An interesting note before we go to the Laplace domain: the impedance of this circuit looks a lot like a graph of a quadratic function. In fact, if we replace with a variable…say s, it can be written as:

So, we’ve turned a differential equation into a polynomial equation!

BUT WHAT ABOUT TIME?

Bing, bang, boom! Frequency response of a lumped element circuit with an elegant polynomial solution! But what about time the time domain filter I promised? Armed with a frequency response (hitherto known as FR), it is certainly possible to create a time domain transfer function or filter. Here are some methods I’ve tried:

Methods to convert a Frequency Response (FR) to a time-domain filter

methodbig Opros, cons
IFFT(FR) → time domain convolution with signal O(m*n)
m is resolution of FR
n is signal samples
+ simple, rather direct
– accuracy limited by FR resolution
– super slow
DFT(signal) x FRO(m log n)+ relatively easy to understand and implement
– not “real-time” i.e. requires “frames” with overlap and add
– time domain artifacts due to finite signals, finite resolution
FIR2: Frequency sampling-based FIR filter designO(m log n)?+ brute force solution
– memory intensive filtering: very high order filter required for any reasonable accuracy (N==Fs)
– accuracy limited by FR resolution
filter coefficient optimization:
run steepest descent optimization on filter coefficients until filter matches FR
∞ for optimization (optimality not guaranteed)
O(n)* once filter is converged∞
*technically O(m*n) but filter order can be kept as low as order of system
+ kind of cool
+ extra brute force solution
– optimizing the filter is not a guaranteed-to-work process depending on FR complexity

None of these are especially satisfying to me because they’re all rather messy approximations with a few levels of abstraction. This is the meat and potatoes of this post. There are two handy dandy pieces of math we need: the Laplace transform, which converts from time domain to the complex frequency s-domain, and the bilinear transform which converts directly from the LaPlace s-domain equation to the discrete time domain of digital signals (airhorn noises). This is huge! We already did the frequency domain math for Rs, Ls, and Cs!

There’s just one thing: the Laplace domain is in terms of the complex frequency variable 𝑠 where 𝑠=𝜎+𝑗𝜔. We are allowed to convert from the Fourier domain to the LaPlace domain if we set 𝜎=0, which is more-or-less an assertion that the system is stable and the input is continuous (in time) and real (in frequency). Then we can simply replace every 𝑗𝜔 with an 𝑠:

This last expression is what is sometimes referred to as the polynomial solution. Let’s take that into the time domain:

Example code:

C=100e-6; %Farads
L=10e-4; %Henries
R=1; %Ohms

%polynomial expression
a=[L R 1/C] %denominator
b=[0 1 0] %numerator

[B,A]=bilinear(b,a,fs);

%results — this is all you need to filter any signal!
B = 0.0103 0.0000 -0.0103
A = 1.0000 -1.9751 0.9794

Checking the results shows alignment (of course!)

Ain’t that great? What’s great about this method is that this is the exact answer to “how will this circuit behave in response to a signal?” There are no cons (except for sampling frequency)!

methodbig Opros, cons
Bilinear transform of polynomial solutionO(n)*
technically m*n where m is the order of the system
+ it’s the exact solution
+ super fast
+ gives you F(f) and F(t)
+ sounds cool
– you have to “solve” the circuit

To bring it home, we can also filter any time signal with our RLC circuit, giving us the time response. Here’s a 10V stepped input:

Or a stepped sine wave:

Admittedly, the bilinear transform is a discrete time approximation of a continuous time object—and so is a digital signal— but in comparison, say to a the FIR2 approach, which requires, for reasonable levels of accuracy, a 48,000-term filter, I find it much more satisfying to have a 6-term filter derived directly from the physical properties of the circuit.

APPLYING THIS METHOD TO ACOUSTICS

Now that we have a method that’s copacetic for a simple example, let’s apply this to the electro-mechano-acoustic domain! This is where the cons come in. While the math is simple and exact, the algebra quickly becomes nightmarish for complex systems. A simple transducer model is relatively simple until you chase down the acoustic terms, and then it becomes hellish, but I have a solution for that, too. Observe:

Factoring this chonky conglomeration to obtain coefficients yields something so grotesque it cannot be displayed readably with LaTex:

But using the power of the symbolic library, we can easily collect the terms and calculate the coefficients:

Turning Z(s) into a time domain filter Z(t) is as simple as taking the bilinear transform of 1/Z again! The results are validated with a comparison to a full speaker simulation software. If you’re wondering where the orange line is, it’s directly beneath the yellow line.

Admittedly, the model with acoustic impedance added is very close to the one without, but we’re here for precision anyway!

Inverting to impedance:

Checking it against a real transducer (I switched TS parameters for this one to the ND91-4 by Dayton Audio, a classic mini-woofer)—overlaying the simulated response on top of the DATS measured impedance response (blue line) by Dayton Audio vs our orange polynomial line, it looks pretty damn close up to 1kHz! The loss off accuracy above 1k is most likely due to the secondary inductance/resistance of the magnetic circuit, which is not typically reported by manufacturers in the TS parameters or datasheets and therefore not modeled.

Et voila! with a little bit of computer assisted algebra, we can take a lumped element model and convert it into a time-domain filter to be applied directly to incoming signals. In this case, we solved the algebra to get us the time-domain impedance of a transducer model, but with some simple re-arranging and a little code we can convert voltage to excursion, SPL, velocity, transmitted force, and much more!

HELENS

Did you know
you can squeeze
oil from stone?

With enough heat / pressure
+ a dash of wanton capitalism
And you can coerce shale to cry

Teardrops are always surprisingly hot
Though less valued than shale’s
The process feels similarly igneous

I scream at the wheel
through tears taken from me:
I imagine you in the passenger seat

next to me
holding me steady
a drink

“Well, sure, it hurts—”
you start gently,
full of kindness,

and then you look at me
with eyes like we could take on
an errant volcano, with aplomb

And you say

I’m gone now
You can’t change that.
But you can do anything

So what are you going to do now?

NEGATIVE CREEP

have you ever felt like outer space     here’s a lame
buddhist riddle    what is the sound of
silence   when I was 13    I chose a name
to write on the world    to fill in the silent space
with paint     unaware of irony then    but I
was still clever    my name is    A    B   S   E   N   T

last night close my eyes    but I still think of you    
j’hallucine       hello Alice    no let me explain 

      it starts with     !     roaring     
tastes loud     like the
heart of a star dying       where
gold is made     what is my size    I am the
wrong size    
    my body the magnitude of Creation
my arm is a spiral arm  my feet are
still in bed    the only landmark is 
sound who
is roaring   who is yelling like
time as it greedily gobbles lives
swallows worlds     this is nothing
so pretty as the sound of Death who is
sonorous and deep like the tomb of god
falling shut     no this is the sound of god
preying  anti noise the shout of   the
void   Hungry    it is creeping     looking    
for me

Dublin night, walking home, You
ketamine? Guinness.

ours    we are exactly who we need to be     we
are exactly where we need to be

In this memory I am
So happy
Full

I would change nothing. But remembering it
in bed now, I trip. Don’t worry girl, it’s
not you. Just all the small things     I’ve been
through    eh

It’s a sober and vivid hallucination,
a combinatorial flashback. Not a dream.
I roll over to write this and I feel my arms
swing     the span of solar systems    everything
i touch unfathomably far away     i have PTSD   
when i think of you       i hallucinate        
in space          

in between dimensions
      break here in case of emergency   
thoughts too   break       my body 
slides?  a part 

the fracture flows    a razor sharp crack across the
diagonal of your body   your left lower corner:
your pinky toe but not like not ah   not   the
location does not exist or should not   imagine
um imagine if you had become a flat square
for all eternity    i did it once it was
terrible   no uh imagine um your left leg but
maybe behind you as if you had broken it
completely 

the right top corner: above your right eye by
where your uncertainty lives  offset and always a
bit perpendicular to your other eye   as if you
had broken that bit too     

not that the right eye points in a different
direction    your left eye just sees half-
dimensions   useful for imitating Picasso    
less useful when drunk     the right eye sees
wholly     it got the extra bits   

anyway that’s
where the right corner is it’s offset up a bit
and perpendicular or something I don’t know
I’m not a poet    I’m just hallucinating

as the crack flows   lightning-fast very sharp
corner to corner    i disrupt into parts   
the way a mirror does     something that
once was whole and full    which held worlds   
now is unbearable to look into    fragments 
scattering reflection    in- 
complete pieces    

each split   like fission   takes something from
this world   you never get back   if you just
put the pieces back together    like a mirror   
you are left   with less    just look at yourself

the lines that split are incredibly thin    but if
you are not careful or cared for,    if you are
not whole   

then there is empty space   

and  it shouts 
the void    is hungry    it comes through   in
between the pieces of me    it crawls through
those cracks    fast   faster than you can mend   
faster than you breathed me in   faster than
you forgot me   and once here    it will not
leave :  
negative creep

in negative creep you write this     but a person
who cares?     they say     if you are not
whole     there is a thing called kintsugi         to
repair broken pottery with gold in the cracks    
first you need acceptance and glue    but then
when you hallucinate     you can look amongst
the screaming stars      to find your pieces 

and there you may even find a lil bit of gold