UGens

You have already seen a few Unit Generators (UGens) in action in sections \ref{sec:first-sine} and \ref{sec:nesting}. What is a UGen? A unit generator is an object that generates sound signals or control signals. There are many classes of unit generators, all of which derive from the class UGen. SinOsc and LFNoise0 are examples of UGens. For more details, look at the Help files called “Unit Generators and Synths,” and “Tour of UGens.”

The default piano-like synth used by Pbinds you wrote up to know is made of a combination of unit generators.1 You will learn how to combine unit generators to create all sorts of electronic instruments with synthetic and processed sounds. The next example builds up from your first sine wave to create an electronic instrument that you can perform live with the mouse.

Mouse control: instant Theremin

Here’s a simple synth that you can perform live—it is a simulation of the Theremin, one of the oldest electronic music instruments:

{SinOsc.ar(freq: MouseX.kr(300, 2500), mul: MouseY.kr(0, 1)}.play;

If you don’t know what a Theremin is, please stop everything right now and search for “Clara Rockmore Theremin” ou YouTube. Then come back here and try to play the Swan song with your SC Theremin.

SinOsc, MouseX, and MouseY are UGens. SinOsc is generating the sine wave tone. The other two are capturing the motion of your cursor on the screen (X for horizontal motion, Y for vertical motion), and using the numbers to feed frequency and amplitude values to the sine wave. Very simple, and a lot of fun.

Saw and Pulse; plot and scope

The theremin above used a sine oscillator. There are other waveforms you could use to make the sound. Run the lines the below—using the convenient plot method—to look at the shape of SinOsc, and compare it to Saw and Pulse. Then rewrite your theremin line replacing SinOsc with Saw, then Pulse. Listen how different they sound.

{ SinOsc.ar }.plot; // sine wave
{ Saw.ar }.plot; // sawtooth wave
{ Pulse.ar }.plot; // square wave

The lines above won’t make sound—they just let you visualize a snapshot of the waveform. Now try .scope instead of .play in your theremin code, and you will watch a representation of the waveform in real time (a “Stethoscope” window will pop up).


  1. Since you used Pbinds to make sound in SuperCollider so far, you may be tempted to think: “I see, so the Pbind is a Unit Generator!” That’s not the case. Pbind is not a Unit Generator—it is just a recipe for making musical events (score). “So the EventStreamPlayer, the thing that results when I call play on a Pbind, THAT must be a UGen!” The answer is still no. The EventStreamPlayer is just the player, like a pianist, and the pianist does not generate sound. But the piano—the instrument—does. So in keeping with our metaphor, the instrument piano is the thing that actually vibrates and generates sound, and that is a more apt analogy for a UGen. When you made music with Pbinds earlier, SC would create an EventStreamPlayer to play your score with a built-in piano synth. You didn’t have to worry about creating the piano or any of that—SuperCollider did all the work under the hood for you. That hidden piano synth is made of a combination of a few Unit Generators.