Well, I ended up trying to use Chat GPT to translate SuperCollider UGen source code into Max rnboscript for use in RNBO (as a way to accomplish the titled goal of this thread).
But as one might expect, this didn’t work particularly well, even after multiple attempts at refining Chat GPT’s output. I suspect b/c the version of Chat GPT I was using simply didn’t grasp the nuance of SuperCollider’s architecture vs that of the Max RNBO environment.
Maybe I just need more prompt engineering practice, but I ended up doing it the hard way and managed to figure out a methodology to translate SuperCollider UGen source code into a RNBO abstractions, which you can find on my Github here:
As an initial proof of concept I translated the PitchShift UGen source code, but plan to continue porting some of my other favorite UGens and adding them to this repo over time.
So I think this represents a viable way to translate SC UGen source code into Max RNBO (rnboscript), which can then be exported to the various platforms RNBO supports (Javascript for Web, VST3, Raspberry Pi, C++), allowing one way to export at least SC UGen code to other platforms.
Translating from the original C++ source to Max RNBO’s “rnboscript” language was a pretty straight forward process once I wrapped my head around w/ what was going on in the SC Server UGen code.
Basically all the unit pointer operations get abstracted away by using the RNBO Codebox~ “@state” variable decorator.
And b/c the code inside the RNBO Codebox~ object is run on a per sample basis, the “inNumSamples” argument for blocksize-based DSP gets abstracted away too, allowing the core DSP code to not have to sit w/in the while() and for() loops of the original SC source.
e.g this SC UGen C++ design pattern:
void PitchShift_next(PitchShift* unit, int inNumSamples) {
...
remain = inNumSamples;
while (remain) {
nsmps = sc_min(remain, counter);
remain -= nsmps;
counter -= nsmps;
LOOP(nsmps,
iwrphase = (iwrphase + 1) & mask;
//<UGen DSP code>
dlybuf[iwrphase] = ZXP(in);
ZXP(out) = value *= 0.5;);
);
}
}
…gets abstracted into this in RNBO Codebox~ code:
function PitchShift_next(i0) {
var input : number = i0; //store input sample data
var output : number = 0.0;
var value : number = 0.0;
...
counter -= 1;
iwrphase = (iwrphase + 1) & mask;
//<UGen DSP code>
dlybuf[iwrphase] = input;
output = value *= 0.5;);
return output;
}
(There were also various SC specific functions I had to reimplement using my own functions and RNBO native operators, so I’m glossing over some nitty gritty details. But RNBO operator support is pretty good, so this was pretty straight forward too.)
Overall, I’m looking forward to porting more SC UGen source code to Max RNBO in the future so my favorite SC DSP can live on in the various platforms RNBO targets.