You forgot to specify the out bus :
Out.ar(SinOsc.ar(mul: EnvGen.kr(env_shape)))
should be
Out.ar(0, SinOsc.ar(mul: EnvGen.kr(env_shape)))
But this doesn’t fix it. I tried to ‘flop’ the array because apparently, SuperCollider doesn’t really understand what to do with it :
SynthDef(\x, {
var env_shape = Select.kr(
\envshape.kr(1),
[
Env([0, 1], [\duration.kr], \lin),
Env([0, 1, 0], [0.01, \duration.kr - 0.01], \lin),
Env([1, 0], [\duration.kr], \lin),
].flop
);
Out.ar(SinOsc.ar(mul: EnvGen.kr(env_shape)))
}).add
)
Apparently that ‘works’, but Select
is complaining that he doesn’t like Env
s as inputs.
Instead of declaring an array of Env
, I tried to wrap them directly inside EnvGen
s.
Env
format is not ‘audio format data’. EnvGen
converts an Env
to ‘audio data format’ so you can make it interact with other synth, for example by multiplying it, controlling a parameter, or, in this case, use it as a parameter for Select
. If you have an Env
, most of the time, the first thing you’d like to do is to convert it with EnvGen
before using it for anything.
(
SynthDef(\x, {
var env_shape = Select.kr(
\envshape.kr(1),
[
EnvGen.kr(Env([0, 1], [\duration.kr], \lin)),
EnvGen.kr(Env([0, 1, 0], [0.01, \duration.kr - 0.01], \lin)),
EnvGen.kr(Env([1, 0], [\duration.kr], \lin)),
]
);
Out.ar(0, SinOsc.ar(mul: env_shape))
}).add
)
No more error messages, so I suppose it works ? Didn’t test. No need to ‘flop’ any more. I have an insight on why, but couldn’t explain it correctly, so this will stay a mystery for now.