Lab Goals and Policies
Labs are an opportunity to work together with a partner on exercises to reinforce concepts from lecture and to prepare for problems on the problem sets. A successful lab experience requires each member to contribute equally. In pair programming, one student is the "driver", who controls the keyboard and mouse. The other is the "navigator", who observes, asks questions, suggest solutions, and thinks about slightly longer-term strategies. The two programmers switch roles about every 20 minutes. If you believe your partner is not participating appropriately in pair programming please first address your concerns to your partner, and try to agree on what should be done to make the pair programming more successful. If that approach is not successful, explain the issues to one of your instructors, who will work with you and your partner to improve the situation.
Simple SynthDefs
Start by creating a new, blank file in the SuperCollider IDE.
For these exercises, the goal is to get practice writing simple and basic
SynthDefs. Below you will create SynthDefs to playback the classic waveforms.
You can assume that each SynthDef here takes two arguments of the following
default parameters: freq = 200
and amp = 0.1
. You can assume that the
out bus for each of these is 0. Ensure that the SynthDef produces a
stereo signal. Finally, play the SynthDef back by creating a Synth. Assign
it to a variable so that you can stop the sound using the .free
method.
-
Write a SynthDef called
\tri
that plays back the UGenLFTri.ar
with the frequencyfreq
and amplitudeamp
. Additionally, write a line of code to create the Synth and then a line to free it. -
Write a SynthDef called
\pulse
that plays back the UGenPulse.ar
with frequencyfreq
, amplitudeamp
, and duty cyclewidth
.width
should be an additional argument to the SynthDef and should have a default value of 0.5. Additionally, write a line of code that creates the Synth but override the default values with a frequency of 100Hz, amplitude of 0.15, and width of 0.75. Write a line of code to free the synth. -
Write a SynthDef aclled
\trioctave
that plays back the sum of two triangle waves produced byLFTri.ar
. One of the triangle waves should be passed the argumentsfreq
andamp
and the other should be an octave higher with half the amplitude. Write a line of code to create the synth, a line to set the frequency to 400Hz while it’s playing, and a line to free it.
More SynthDef practice
In the next part of the lab we are going to make some simple pitched synthetic notes that sound close to pitched percussion instruments like a vibraphone or marimba. The basic theory behind this is we are going to take an impulse (a very narrow spike as if we took a square wave with a duty cycle infinitesimally close to zero) and pass it through a resonator to bring out harmonics in the spike so it sounds pitched.
Step 1: Write a SynthDef called \blip
Write a SynthDef called blip with the following conditions:
- It should take a default argument
out = 0
for the bus of the out signal, an argumentfreq = 440
for the fundamental frequency of the note, and an argumentamp = 0.1
to control the amplitude of the final signal. - The impulse signal is done through the UGen Impulse. The frequency argument controls how often an impulse is created. I set it to 1 so we get a blip every second but you could change it to whatever you like.
- The impulse needs to be passed through a resonator. The UGen
Ringz should do the trick.
The frequency of
Ringz
controls the pitch. You can adjust the decay time if you wish to control how long it takes for the pitch to decay. - You should produce a stereo output.
- After creating the Synth, write a line or two to set the frequency to different values. In the audio example below, I update the frequency as it is playing to one octave above 440Hz (i.e., 880Hz).
Step 2: Write a SynthDef called \reverb
Write a SynthDef called \reverb
that takes in a stereo signal
and passes it through the UGen
FreeVerb. This
UGen will add reverberance to the sound, creating a sense of space
and depth. FreeVerb has a few important parameters that you can adjust.
The parameter mix
controls how much of the reverberance to add relative
to the original signal and the parameter room
gives a sense of how large
of a reverberant space should be created. The higher the value of room
the more was there will be.
- Write a SynthDef that takes arguments for the out bus
out
, the in busin
, the mixmix
with default value 0.33, and the roomroom
with default value 0.5. - Create a
\blip
Synth and route it to an instance of the reverb Synth to add reverberance to the sound. Ensure that the reverb synth is after the blip synth. Otherwise you will not hear anything. You can check you have the right ordering by runnings.plotTree
. - You should also write code to be able to free both synths.
An audio recording below with added reverberance. Halfway through I increase the room size to give it more depth.
Step 3: Creating Multiple Blips
Here we will create multiple blips and pass them through an instance of the reverb.
To add a little bit more unpredictability, we will modify slightly the original
\blip
SynthDef. Create a new SynthDef called \blipRandom
. It should be identical
to the SynthDef \blip
except that we are going to use the UGen
Dust which generates random impulses. Set
the average number of impulses per second to be 0.5.
Next create four running instances of \blipRandom
to create an A minor chord. An
A minor chord consists of the notes A, C, and E. Recall that 440Hz is the A on the
staff in treble clef. A C is three semitones above A for a ratio of 6/5. An E is
seven semitones above A for a ratio of 3/2. You should create a group of random
blips. Below is a diagram of what the plotTree should look like:
Because all of the blips are in one group, it should become very easy to free them by simply freeing the group.
Solutions
Solutions to the lab will be posted after the lab is over.
lab_synthdefs_solns.scd