Catching A Wave
Assign: Thursday, September 16
Due: Friday, September 24
Assignment Policies
All assignments are partner assignments. Please make sure to review the policies and guidelines about discussing assignments with those other than your partner. Assignments are usually, but not always, a combination of paper and coded exercises. Please make two submissions (one for paper exercises and one for coded exercises) to Gradescope. Paper exercises are marked with HW to indicate a handwritten question and C to indicate a coded question. Paper submissions can receive an extra 2% bonus if they are typed. Please visit the tools section of the website for more information.
Written Exercises HW
-
Write out the first 5 partials of the harmonic series with the following fundamentals:
- 300Hz
- 600Hz
-
Consider the sum of two sine waves: $\sin(x) + \sin(x + a)$ for some constant $a$.
-
For what values of $a$ will the sum double the amplitude of $\sin(x)$? Give all possible solutions.
-
For what values of $a$ will the sum equate to zero? Give all possible solutions.
-
-
Consider the sine wave $h(t)$ where $h(t) = A\sin(-\omega t + \phi)$. Note that $\omega$ is termed “angular frequency” and is equivalent to $2\pi f$. Depending upon the audio textbook, sinusoids may be written in terms of angular frequency so you should be comfortable with both notations. Thus, we can say $h(t) = A\sin(-\omega t + \phi) = A\sin(-2\pi ft + \phi)$. Let’s investigate what it means then to have a negative frequency or a negative angular frequency.
- Using your trigonometric identites, find an equivalent expression for $h(t)$ that has a positive frequency and positive amplitude. Hint: You might find the following identity useful: $-\sin(x) = \sin(x + \pi)$
- Based on your answer to part(a), what can we say then about the difference between a positive and negative frequency? Would we perceive any aural difference between $A\sin(-\omega t + \phi)$ and $A\sin(\omega t + \phi)$? Explain in a few short sentences.
-
Equal temperament is a tuning system that divides the octave evenly into twelve semitones. Remember that the interval between two notes is not determined by the difference in frequency but by the ratio between those two notes. Given some note $f_{init}$ and some higher note $f$ where both are frequencies in Hz, then $f$ is an octave higher than $f_{init}$ when $f/f_{init}$ = 2.
-
Suppose $f_{init}$ = 400Hz, what is the frequency of $f$ when $f$ is two octaves above $f_{init}$?
-
The ratio between two frequencies for an octave is 2. Determine the ratio between any two frequencies that are a semitone apart in equal temperament. Show your work and explain how you arrived at your solution. Remember that 12 semitones consitute an octave in equal temperament.
-
Derive an equation that expresses the frequency $f$ based on an initial frequency $f_{init}$ and a number of semitones $s$ where $s$ is the number of semitones from $f_{init}$ to $f$.
-
-
REQUIRES WAVES: Write out the first four partials of the following waveforms as a sum. Do not use summation notation here. Assume that the fundamental frequency is $f$ with an amplitude of $A$. For example, the first four partials of a sawtooth wave would be written as $A\sin(2\pi ft) + \frac{A}{2}\sin(2\pi (2f)t) + \frac{A}{3}\sin(2\pi (3f)t) + \frac{A}{4}\sin(2\pi (4f)t)$.
-
A square wave
-
A triangle wave
-
A sawtooth wave shifted to the right by $0.5$ seconds. Be careful here. The entire waveform should be shifted by $0.5$ seconds.
-
-
REQUIRES WAVES: Below is a series of audio files for a single note that is either a sawtooth wave, sine wave, square wave, or triangle wave. Using your ear, identify the type of wave. Think about the harmonic content of each wave and use that as your guiding principle when considering the wave type. The following waves were generated using the UGens
SinOsc.ar
,LFTri.ar
,Saw.ar
, andPulse.ar
.Example 1
Example 2
Example 3
Example 4
Example 5
Example 6
The purpose of this exercise is attune you to the differences in timbres between different waveforms. Good electronic musicians can hear different aspects of a song and reason about how those aspects were created. Because these four waveforms are so ubiquitous in music, it is good to really familiarize yourself with the sonic characteristics of each.
Coding Exercises C
The starter code for the coding exercises can be found here
-
Write a short one line piece of code that plays a sine wave of 400Hz from the left speaker and a sine wave of 800Hz from the right speaker. Set the amplitude for each wave to be 0.2. Make the phase of the sine wave from the left speaker 0 and the phase of the sine wave from the right speaker $\pi$. Test on your own speakers.
-
In handwritten exercise 4, you derived a mathematical equation for expressing the frequency of any partial $s$ semitones above some other frequency (referred to as $f_{init}$). Write a function in SuperCollider that expresses this equation. Your function should accept two arguments:
f_init
andsemitones
. Your function should return the frequency that is the number ofsemitones
abovef_init
. It is strongly recommended that you do the handwritten exercise first. -
REQUIRES WAVES: Write a function called
~thirdPartials
that produces a waveform with the following properties.- Only has every third harmonic (i.e., harmonic numbers 1, 4, 7, … etc.)
- The amplitude of each harmonic should be (1/harmonic_number)^3 times the fundamental’s amplitude.
- Phase of all partials is zero.
Some more details about
~thirdPartials
:~thirdPartials
should accept two parameters:fundFreq
andfundAmp
. Set them to the default values of 300, and 0.2, respectively.fundFreq
is the fundamental frequency andfundAmp
is the fundamental amplitude.~thirdPartials
should return an array of two signals such that~thirdPartials.play
effectively produces stereo audio.- The number of partials generated should be 20.
- Important: Do not try to play twenty separate sine waves. Instead sum
each sine wave into a single signal that is returned by
~thirdPartials
. In the discussion of Sound Basics, we played many sine waves simultaneously which was fine to demonstrate how the ear perceives the harmonic series. The issue though if we want to create an exact waveform as described above is that there are tiny delays created when sclang sends messages to the audio server. Those delays will lead to phase differences among the different sine waves. By summing all the sinusoids within the function, we ensure that we create a single composite signal to be played.
-
REQUIRES WAVES: In class, we saw that one way to make a sawtooth wave was to sum all partials from the harmonic series such that the amplitude of any partial $n$ was $1/n$th of the fundamental’s amplitude. A sawtooth wave can also be created by using the same amplitude relationship AND shifting the phase of the even harmonics by 180 degrees. The only difference between the two methodologies is whether the slope of the ramp is positive or negative. There is no effect on our aural perception. Write a function
~sawRampUp
that implements the method for creating a sawtooth wave by shifting the even harmonics. Note: you will need to choose an invariate number of partials. For the purpose of this exercise, 30 will suffice.Some details about
~sawRampUp
:~sawRampUp
should accept two parameters:fundFreq
andfundAmp
. Set them to default values of 300 and 0.3, respectively.fundFreq
is the fundamental frequency andfundAmp
is the fundamental amplitude.~sawRampUp
should return a unit generator such that~sawRampUp.play
effectively produces audio.- As a suggestion, I would make sure to use the
.plot
method on your function to ensure that you have actually created a sawtooth ramp that ramps up. - Important: Do not try to play thirty separate sine waves. Instead sum
each sine wave into a single signal that is returned by
~thirdPartials
. In the discussion of Sound Basics, we played many sine waves simultaneously which was fine to demonstrate how the ear perceives the harmonic series. The issue though if we want to create an exact waveform as described above is that there are tiny delays created when sclang sends messages to the audio server. Those delays will lead to phase differences among the different sine waves. By summing all the sinusoids within the function, we ensure that we create a single composite signal to be played.
-
REQUIRES WAVES: Create a function called
~pulse
that returns a pulse wave by using any number of sawtooth waves with the UGenLFSaw
. Note thatLFSaw
uses an initial phase offset as an integer. For example, aniphase
of 2 offsets the sawtooth wave by $2\pi$.~pulse
should accept three parameters: a frequency, a duty cycle between 0 and 1 exclusive, and an amplitude. You do not need to handle frequencies that fall outside human audible range or duty cycles that are less than or equal to 0 or greater than or equal to 1. Ensure that your peak amplitude does not exceed 1. A good rule of thumb here would be to divide your final signal by the total number of uses ofLFSaw
.
Challenge HW
In exercise 2, we considered the sum of $\sin(x) + \sin(x + a)$ and saw that the phase of $a$ could either double the amplitude of $\sin(x)$ or completely cancel $\sin(x)$. It turns out that sinusoids are closed under addition. This means that you can add as many sinusoids as you like of the same frequency with different amplitudes and phases and still get back a sinusoid of the same frequency. Therefore, the sum of $\sin(x)$ and $\sin(x + a)$ is a single sinusoid of the same frequency. $a$, the phase of the second wave, actually controls the amplitude of the resulting wave! Changing $a$ either boosts or decays the resulting sinusoid. The earlier exercise asked you to consider two different values of $a$. In this question, let’s derive a more general understanding of the resulting signal.
-
Derive a formula to express the resulting sine or cosine wave that comes from summing these two waves together in terms of $x$ and $a$. Your answer should be in the format of $A\sin(x + \phi)$ or $A\cos(x + \phi)$ where $A$ is the amplitude of the resulting wave and $\phi$ is the resulting phase. Hint: consult this list of trignometric identities. Additionally, this formula may be useful to you depending upon your approach: $A\cos(\omega t) + B\sin(\omega t) = \sqrt{A^2 + B^2} * \cos(\omega t - \tan^{-1}(B/A))$. For the mathematically inclined, you can find a discussion of this equation here.
-
Find all values of $a$ such that the amplitude of $\sin(x)$ is equal to the amplitude of $\sin(x) + \sin(x + a)$? Note that $a$ is a constant and should be considered a fixed value. Your answer to $a$ should not contain the variable $x$.
The big takeaway from this exercise and the more manageable one from before is that amplitude and phase are very much related when dealing with multiple sinusoids of the same (or near same frequency). Audio engineers when mixing tracks have to be concerned with phase cancellation. It can kill a good audio mix and make your studio recording sound thin or warped. Differences in phase interaction can boost or completely eliminate certain parts of the frequency spectrum. As this example shows it is possible to have multiple sinusoids of the same frequency result in no change in overall amplitude but that is only at precise phase differences. More likely than not, the amplitude change will be pronounced.
Submission
Feedback
When you are finished with the problem set, please fill out the form linked here to provide feedback on how long the problem set took you and how difficult you found it. Note that you must fill out this form to receive credit for the problem set.
Submission Guidelines
All assignments in this course are submitted through Gradescope. There are two kinds of assignments in this course: paper assignments and code assignments. Both are submitted to Gradescope. Most assignments are a mix of code and paper assignments. Each question or question part will be marked either “code” or “paper” to indicate which kind of question it is. For paper assignments, note that typed answers will receive a small additional bonus of 2%.