Product SiteDocumentation Site

11.3.10. SynthDef and Synth

The preceding sections of this "Basic Programming" guide have only created sound with Function's. The truth is that Function's are very useful for creating sound, but they represent a simplification of the actual commands and Functions that must be run by the interpreter in order to create sound.
// When you write this...
(
   { SinOsc.ar( freq:440, mul:0.2 ); }.play;
)

// The interpreter actually does this...
(
   SynthDef.new( "temp__963", { Out.ar( 0, SinOsc.ar( freq:440, mul:0.2 ) ); } ).play;
)
Yikes! Don't despair - it's easy to understand - it just looks scary!

11.3.10.1. "Out" UGen

The "Out" UGen is one of the bits of magic automatically taken care of by the interpreter. It routes an audio signal from another UGen into a specific output (actually, into a specific bus - see Section 11.3.11, “Busses”).
The following examples have the same effect:
{ SinOsc.ar( freq:500, mul:0.2 ); }.play;
and
{ Out.ar( 0, SinOsc.ar( freq:500, mul:0.2 ) ); }.play;
The first argument to "Out.ar" is the bus number for where you want to place the second argument, which is either a UGen or a multi-channel Array of UGen's. If the second argument is an Array, then the first element is sent to the first argument's bus number, the second argument is sent to one bus number higher, the third to two bus numbers higher, and so on. This issues is explained fully in Section 11.3.11, “Busses”, but here is what you need to know for now, working with stereo (two-channel) audio:
  • If the second argument is a two-element Array, use bus number 0.
  • If the second argument is a single UGen, and you want it to be heard through the left channel, use bus number 0.
  • If the second argument is a single UGen, and you want it to be heard through the right channel, use bus number 1.
If you're still struggling with exactly what the "Out" UGen does, think of it like this: when you create an audio-rate UGen, it starts creating an audio signal; the "Out" UGen effectively connects the audio-rate UGen into your audio interface's output port, so it can be heard through the speakers. In Section 11.3.11, “Busses”, it becomes clear that there are, in fact, other useful places to connect an audio-rate UGen (through an effect processor, for example), and the "Out" UGen can help you do that.