home/ atoms/ sc-synthdef-synth-pattern

A SynthDef is a reusable recipe for sound; a Synth is one execution of that recipe

In SuperCollider the preferred way to make sound is to define a SynthDef (a named UGen graph) and then instantiate it with Synth.new. This separates the recipe from its execution, enabling multiple simultaneous instances with different argument values, and arguments can be set while the Synth is running. Contrast with Function.play, which is a shortcut that automatically creates and immediately discards a SynthDef — convenient for testing but less flexible. A SynthDef requires at least one output UGen (Out.ar) specifying a bus index; without it, the signal is computed but never heard.

Examples

Define: SynthDef.new(\sine, { arg freq=440; Out.ar(0, SinOsc.ar(freq)) }).add; Instantiate: x = Synth.new(\sine, [\freq, 660]); Modify live: x.set(\freq, 880); Free: x.free;

Assessment

Why does x = {SinOsc.ar}.play; x.free; work, while x = {SinOsc.ar}; y = x.play; x.free; does not free the audio? Rewrite the second example so that free works correctly.

“A SynthDef is essentially a recipe for a particular sound, and a Synth is the execution of that recipe.”
corpus · supercollider-tutorials-full-transcripts-and-code-eli-fields · chunk 6