LiveSPICE, a real time SPICE simulator for live audio

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

mystran wrote: Wed May 19, 2021 6:25 am Instead of partitioning the solution into just linear and non-linear parts, you can go further and partition the solution into "static", "dynamic" and "non-linear" where you factor out the static parts in precomputation, then compile code that factors the dynamic parts (eg. pots) once per time-step and only iterates the non-linear part (and similarly for the back-substitution part, where you only need to generate code to solve the nodes you actually need for things like capacitors and output).

I don't know what the LiveSPICE solve looks like, but if you use something like LU this is literally just a matter of ordering the rows and columns and then reordering/staging the factorization.
(It's been a while since I've worked on this so some of this is foggy)

The solver is basically doing LU decomposition. It rewrites the system into an upper triangular matrix, except for the bottom right corner which has the non-linear equations and variables.

The problem I ran into is that I want to do that LU decomposition *symbolically*, so the solution (the back substitution) for the linear part of the system can be compiled code unique to that simulation, and the equations to generate the Jacobian for the non-linear solver are also compiled for that simulation. If you leave pots as variables, that symbolic upper triangular solve step is really messy, the expressions become impractically huge. They're both slow to solve for, and slow to run at runtime.

At runtime, the solver loop for each timestep basically looks like:

Iterate until convergence on all N variables (20-100 for typical circuits):
- Run J, the circuit-specific compiled code that generates the Jacobian for M non-linear variables (4-8 for typical circuits)
- Run dynamic solver on the Jacobian to solve for the next iteration of M non-linear variables
- Run L, the circuit-specific compiled back substitution code that generates the solutions for the N - M linear variables. This depends on the result of the dynamic solver for the last M variables

Skimming the thread to remind myself, I see we talked about this before :) I guess I'd have to see a more detailed description of what you are proposing to understand it. I've been stumped on this dynamic pot problem for a while now :)

Post

dsharlet wrote: Wed May 19, 2021 6:50 am The problem I ran into is that I want to do that LU decomposition *symbolically*, so the solution (the back substitution) for the linear part of the system can be compiled code unique to that simulation, and the equations to generate the Jacobian for the non-linear solver are also compiled for that simulation. If you leave pots as variables, that symbolic upper triangular solve step is really messy, the expressions become impractically huge. They're both slow to solve for, and slow to run at runtime.
The trick is that when you want to do one step of the LU factorization, you only need the actual values for the pivot row and column and addition can be done in any order, so you can always keep stamping more stuff into the remaining unfactored bottom-right block even if the earlier rows have already been factored.

If you construct your pot-stamps in such a way (eg. using "ideal transformers" similar to how you can reduce the dimensions you need to solve for the non-linear block) that the dynamic values get their own rows, you can put those rows between all the static stuff, but before the non-linear block. You can then factor out the static stuff first, then generate code that adds the dynamic values into the "prefactored" bottom-right block, then factor out the rows for the pots to get a similar "prefactored" block to use for iteration, which can then just stamp the Newton derivatives and complete the LU factorization on per-iteration basis.

In other words.. you can interleave the factorization and the stamping and then you can move first part of the factorization before code-generation and the second part of factorization out of the iteration and you don't actually even need to do any of this symbolically (it's perfectly fine to work with the numerical values), except as far as you just need to keep track of which dynamic variables still need to be added at runtime (either on per-step or per-iteration basis).

Post

SORRY I DON'T KNOW HOW TO USE THIS QUOTE FEATURE
My 1st message was:
Plugins!!Plugins!!
How ya doin'! I'm wondering if LiveSpice is totally royalty-free to use for my productions, and are there any restrictions for using it? Can I take the models I build and use them in another plug-ins creating software like JUCE or Blue Cat's Plug'n Script?

dsharlet wrote back (part of the message is not included):
If you are asking about the source code of LiveSPICE, it uses the MIT license, which is pretty permissive.

If you are asking about the simulations it generates, I would say that depends on the source of the circuits you are simulating. I certainly wouldn't claim ownership of the generated simulations, so if you developed the circuit yourself, it's all yours. If you copied a circuit from somewhere, I would ask the owner of that circuit.

End Quote

My new reply is:
So, to make my plug-ins or software, I guess I need to know if I will be needing to include the source code of LiveSPICE and/or the MIT License inside of my plug-ins or software, JUST BECAUSE I'M USING LiveSPICE TO CREATE THE PLUG-INS OR SOFTWARE. Sorry, I'm a total novice developer. To put it differently, If I make a VST 3 plug-in and include a Live SPICE Simulation, do I then have to include the Source Code of LiveSPICE or the MIT License in some form somewhere (either within the plug-in code or in a Document outside of the plug-in code)?

About the circuits---If I develop a circuit within LiveSPICE, is LiveSPICE a source of FREE circuits because it has "included parts" that I access using the LiveSPICE interface? To put it differently, Are the "included parts" of LiveSPICE totally FREE to use, as "source"? How do I develop my own circuits from scratch? Can I do it somehow inside of LiveSPICE or even outside of LiveSPICE?

I also have no idea on how I'm to get the simulations into a different set of instructions or code because, I say again, I am a total novice developer with no coding experience.

Post

Plugins!!Plugins!! wrote: Thu May 20, 2021 4:00 am SORRY I DON'T KNOW HOW TO USE THIS QUOTE FEATURE
If you click the "quote" icon in a post (ie. the quotation marks on top-right), it'll actually show you by giving you the whole post in the editor inside a quotation block which can then be editted, but the above quote in BBCode looks like this (and no, you don't need to worry about the parameters; they are optional):

Code: Select all

[quote=Plugins!!Plugins!! post_id=8114643 time=1621483209 user_id=408701]
SORRY I DON'T KNOW HOW TO USE THIS QUOTE FEATURE
[/quote]

Post

Plugins!!Plugins!! wrote: Thu May 20, 2021 4:00 amTo put it differently, If I make a VST 3 plug-in and include a Live SPICE Simulation, do I then have to include the Source Code of LiveSPICE or the MIT License in some form somewhere (either within the plug-in code or in a Document outside of the plug-in code)?
I am not a lawyer and this is not legal advice, but MIT license is sort and simple and the even shorter version is that essentially all you need to do is to include a copy of the original license (but not source code or anything like that) somewhere with the software and not sue the original author for any damages.

The usual way people do this with permissive licenses (MIT, "BSD", Apache, CC-BY, etc) is to have either an about-box or documentation that contains statements similar to the following:

Code: Select all

This software includes LiveSPICE with following license:

<copy-paste-LiveSPICE-license-here>

Post Reply

Return to “DSP and Plugin Development”