home/ atoms/ live-coding-synthdef-conventions

A live-coding SynthDef names its frequency arg 'freq', exposes an 'out' arg, and self-frees via doneAction

To be a drop-in instrument for any Pbind under ProxySpace, a SynthDef follows three conventions. First, the carrier of a main frequency should have the argument name freq, so Pbind’s scale/tuning/degree pitch system feeds it automatically; when freq cannot be used directly you redirect with Pkey. Second, each SynthDef should have an argument out in its Out.ar so it can be routed through effects, even when set to 0. Third, envelopes are triggered automatically by patterns on the assumption the trigger is 1, so use Env.perc or Env.linen with a doneAction that frees the synth when the envelope finishes — otherwise every note leaves a persistent node and the server eventually chokes during a long set.

Examples

SynthDef(‘bass’, {|freq=440, amp=0.5, out=0| var env = EnvGen.ar(Env.perc(0.01, 0.3), doneAction:2); Out.ar(out, SinOsc.ar(freq)envamp)}).add;

Assessment

Given three SynthDef designs, identify which accumulates server nodes during a performance and why, then rewrite it to free itself safely.

“The carrier of a main frequency of a SynthDef should have the argument name”