Learning SuperCollider patterns: legato, sustain and using pairs

Yesterday I had problems understanding why does a SynthDef and it’s Synth instance complain when it’s envelope duration is shorter than duration \dur. The following code will produce FAILURE IN SERVER /n_set Node 1067 not found complaints in the post window.

The sound will be generated fine, but the problem is that the doneAction and sustain value in Env.linen result in the Synth instance being freed before Pbind does it. So when Pbind does tries to free it, it’s already gone, it doesn’t exist anymore.

I asked nice SC people on SC FB group and the answer led me to understand that there’s a good use of\sustain parameter in Pbind, which deals with exactly that. So to properly control sustain time, an example shows how it can be done:

It seems like the most important part is that the SynthDef has a sustain argument. Pbind will calculate sustain from \dur so that it doesn’t even have to be defined in the Pbind.

There’s a nice thing used above, which I was looking for a while – how to defined note and it’s duration in pairs instead of on separate lines for each parameter: [\degree, \dur] and what follows is a list of pairs.