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.
W Written Exercises
-
Graph the following functions by hand. Check your graphs using https://www.desmos.com.
- $2\sin(2\pi t + \pi)$
- $\cos(4\pi t - \pi/2)$
-
Write out the first five harmonics of the harmonic series of the fundamental 200Hz.
-
Consider the function $f(x)$. Write an expression in terms of $f(x)$ that shrinks the graph vertically by a half and shifts it to the left by $\pi/2$.
-
The frequency of concert A (standard orchestral tuning note) is 440Hz. What is the frequency of the note one octave above concert A? Two octaves? Three octaves?
-
What pitch will be perceived from the given harmonics?
- 300Hz, 600Hz, 900Hz, 1200Hz
- 300Hz, 450Hz, 600Hz, 900Hz
C Coding Exercises
As a reminder to get started, you first need to boot the audio server. You
can either go to the menu item “Server” and click “Boot Server”. Or you
can simply write the code s.boot
and execute it. The quickest way to
stop the sound in the SuperCollider IDE is to click COMMAND and “.” (MacOS)
or CTRL + “.” (Windows). Alternatively you can write CmdPeriod.run
and
execute it or select “Stop” from the menu item “Language”.
-
Write a line of code that plays a sine wave of 440Hz from just the left speaker at an amplitude of 0.1. The phase should be 0.
-
Write a line of code that plays a stereo sine wave of 440Hz at an amplitude of 0.1. Come up with three different ways to do this!
-
Write a line of code that plays a sine wave of 300Hz from the left speaker and 600Hz from the right speaker, both at an amplitude of 0.1.
-
Arrays with the
+
operator behave a little differently than Python or other languages. Elements are added pointwise. Similarly the multiplication operator*
with arrays is not concatenation. Instead each element is multiplied. Predict the output of the following lines of code. Check your intuition by running them in SuperCollider.[1, 2] + [3, 4]
[0, 1] + [2, 3] + [4, 5]
[3, 4] + 1
[0, 2] + (1 ! 2)
[0, 1] + 1 ! 2
[1, 2] * 2
[1, 2] * 3 + [4, 1]
[4, 1] + [2, 3] * 3
- Similarly, describe the waveform and properties of this sound:
{SinOsc.ar(440, 0, 0.1) ! 2 * 2}.play
. Is it a single channel (mono) or stereo sound? What is its amplitude, frequency and phase?
-
Consider the code below:
( var phase = 0; { var sig = SinOsc.ar(440, 0, 0.1) + SinOsc.ar(440, phase, 0.1); [sig, sig] }.play; )
- Before running the code, predict what will happen when I run the
code above. What will happen when I add two sine waves in-phase?
In-phase means the sine waves have the same phase. That is the
default setting in the code about because
var phase = 0
. - Now, change
var phase = 0
tovar phase = pi
. What will happen when I run the code? How can you explain what is happening?
- Before running the code, predict what will happen when I run the
code above. What will happen when I add two sine waves in-phase?
In-phase means the sine waves have the same phase. That is the
default setting in the code about because
-
Let us use the frequency scope to check out what partials are present in certain Unit Generators (UGens) in SuperCollider. The goal of this exercise is to match what we hear with visual feedback from the Frequency Scope.
First run the following line of code to bring up the frequency scope:
FreqScope.new
. This will bring up a window. The vertical axis depicts the amplitude of the sound in units called decibels. We won’t concern ourselves now with exactly what decibels are and how they relate to amplitude. For now, we can follow our basic instincts. Any bars plotted above other bars have higher amplitude and are therefore perceived as louder. The horizontal axis depicts frequency logarithmically.Let’s plot some sound. The Frequency Scope is dynamic which means it will continually plot the sound as it plays. When you play each sound ask yourselves the following questions:
- Does this sound have pitch? If so, does the Frequency Scope show a peak for that pitch? If not, what can we say about the peaks? Are there any? If so, describe them.
- If the sound has pitch, are there additional harmonics from the harmonic series? Compare two sounds that have pitch. If they sound different even though they have the same fundamental, what is changing about their harmonics?
- Does the UGen sound brighter or duller compared to other UGens? How are the harmonics shown in the Frequency Scope different for brighter vs. duller sounds?
Run the following lines one at a time. You’ll want to play each one many times to get a sense of how each compare.
{SinOsc.ar(440, mul: 0.1) ! 2}.play; {WhiteNoise.ar(0.1) ! 2}.play; {Pulse.ar(440, mul: 0.1) ! 2}.play; {BrownNoise.ar(0.1) ! 2}.play; {LFTri.ar(440, mul: 0.1) ! 2}.play; {Saw.ar(440, mul: 0.1) ! 2}.play;
When you are done writing comparisons, students should then quiz each other to see if they can identify each sound by ear. Good computer musicians are able to hear sounds in music and reason about their properties based on pitch vs. noise and brightness vs. dullness.
Solutions
Solutions to the lab will be posted after the lab is over.
lab_sound_basics_solns.pdflab_sound_basics_solns.scd