I’m going to post one new track a week, as a way of learning how to use SuperCollider effectively. The tracks themselves will be hosted on Soundcloud and I will write a short post about each one here explaining some of the techniques that went into them.
This track was partially inspired by James
which you should go read right now if you haven’t already. In fact, I’d
recommend printing it out and having it with you at all times. Briefly,
patterns are an extremely powerful method for generating streams of
values in SuperCollider. These values can control anything: pitch,
loudness, duration, sample offset, etc. Using
Pbind, several values
can be combined into an event stream, like so:
1 2 3 4 5
Pbind(\freq, 2640+Pwhite(-10,10,inf), \delta, Pseq([0.75, 0.75, 0.75, 0.5, 0.25], inf), \sustain, 0.0625, \amp, Pgbrown(0.2,0.4, 0.02, inf), \instrument, Prand([\sawpass, \singrain],inf))
In this example, the frequency is 2640 Hz plus a random
number between -10 and 10 Hz. The time between notes (
delta) is the
five-element sequence in brackets. The sustain is always 0.0625s, for a
short, percussive sound. The loudness (
\amp) is controlled by
Pgbrown which generates geometric Brownian motion, in this case with a
low of 0.2, a high of 0.4, and a step size of 0.002. Finally, the Synth
to use is randomly chosen every note, and can be either
There is a large library of pre-existing patterns, but if what you need doesn’t exist, the
Prout class lets you make any routine into a pattern.
In this week’s track, I implemented a very simple Markov chain using a
Prout. Overall, there are four
Pbinds playing simultaneously. The
Pbinds go into a simple mixer that I made, about which more in a
later post. I also made a simple
PlayBuf-based Synth that loops two
seconds of a sample, with the start position given by the x-position of
the mouse (s/o to friends who send
you field recordings from their travels).
The code is structured into two files:
Setup.scd, which boots the
server, creates all the SynthDefs, sets up the signal routing, and draws
the GUI; and
Patterns.scd, which specifies the patterns for each
Pbind. I use Pbindef, which allows you to create a global dictionary
of patterns which can then be modified on the fly. The piece is in just
intonation (duh) with a base frequency of 82.5 Hz.
Code is below.