Creating new segments of an envelope on the fly

Hi, following this previous rookie post and the nice answer of Jordan :

I would really like to know what are all the other options to first play a synth an then creating new segments of its envelope on the fly. Thoses segments could control any kind of parameters of the synth, changing duration, values and curves of the envelope - always working on this first synth instance, without adding new ones.

Strangely enough I didn’t find any example of code for this on the forum and I think it’s a cool and intuitive way to improvise drones, glissandos, clusters and so on…

I discovered this method by Daniel on a old forum, which allow to pass the synth envelope array as Pbind arguments, it works well but in this case, I don’t know how I can update the Pbind without starting a new synth event, by continuing the course of the original synth and changing the values on the fly.
https://listarc.cal.bham.ac.uk/lists/sc-users-2013/msg36174.html

I have the feeling there is a lot of options to do that and that it could help me a lot to discover them to learn SC…

Thanks a lot.

Here’s a quick example:

(
x = {  |freq = 400, freqLag = 0, curvature = 0, warp = 5|	
	SinOsc.ar(VarLag.kr(freq, freqLag, curvature, warp), mul: 0.1).dup(2)	
}.play
)	


x.set(\freq, 500)

x.set(\freq, 700, \freqLag, 1)

x.set(\freq, 400, \freqLag, 1)

x.set(\freq, 700, \freqLag, 1, \warp, 0) // step

x.set(\freq, 400, \freqLag, 1, \warp, 5, \curvature, -10) // decelerating


x.set(\freq, 700, \freqLag, 1, \warp, 0) // step

x.set(\freq, 400, \freqLag, 1, \warp, 5, \curvature, 10) // accelerating


x.release(3)


You can do that for all params of your synths. Of course, then, you get a large number of controls. A more lazy approach is the use of floats for SynthDef’s ‘rates’ arguments:

https://doc.sccode.org/Classes/SynthDef.html#*new

Hope that helps, best

Daniel

PS: in the example above, frequencies are taken as control input. It would be more natural to choose midi and convert in the synth: because of logarithmic perception a linear lag could then really be perceived as linear.

(
y = {  |midi = 60, midiLag = 0, curvature = 0, warp = 5|	
	SinOsc.ar(VarLag.kr(midi, midiLag, curvature, warp).midicps, mul: 0.1).dup(2)	
}.play
)	


y.set(\midi, 64)

y.set(\midi, 60, \midiLag, 1) // linear by default (like a linear glissando on an imaginary keyboard without steps)

y.set(\midi, 72, \midiLag, 1)

y.set(\midi, 60, \midiLag, 1, \warp, 5, \curvature, -3) // decelerating


y.set(\midi, 72, \midiLag, 1) // still decelerating because warp and curvature have been set

y.set(\midi, 60, \midiLag, 1, \warp, 5, \curvature, 3) // accelerating

y.set(\midi, 72, \midiLag, 1) // still accelerating because warp and curvature have been set

y.release(3)