Hi everyone!
So I finally took the dive and gave Nim a whirl, and I did so using my favorite music synthesizer system, SuperCollider. SC is basically a signal processing system that allows you to arrange a bunch of UGens, processing blocks written in C++, using a scripting language. It's very exciting because it's the most hackable and the most realtime of the music systems I am aware of.
It works really well! The Nim code is still unsafe and very gritty, but as a proof of concept, it does just fine.
Notably, writing realtime SuperCollider UGens requires you to use a subset of C++, sticking to primitive data types and stack memory. Turning off the garbage collector with --gc=none works very well to warn about unsafe memory- and that's very neat because GC memory is exactly what you want to avoid when writing realtime code, so you get a compiler warning.
The details are here:
https://github.com/carlocapocasa/scnim
Thanks for creating Nim!
Carlo
One the things nim needs right now is some exposition. If you have a blog (or maybe as a guest blog entry in this site) you could write your experience and how this project work.
This x 1000. Always happy to accept guest posts on nim-lang.org.
I've tweeted about your project to give it some more exposure because it is really cool.
Also, if you get a chance it would be awesome if you turned this into a Nimble package somehow :)
Holy UGenGraph! Great news
I'm working on a client library, but it is only a few days old! That would be so awesome to have both server and client covered.
:)
Thank you so much!
One the things nim needs right now is some exposition. If you have a blog (or maybe as a guest blog entry in this site) >> you could write your experience and how this project work.
This x 1000. Always happy to accept guest posts on nim-lang.org.
Wow, I had no idea Nim was having a hard time with exposure- ever since I first noticed it a year or two ago it just seemed so inevitable to me. Okay I'll cook something up.
Thanks for the tweet! I couldn't be more proud. :)
The optimization aspects are specially interesting given Nim's population
The Creator of SuperCollider, James McCartney, was especially gung-ho about performance when he wrote SC on his old-timey mac boxes back in the 90s, and it shows- he was not shy about using C macros for just about anything, including loops, to squeeze out a few more CPU instructions, totally mangling the codebase in the process. Seriously, the thing is horror show- but it works! SC is the only system I can get glitch-free audio processing on sub 2ms mic-cpu-speakers latency with.
Pasting some of his monstrous blobs of macro code into my C++ UGen - it was like re-working a crafty scrapbook from the underworld - I remember thinking more than once how I'd just love to have Nim templates- compile time code generation is absolutely perfect for this. When you look at his plugins- sometimes he will have 5 different versions of the same function for different data rate combinations- it just screams code generation. The potential is stunning. And that's just music- there's industrial automation, realtime AI streams... I did some consulting work for that recently, they can't get below 40ms because of the way Python does memory allocation.
I'll wrap all of this into a nice post :)
Holy UGenGraph!
:)
I'm working on a client library, but it is only a few days old! That would be so awesome to have both server and client covered.
Aw, amazing! Please do share your repository if you like- doesn't matter if it's new, maybe we can give each other a hand.
I invented a plain-text music notation called SpaceTracker a while back and I've been meaning to convert into to a C library and hook it up to the client- looks like with Nim and your work I'll finally be able to do that- I'd been putting off learning C or C++ properly because there was just more I could get done by sacrificing performance.