Hi, gang. I was working on connecting Swift to scsynth
with the idea of making a Mac-native MIDI application, and I needed an easy way to make and try out synthdefs. I then realized that if I did this in C, lots of other languages (Swift, Ruby, Python, etc.) could import it, and it might be useful to others besides me. It seemed like the easiest solution was to embed Lua, and I now have a proof-of-concept toy version working, in that this Lua code:
controls = { Control("out", 0), Control("freq", 440), Control("amp", 0.125) }
osc1 = Mul(SinOsc(controls[2]), controls[3])
return Out(controls[1], osc1, osc1)
gets parsed to a byte-for-byte identical SynthDef data blob as this sclang
code:
{ |out=0, freq=440, amp=0.125|
var osc = SinOsc.ar(freq) * amp;
Out.ar(out, [osc, osc]);
}
I’ve put the library up on GitHub at GitHub - doubtfulpalace/SuperColliderSynthDefLib, and I’d love to get feedback, specifically:
–Is there anything like this out there already? I know about Lua2SC, but this is quite different.
–Is this something that people would find useful?
–Feedback on the code or the DSL would be very welcome.