Hello fellow coders!
Inspired by the recent developments of DynGen and some past work I did back at Uni with JuliaCollider, I decided to work on this new project over the Christmas break: embedding the Cmajor language and JIT engine in SuperCollider as a plugin.
For those who don’t know, Cmajor is a fairly recent audio DSL that has an LLVM-based JIT compiler which is mostly used to develop VST / CLAP plugins. It’s very optimized and performant, and it seems like the perfect fit for on-the-fly development of UGen code.
The result is the new CmajorCollider plugin, that you can find here:
The concept follows what I had already done in JuliaCollider and DynGen is doing as well: you define a CmajorDef with the code you want to compile and send it to the server. Then, you can use the Cmajor UGen to index the specific CmajorDef. Recompiling the same CmajorDef will hot-replace the existing Cmajor instances pointing to it.
CmajorDef supports both in-place code but also compiling specific .cmajor or .cmajorpatch files.
There is also some special binding code for SC Buffer reading and writing, and some limitations to the types of input you can use. You can find more info in the CmajorDef and Cmajor help files ![]()
This is a very simple example of the syntax of the plugin. More interesting examples can be found in the help files.
(
s.waitForBoot({
var code = "
processor Sine {
input value float freq [[ init: 440 ]];
output stream float out;
void main()
{
float64 phase = 0;
loop {
phase = (phase + freq * processor.period) % 1.0;
out <- float(sin(phase * twoPi));
advance();
}
}
}";
CmajorDef(\sine, code).send;
s.sync;
{ Cmajor.ar(\sine, MouseX.kr(200.0, 1000.0, 1)) }.play;
});
)
There are pre-built binaries in the Releases page but please let me know if it works for you, specifically on macOS and Linux as I could only properly test on Windows ![]()