Curve type as SynthDef argument

Hi, is there a possibility to change the curve type of an Env inside a SynthDef? Or a solution to get a similar result?

I tried the following, which didn’t work:

SynthDef(\envSound,{ |curveType|
	var sig =,
	env = Env.linen(1,0,0.01,0.2,curveType),
	envSig =,doneAction:2);, (sig*envSig)!2);


It does work, but without affecting the current segment:

x = { |curveType = 0, gate = 1|
	var env, envSig;
	env = Env.linen(0.003, 0, 0.003, 0.2, curveType);
	envSig =, * gate);, envSig!2);

x.set(\curveType, 5)

x.set(\curveType, -10)


Alright, however when i try to change the curvature with a symbol such as:

x.set(\curveType, \sine)

it doesn’t seem to work?

The server doesn’t understand symbols. If you want this kind of flexibility consider DemandEnvGen.

If you"re curious you could even do it with Env/EnvGen by using a little trick:
An Env is encoded into an array which you can regard with ‘asArray’.

Env.linen(0.003, 0, 0.003, 0.2, 7).asArray

-> [ 0, 3, -99, -99, 0.2, 0.003, 5, 7, 0.2, 0, 5, 7, 0, 0.003, 5, 7 ]

You see where the curvature and the curve type (= shape, see e.g. DemandEnvGen help for this convention) are stored.

Rewriting the above example

// default shape 5 (exponential curve value)
x = { |curvature = 0, shape = 5, gate = 1|
	var env, envSig;
	env = [
		0, 3, -99, -99, 0.2, 0.003, shape, curvature,
		0.2, 0, 1, 0, 0, 0.003, shape, curvature
	envSig =, * gate);, envSig!2);

// curvature value
x.set(\curvature, 10)

// sine shape
x.set(\shape, 3)

Attack and release times could also be made to args etc. But this is kind of a hack, DemandEnvGen is more comfortable.

-> 3

-> 2



It’s correct that this way you get the numerical encoding of the curve type (shape), but as the example is written, the argument (misleadingly named curveType) only takes over the curvature (‘curve factor’, basically of exponential type). That’s why I recommended DemandEnvGen or passing an array to EnvGen.

That’s true – and, I didn’t say anything to contradict that.

The question was, if you’re using an array in EnvGen, or DemandEnvGen, how do you get from the shape symbol to the number that the server requires? So I answered that question :wink: that’s all.


extremely old thread here, but I was searching for this exact problem. being lazy and not waning to learn about demand ugens or do that array hack, I realized I could just make two copies of the synthdef and choose which one at synth creation time :slight_smile:

maybe this will help the next person

SynthDef(\blah_lin, [args…

SynthDef(\blah_step, [args…

and then at creation time

Synth([\blah_lin, \blah_step].choose, [args…