Using envelopes to create score for NRT synthesis

Hello!

I have generated a large amount of envelopes that I want to use to control Synthdefs. Due to the large number of the envelopes (and the number of Synths needed running at the same time) I can’t do this in real-time so NRT is the only way around this.

The envelopes need to control Synthdefs that are created at very specific timing and when the envelopes finish the Synthdef’s should be killed as well. Ideally, there will be different Synthdefs used, but for now, let’s say I want to use only one Synthdef but many instances of it at the same time. In each Synthdef created I would like to control the frequency and the amp with 2 different envelopes.

Since I am a bit confused with NRT could anyone suggest a way that I could create a score with envelopes whose values are already created and stored in arrays? Or how to address this in any way? How can you write a score with a set of envelopes that trigger Synths in time (some triggered at the same time while others in different timing) and then release those Synths when the envelope finishes…

Any help would be greatly appreciated!
thank you!

In an extremely simplified example (that does not work obviously) would like to do something like this

(

var f, o;

g = [

[0.1, [{Out.ar(0,  Saw.ar( EnvGen.ar(Env([0, 1000, 90, 40], [0.1, 0.5, 1],[-5, 0, -5]),  doneAction:2)))}],[{Out.ar(0,  Saw.ar( EnvGen.ar(Env([0, 2000, 190, 420], [0.1, 0.5, 1],[-5, 0, -5]),  doneAction:2)))}]],	

[0.2, [{Out.ar(0,  Saw.ar( EnvGen.ar(Env([0, 1000, 90, 40], [0.1, 0.5, 1],[-5, 0, -5]),  doneAction:2)))}]],

[0.3, [{Out.ar(0,  Saw.ar( EnvGen.ar(Env([0, 1000, 90, 40], [0.1, 0.5, 1],[-5, 0, -5]),  doneAction:2)))}]],

[1, [\c_set, 0, 0]]

];

o = ServerOptions.new.numOutputBusChannels = 2; //

Score.recordNRT(g, “/Users/XXX/Music/SuperCollider Recordings/help-oscFile2.osc”, “/Users/XXX/Music/SuperCollider Recordings/helpNRT2.aiff”, options: o); // synthesize

)