dsharlet / LiveSPICE

Real time SPICE simulation for audio signals
MIT License
419 stars 61 forks source link

API Support? #203

Open ziadhm001 opened 12 months ago

ziadhm001 commented 12 months ago

Hello, me & my team are currently working on a project that can be summarized into hardware kit powered by a simulator (so no real hardware in the background), so real-time simulation is a must for us, but though we aren't interested into running this with any GUI involved, we just need to pass params by APIs, netlists or acm format whatever it takes and get the output as a response.

So do we you have/planning to have an API support in livespice?

dsharlet commented 12 months ago

This is an interesting question. A few thoughts on the topic:

ziadhm001 commented 12 months ago

Through my case, the layout may remain static (same components every time) but the interconnections between components may vary, a few milliseconds up to maybe 0.5 or 0.6 second would not be a problem, as long as after that time the audio our signal output is gonna be real-time (That may be another thought, the output can be read as an ordinary signal right?).

dsharlet commented 12 months ago

The performance of both simulation and recompiling the circuit really completely depends on the circuit complexity, and the hardware you are running on. Some examples (all 8x oversample rate, on AMD desktop CPU from ~2 years ago):

I'm not sure what you mean by ordinary signal. https://github.com/dsharlet/LiveSPICE/blob/master/Circuit/Simulation/Simulation.cs#L156 is the API that accepts the signal buffers, they're just double[] in C#. It should be possible to set things up so there are no allocations (so no garbage collection needed). I've periodically spot checked this is the case in our applications.

dsharlet commented 12 months ago

Before digging too much into the code, I'd recommend building some circuits you want to simulate with the GUI, and then try running the test application (the benchmark mode) on your target hardware on that circuit. That way, you'll be able to see how long it takes to compile the circuit, and how fast it simulates, on your real hardware. This will also reveal if there are going to be any challenges with dependencies on your target platform.