victor-shepardson / rave-supercollider

GNU General Public License v3.0
53 stars 7 forks source link

Cannot instantiate more than one RAVE ugen in a synth? #1

Closed jreus closed 2 years ago

jreus commented 2 years ago

Heya @victor-shepardson - I'm trying to have a SuperCollider patch with multiple RAVE models running and trying to figure out the best way of proceding. The usage of the RAVE Ugen is unlike anything I've seen in SuperCollider before, it's a bit of a mind trip trying to understand!

I was hoping to have a single synth with both RAVE models running in it. Something like this:

inbus = Bus.audio(s, 1);
model1 = PathName("model1.ts");
model2 = PathName("model2.ts");
model1_control = RAVEControl(s, modelFile: model1.asAbsolutePath);
model2_control = RAVEControl(s, modelFile: model2.asAbsolutePath);
fx = {|m1_dry=1.0, m2_dry=1.0, m1_useprior=0, m1_temp=1.0, m2_useprior=0, m2_temp=1.0, pregain=1.0, gain=1.0|
    var src, fx1, fx2;
    src = In.ar(inbus);
    fx1 = RAVE.ar(model1_control, src, m2_useprior, m2_temp);
    fx2 = RAVE.ar(model2_control, src, m2_useprior, m2_temp);
    [fx1*m1_dry, fx2*m2_dry];
}.play(outbus: 0);
model1_control.load(fx); // This line works
model2_control.load(fx); // This line returns 'FAILURE IN SERVER /u_cmd failed'

But that last line returns a FAILURE IN SERVER /u_cmd failed error. Is there a reason why I shouldn't be putting multiple RAVE Ugens in a single synth? Is there a better approach?

many thank yous!

victor-shepardson commented 2 years ago

hmm, this looks right to me. We have definitely used multiple models before. But anecdotally the FAILURE IN SERVER /u_cmd failed error seems to happen in some synths for no discernable reason. Possibly https://github.com/victor-shepardson/rave-supercollider/blob/d4bd3dd898999f23606f1804ccb3d678e35b994a/plugins/RAVE/RAVE.sc#L6 is not working as expected. You might try putting the two RAVEs each in a different SynthDef.

The reason for the weird RAVEControl stuff is that SC makes it hard to pass an arbitrary string to a UGen at construction. I'm using the "unit generator commands" method to pass the model filename later, which means bookkeeping both an ID of the Synth and of the RAVE UGen within the SynthDef. This is not well documented and I am probably doing it wrong. But I think there should be a more user-friendly alternative, analogous to how Klank.ar lets you pass an array of frequencies -- I will try this soon, hopefully eliminating RAVEControl entirely, and letting you just pass the filename to RAVE.ar in a SynthDef, like you would expect.

victor-shepardson commented 2 years ago

closing, new version is up which no longer uses u_cmd