overtone

pfeodrippe 2024-11-17T21:01:06.734569Z

For the video below, lower your device's volume. In this video I'm experimenting with DSPing from Clojure. What's happening is the following 1. We input a Clojure form 2. tools.analyzer parses it 3. We have a very simple and limited transpiler that uses the :op fields from the analyzer for dispatching 4. The transpiler outputs a string that's raw C code 5. The C code is stored in a temp file and we call clang to generate a dynamic (shared) lib for us 6. We send the dyn lib path to the SC server using a OSC command to a custom SC plugin 7. This plugin dlopens the dyn lib defdsp is a macro that puts all above together, including sending the dyn lib path to the server. The main purpose is to interact quickly in DSPs without having to compile a full plugin. Next step, I will try to store state for some delay-based effects. In the video, you can see that scsynth does not crash when we pass bad data (the (dec i) when i is 0), just the plugin crashes and we can restart it by dlopening again. We have ugly sounds for now as I'm just messing with it atm, with proper state storage, it should be better =D

👏 4
🆒 2
👀 2
Joakim Verona 2024-11-18T08:17:45.811179Z

very impressive!

😎 1
pfeodrippe 2024-11-27T06:09:09.027129Z

Implementing https://github.com/supercollider/example-plugins/blob/main/03-AnalogEcho/AnalogEcho.cpp in "Clojure C", you can hear the effect in the video (first it's disabled, then enabled, disabled and enabled). I'm also adding a screenshot of the clj code vs the generated C code (it's a translation as direct as possible, we follow C semantics as the Clojure ones would be inefficient for our purposes, and if you want something more akin to Clj, check #jank), I wasn't aware that I could infer so much types in C \o/ And, oh gosh, DSP is just nitty-gritty details all the way down... I appreciate SC and overtone even more!! The transpilation is done at https://github.com/pfeodrippe/vybe/blob/develop/src/vybe/c.clj, nothing fancy, we just concatenate strings. The "C" code from the video is at https://github.com/pfeodrippe/vybe/blob/develop/src/vybe/experimental/audio/overtone.clj#L307 (each vc/defn* is compiled as a standalone (so you don't need to compile everything in bulk) and the function can use vars from the JVM, structs (defined using vybe.panama), refer to other functions (invoking it or... yes, using #'myfn to refer to it as a function pointer, a var is just a pointer after all!))

🙌 3
diego.videco 2024-11-20T20:04:56.070419Z

Indeed!

1