The technical modelling thread

I’m not sure whether this thread was opened to talk about circuit modeling or about amplifier modeling in general.

If I were starting from scratch today (which is not my case), I might begin with a black-box approach and take a look at the NAM GitHub project, perhaps trying to understand whether there's room for improvement somewhere, mainly for my own purposes (so not for selling plugins).

If instead we want to talk about circuit-level simulations (and here I assume I’m sufficiently familiar with the state of the art):

  • Non–real-time simulations can be done with SPICE simulators/editors. My favorites are TI Tina and ngspice, but there are others, even more well known (e.g. PSpice, LTSpice). Both TI Tina and ngspice allow processing WAV files (ngspice needed a small code modification). You still need to look online for 12AX7 models, and possibly power tube models as well (EL34, 6L6, etc.). They can be found quite easily. I wouldn’t underestimate these tools, even though they don’t run in real time. They help build an understanding of how guitar amplifiers work, and with some oversampling and batch scripting you can achieve, in my opinion, very good sounds. But it requires patience. That's what I did for years.

  • Real-time simulations using existing tools: LiveSpice is a very interesting one.

  • Real-time simulations built from scratch: here you need not only a basic understanding of how circuits work, but also C++ development skills, at least basic knowledge of matrices (basic operations, determinants, invertibility, etc.) or at least how to determine transfer functions, and knowledge of iterative root-finding algorithms (e.g. Newton–Raphson-like methods).

Note: not all circuit simulations are built in the same way. Ideally they should get the same results of a Spice simulation (if they are using the same non linear models), but it is not always the case. Some crucial choices must be made, such as how to represent the circuit, whether to split it into blocks (and what to put in each block), and which models to use to represent nonlinear components (e.g. 12AX7, transistors, op-amps, transformers, pentodes, etc.). Newer models are supposed to be more refined than older ones.

In the case of DiBiQuadro: our simulations prioritize accuracy and precision at the expense of performance (implicitly, we are aware of the basic performance optimization techniques you're already referring to in this 3ad).

Regarding the third scenario (real-time circuit simulations from scratch): IMHO it's pointless to invent or over-discuss these topics on forums - even though you're free to continue, of course - because there are resources specifically dedicated to this kind of subject (e.g. DAFx, specific master and PhD engineering theses on these topics, etc.). If you have the necessary background, it makes much more sense to educate yourself by reading those materials directly.
 
std::cos and std::sin are certainly slower than a LUT. I'm aware of phase accumulation and polyblep approaches - what else is there?

std::cos and sin are too slow to be running on a per sample basis across an entire amp schematic IMO.

It depends on your accuracy requirements of course, but because of vectorization and branchless processing, libm sin()/cos() is often faster than an interpolated LUT. Even a Taylor series can be faster. Anyway, just sharing a fun and counter-intuitive fact.
 
I think we’ll find a lot more people like these conversations when they can speculate without knowing anything. Certainly well beyond my depth, but I usually find this stuff interesting. I always wondered about the component modeling and the quest for accuracy where accurate might not always be equal to sounding better. Traditional guitar sounds are a whole system of things that sound bad on their own that then gets filtered by a speaker/microphone/eq. Why not virtually use components that just sound good from input on?
Sounding better isn't really the purpose. Some guitars just don't mix well with some real amps and it just happens. A boomy amp mixed with a muddy/warm guitar might never work for someone. Likewise with bright and bright. Some amps even sound awful by themselves unless they are dialed in to certain settings.
Unfortunately sounding good and sounding completely authentic are different end goals

Having an emulation and stating that its an exact copy of an amp and then it isn't doesn't help the people looking to replace or substitute their actual amplifiers. If someone tours locally with a Rectifier but then gets a gig remotely would benefit from having a portable option.

Having said that, all of these solutions are very close at this point and any would do for my purpose. It's only through some of the expertise here that I learn more.
 
Last edited:
Wonder if @FractalAudio reads this, chuckles, and says what a bunch of morons.

Seems as though he’d have more knowledge on this than any singular person on the planet.

The thought has crossed my mind…What’s his retirement plan? Will the fractal equations be passed down like the KFC spice blend? would he want to see his work continued like mathematicians/physicists and release it all for the next gen to further.
That’s a valid point , I mean realistically if the 4th gen product arrives later this year or next and it built to go 8 to 10 years , plus your going to have AI and machine learning continue to improve

The overseas companies continue to improve quality at lower price points etc
It’s anyone’s guess if there will be AXE 5 in 2035 , will we still be hear arguing about accuracy and leds ?

Who knows
 
You rarely, if ever, need sin or cos for amp modeling. More common trig functions encountered are tanh and atan. I personally am not a fan of LUTs but use them when necessary. I prefer polynomials when possible.

There are many different techniques for nonlinear modeling (which is the crux of the issue). If the circuit is linear you can simply use linear digital filters.

There are nodal techniques: K-method, DK-method, modified nodal analysis (MNA), etc. SPICE is an example of MNA. Wave Digital Filters (WDFs) are another technique and are a type of scattering method.

Regardless of the technique, and it doesn't really matter which of the techniques you use, the weakest link is the actual nonlinear models themselves. You can see this yourself by using SPICE and trying different models for the nonlinear components. You can get drastically different results. More complex models can give better accuracy but increase the required CPU power.

Stability is another bugbear. All the methods suffer from stability issues to varying degrees.

To understand stability consider a tube triode. The plate current is a function of the grid voltage AND the plate voltage. If the plate voltage decreases the current decreases. But if the current decreases the voltage increases (assuming a resistive load). But if the voltage increases the current increases and the voltage decreases but then the current decreases and the voltage decreases but... The solution is to use a solver like Newton's method but sometimes the solver has difficulty converging. The greater the distortion the more difficult it can be for the solver to converge.

Trying to model a complete amplifier using any of the techniques in real time is nearly impossible. As the complexity grows the matrices grow and the required CPU power grows exponentially.

Eventually, someday, we'll be able to enter a netlist and evaluate that in real time. We're getting close now. There are real time SPICE simulators that can obtain near real-time performance, albeit with simplified nonlinear models. I'd say that is still another decade or so away.

The reason you need an actual amplifier in addition to the schematic is that there are things that the schematic doesn't show. For example, a schematic often won't show the turns ratios of the transformers and certainly not the winding resistance. The B+ voltages are often not shown. Pot tapers aren't always indicated. Etc. Another issue is that schematics are often incorrect.

Schematics also don't show, because they simply cannot, parasitics. Many amplifiers exhibit unpredicted behavior due to parasitic elements. Crosstalk, parasitic capacitance/inductance, etc. can affect the behavior. For example, output transformer leakage inductance wouldn't be indicated on a schematic and often not even on the transformer spec. Leakage inductance can have a considerable affect on the behavior of the power amp.

Even little things like the type of tube socket can matter. The amount of stray capacitance caused by the socket can cause a significant change in the frequency response. For example, a socket might have 0.7 pF of stray capacitance. If we take a 12AX7A with a Cgp of 1.7 pF then the total Cgp would be 2.4 pF. If the triode stage's gain is 60, then the Miller capacitance would be about 150 pF. If the socket's stray capacitance is 1 pF then the Miller capacitance increases to about 165 pF. That's a 10% increase which means the frequency response drops by 10%.

It's not a trivial matter and it's not the kind of thing you code in a weekend. It takes YEARS to develop this sort of stuff.
 
I love that this thread exists and that Cliff bothers to participate.

You rarely, if ever, need sin or cos for amp modeling. More common trig functions encountered are tanh and atan. I personally am not a fan of LUTs but use them when necessary. I prefer polynomials when possible.

There are many different techniques for nonlinear modeling (which is the crux of the issue). If the circuit is linear you can simply use linear digital filters.

There are nodal techniques: K-method, DK-method, modified nodal analysis (MNA), etc. SPICE is an example of MNA. Wave Digital Filters (WDFs) are another technique and are a type of scattering method.

Regardless of the technique, and it doesn't really matter which of the techniques you use, the weakest link is the actual nonlinear models themselves. You can see this yourself by using SPICE and trying different models for the nonlinear components. You can get drastically different results. More complex models can give better accuracy but increase the required CPU power.

Stability is another bugbear. All the methods suffer from stability issues to varying degrees.

To understand stability consider a tube triode. The plate current is a function of the grid voltage AND the plate voltage. If the plate voltage decreases the current decreases. But if the current decreases the voltage increases (assuming a resistive load). But if the voltage increases the current increases and the voltage decreases but then the current decreases and the voltage decreases but... The solution is to use a solver like Newton's method but sometimes the solver has difficulty converging. The greater the distortion the more difficult it can be for the solver to converge.

Trying to model a complete amplifier using any of the techniques in real time is nearly impossible. As the complexity grows the matrices grow and the required CPU power grows exponentially.

Eventually, someday, we'll be able to enter a netlist and evaluate that in real time. We're getting close now. There are real time SPICE simulators that can obtain near real-time performance, albeit with simplified nonlinear models. I'd say that is still another decade or so away.

The reason you need an actual amplifier in addition to the schematic is that there are things that the schematic doesn't show. For example, a schematic often won't show the turns ratios of the transformers and certainly not the winding resistance. The B+ voltages are often not shown. Pot tapers aren't always indicated. Etc. Another issue is that schematics are often incorrect.

Schematics also don't show, because they simply cannot, parasitics. Many amplifiers exhibit unpredicted behavior due to parasitic elements. Crosstalk, parasitic capacitance/inductance, etc. can affect the behavior. For example, output transformer leakage inductance wouldn't be indicated on a schematic and often not even on the transformer spec. Leakage inductance can have a considerable affect on the behavior of the power amp.

Even little things like the type of tube socket can matter. The amount of stray capacitance caused by the socket can cause a significant change in the frequency response. For example, a socket might have 0.7 pF of stray capacitance. If we take a 12AX7A with a Cgp of 1.7 pF then the total Cgp would be 2.4 pF. If the triode stage's gain is 60, then the Miller capacitance would be about 150 pF. If the socket's stray capacitance is 1 pF then the Miller capacitance increases to about 165 pF. That's a 10% increase which means the frequency response drops by 10%.

It's not a trivial matter and it's not the kind of thing you code in a weekend. It takes YEARS to develop this sort of stuff.

:love
 
Even little things like the type of tube socket can matter. The amount of stray capacitance caused by the socket can cause a significant change in the frequency response. For example, a socket might have 0.7 pF of stray capacitance. If we take a 12AX7A with a Cgp of 1.7 pF then the total Cgp would be 2.4 pF. If the triode stage's gain is 60, then the Miller capacitance would be about 150 pF. If the socket's stray capacitance is 1 pF then the Miller capacitance increases to about 165 pF. That's a 10% increase which means the frequency response drops by 10%.
How do you deal with this sort of thing in a real amp? I imagine amp manufacturers pick the next tube socket from the box and don't think any further than that.
 
How do you deal with this sort of thing in a real amp? I imagine amp manufacturers pick the next tube socket from the box and don't think any further than that.
The variation is between types of tube sockets. A chassis-mount socket will exhibit different pin-to-pin capacitance than a board-mount socket. Then you need to factor in the wires from the socket to the board and/or the traces on the board. The point is that a schematic doesn't show this information so you can't accurately model using only a schematic.
 
There are nodal techniques: K-method, DK-method, modified nodal analysis (MNA), etc. SPICE is an example of MNA. Wave Digital Filters (WDFs) are another technique and are a type of scattering method.

Cool! If you don't mind sharing: which of these approaches do you use to model your guitar preamps, for example in the Axe-Fx III or the AM4? And which 12AX7 model do you use (e.g. Koren, or this one, etc.)?
 
Back
Top