Halite - an analog circuit simulator in ~1k lines of code

DSP, Plug-in and Host development discussion.
User avatar
Audiority
KVRian
776 posts since 15 Nov, 2005 from Italy

Post Mon Feb 12, 2018 3:37 am

Do you have a struct for the input signal to share? I'm used to place it in the U vector, but I'm a bit clueless how to place it in your code.

Thanks!
Audiority
Need a Kontakt scripter? Contact me.

mystran
KVRAF
5109 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Mon Feb 12, 2018 3:57 am

Audiority wrote:Do you have a struct for the input signal to share? I'm used to place it in the U vector, but I'm a bit clueless how to place it in your code.
If you're talking about Halite, just look at what the function generator does: it puts the signal into a variable that it stamps as a "dynamic load" to the mna.b vector, so it gets replaced with the actual value every time it solves the system.

While the function generator uses a callback function to generate the input signal, you could just modify that part of the code to stream from a buffer or something instead.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

User avatar
Audiority
KVRian
776 posts since 15 Nov, 2005 from Italy

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Mon Feb 12, 2018 5:06 am

Thanks mystran. I totally missed out the function generator!
Audiority
Need a Kontakt scripter? Contact me.

Miles1981
KVRian
1372 posts since 26 Apr, 2004 from UK

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Fri Mar 23, 2018 12:21 pm

I was wondering if an optimized version could be better done in Python.
Explaining myself. Let's say the JIT is LLVM. It may actually be easier to target clang AST instead of LLVM IR. From the AST, the matrix can be statically defined (and using Eigen, for instance), the derivatives could also be done symbolically and perhaps even some matrix inverses directly as well.

mystran
KVRAF
5109 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Fri Mar 23, 2018 7:25 pm

Miles1981 wrote:I was wondering if an optimized version could be better done in Python.
Explaining myself. Let's say the JIT is LLVM. It may actually be easier to target clang AST instead of LLVM IR. From the AST, the matrix can be statically defined (and using Eigen, for instance), the derivatives could also be done symbolically and perhaps even some matrix inverses directly as well.
I honestly don't really understand any of what you are trying to say here... I mean I obviously understand what the words mean, but the underlying logic completely evades me.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

Miles1981
KVRian
1372 posts since 26 Apr, 2004 from UK

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Fri Mar 23, 2018 11:41 pm

I'm just thinking at what would be the easiest to target. LLVM IR or Clang AST, and the fact that in Python there are potentially more tools for automatic differentiation that in C++ (although there is DCO). So it may be easier to generate optimized code in Python than in C++.

mystran
KVRAF
5109 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Sat Mar 24, 2018 12:22 am

Miles1981 wrote:I'm just thinking at what would be the easiest to target. LLVM IR or Clang AST, and the fact that in Python there are potentially more tools for automatic differentiation that in C++ (although there is DCO). So it may be easier to generate optimized code in Python than in C++.
Well, you only need automatic differentiation if you want to allow components with arbitrary equations that the user can type in (and automatically generate Newton evaluation for these). This runs into a whole new can of worms though. For example, if you try to implement something as simple as a diode in Spice (eg. I've tried in LtSpice) using a voltage controlled behavioural current source, you'll find that you run into all kinds of convergence issues that the built in diode doesn't have.

As well as LLVM IR goes, it's just SSA and if you can't generate SSA you probably can't generate an AST either... so personally I don't see a point why you'd want to draw clang into the mix (although I have to say I'm not convinced I want to use LLVM either; let's not discuss that though).
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

rola
KVRist
63 posts since 22 May, 2002

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Fri Oct 26, 2018 9:56 am

The link seems to be dead. Is this still available somewhere?

mystran
KVRAF
5109 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Fri Oct 26, 2018 11:32 pm

I don't think humanity deserves my code anymore.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

stratum
KVRAF
2183 posts since 29 May, 2012

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Fri Oct 26, 2018 11:45 pm

mystran wrote:
Fri Oct 26, 2018 11:32 pm
I don't think humanity deserves my code anymore.
Is it worse than marshes and bogs of yesterdays Finland, above which todays Finland resides? (or so J.V.Snellman would say?)
~stratum~

Miles1981
KVRian
1372 posts since 26 Apr, 2004 from UK

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Tue Oct 30, 2018 3:45 am

I had a git copy, but if mystran wants it gone, I will also remove (let me know!).

Just an FYI, ATK-modelling-lite is a similar project (but not as optimized as mystran's Halite).

mystran
KVRAF
5109 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Tue Oct 30, 2018 6:23 am

Miles1981 wrote:
Tue Oct 30, 2018 3:45 am
I had a git copy, but if mystran wants it gone, I will also remove (let me know!).
I frankly don't give a shit either way.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

Miles1981
KVRian
1372 posts since 26 Apr, 2004 from UK

Re: Halite - an analog circuit simulator in ~1k lines of code

Post Tue Oct 30, 2018 10:10 am

Haha, fair enough ;)

Return to “DSP and Plug-in Development”