[LAD] simulating analog audio devices

Pieter Palmers pieterp at joow.be
Fri Jun 1 13:43:36 UTC 2007

Erik de Castro Lopo wrote:
> Pieter Palmers wrote:
>> All spices I use (although this excludes ngspice)
> Last time I looked ngspice was the same code base as the others, so
> I assume no difference.
There is a significant difference between the various spice-like tools 
(hspice, eldo, spectre, pspice, pstar, ...). They all are based upon 
berkley spice, but that's where it ends... they have evolved. Especially 
with respect to solution algorithms and options they can differ a lot.

>> have an option to 
>> force them to calculate the response at specified timesteps (along with 
>> the ones they need for accuracy). In this case it seems obvious to set 
>> this timestep to 1/Fsample. Then use only the values at these timesteps. 
>> This is way better than interpolation because the differential equations 
>> are actually solved at these points.
> That would be true except for one factor, the input signal that Robin
> is trying to simulate is analogue. In addition, the Foxx fuzzbox that 
> Robin is trying to simulate is a non-linear device. 

I can't really comment on the fact that the problem is the generation of 
the input signal. Although... (see later)

The non-linear nature of the circuit doesn't matter that much. In 
transient simulations there is no circuit linearization performed, it 
simulates the nonlinear behavior pretty good. When solving the 
differential equations they can be linearized, but that shouldn't affect 
the results in a well-designed and well-configured algorithm.

> The problems you get when doing a discrete time simulation of non-linear
> processes are mitigated as the sample rate is increased. Therefore, the
> higher the sample rate the better.

Increasing the sample rate will of course help, but that is actually a 
side effect, and doesn't guarantee you better results. It won't increase 
the accuracy of the differential equation solution itself. It just 
forces a smaller timestep.

The better way is to have the simulator choose the points it needs to 
achieve a certain (predefined) accuracy. After all it is designed to 
choose them in a sane manner. In order to combat the (re-)sampling 
issues, you ask the simulator to also solve the equations in the 
discrete sample points you need, such that you have the "exact" results 
in these points.

This procedure comes down to asking the simulator to simulate a circuit 
with a certain accuracy (both time- as value-wise) and additionally 
having it generate the values for the timepoints you need.

Regarding the input signal:
What I would expect is that if you are able to specify the time points 
that have to be calculated, and if the input samples are used to 
calculate these timepoints, it should work rather good. The only thing 
the intermediate values are used for is the calculation of the 
derivatives, and some intermediate points that are discarded anyway. One 
could argue that their value doesn't really matter that much as long as 
the input value at a timepoint that is retained in the output is 
correct. Probably a first-order hold (i.e. linear interpolation) will 
already do fine.



More information about the Linux-audio-dev mailing list