Everything in Modulation

Assign: Thursday, October 21

Due: Thursday, October 28

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.

Starter Code

Download the starter code here

Written Exercises HW

  1. In one sentence, explain the difference between the frequency spectrum of amplitude modulation and of ring modulation.

  2. LFO (Low Frequency Oscillators) are sometimes used to create a tremolo effect via ring modulation. The carrier frequency is the original signal and the modulator signal is an LFO producing the tremolo at the rate of the LFO’s frequency. Is the original frequency preserved after the carrier has been modulated by the modulator? Do we still perceive the original frequency aurally? Under what conditions? Explain in a few short sentences.

  3. The wave $f(t) = \sin(400\pi t + \pi/4) + \sin(250\pi t + \pi)$ is modulated by the signal $h(t) = \cos(200\pi t)$ to produce the signal $k(t) = f(t)h(t)$. State all frequencies and their phases and amplitudes present in $k(t)$. Show the work you did to arrive at your answer.

  4. A carrier sine wave of 400Hz is frequency modulated with a sine wave of 200Hz.

    1. What are the frequencies of the first three sidebands of the resulting signal? Any negative frequencies should be treated as positive frequencies.

    2. Is the resulting signal harmonic? Explain. If so, what is the fundamental frequency?

  5. FM modulation is an efficient way to produce sounds with complex spectra. Does FM modulation lead to aliasing? Explain. What role, if any, does the modulation index play?

Exercises C

  1. Use ring modulation to create a simple SynthDef called octavizer that takes a freq, amp, and out argument and produces two sine waves at the frequency and an octave above the frequency. The simple solution would be the one below:

     (  
     SynthDef(\octavizer, {  
         arg out = 0, freq = 440, amp = 0.1;  
         Out.ar(out, SinOsc.ar(freq) + SinOsc.ar(freq*2) * amp ! 2);  
     }).add;  
     )
    

    Instead, try and create the exact same effect by using ring modulation with two sine waves. The frequencies produced by the ring modulation should have the same amplitude and frequency as the one shown above.

  2. In this exercise, create something fun and musical using the tools we have learned so far. This is an opportunity for you to be creative! For those choosing to do a composition for the final project, this will be good practice. Choose any one of the FM or PM SynthDefs we made in lecture or in this assignment and write three patterns that use FM/PM synthesis to create your own short musical work. You have free reign to do whatever you like with the exception of a few constraints.

    Requirements:

    • You must create three (or more) Pbind/Pbindef patterns that use an FM/PM SynthDef. Creating Pbindefs will allow you to update those patterns if that is important to your work. Otherwise keep them as Pbinds.
    • You must create a tempo clock and set those patterns to the tempo clock
    • You must use four or more different patterns other than Pbind and Pbindef. Explore the help documentation. All pattern classes begin with the letter “P”.
    • You must change the modulation index or harmonicity ratio in at least one of the Pbinds to create a changing harmonic spectrum. Don’t just set it to a new constant value. I recommend using something like Pseg.
    • You must have one of the patterns generate chords. See below.
    • Send a recording to your instructor at adavis15@wellesley.edu. Please see the note at the bottom about recording.

    You will notice that I used patterns to create chords. It is fairly easy to do. Here is a small example demonstrating this:

    (
    SynthDef(\sine, {
      arg freq = 440, amp = 0.1;
      var sig = SinOsc.ar(freq, mul: amp) * EnvGen.kr(Env.perc, doneAction: 2);
      Out.ar(0, sig ! 2);
    }).add;
    )
    
    // plays Bb, Db, F chord
    (
    Pbind(
      \instrument, \sine,
      \dur, 0.5,
      \midinote, [70, 73, 77] 
    ).play;
    )
    
    // plays Bb, Db, F chord then a C, E, G chord
    (
    Pbind(
      \instrument, \sine,
      \dur, 0.5,
      \midinote, Pseq([[70, 73, 77], [72, 75, 79]], inf) 
    ).play;
    )
    

    A chord can be created in a pattern by simply using an array of values. In the first Pbind example, an array is given to midinote instead of a single number. Therefore all three notes are played at once every half second. In the second Pbind example, a Pseq cycles through two arrays. Therefore, the first array is played followed by the second chord.

    Below is an example of what I did. Don’t copy me. Find something that appeals to you musically.

    How To Record: Recording in SuperCollider is pretty straight forward. Use the following code to start the recording process. The first code block prepares the recording. In this example, the recording will be called “piece.wav” and it will be placed on your desktop. To actually start the recording, execute r.record. Note that the Recorder object is stored in a variable r but you could name it whatever you like. To stop the recording process, run r.stopRecording. The file will then appear on your desktop.

    // Prepare the recording
    (
    r = Recorder(s);
    r.prepareForRecord("~" +/+ "Desktop/piece.wav");
    r.recHeaderFormat = "WAV";
    )
    
    // Record
    r.record; 
    
    // All of your code to execute and play your piece
    
    // Stop recording
    r.stopRecording; 
    

    An important note: .wav files typically have information about the number of samples stored in the .wav file. Because a SuperCollider recording is done in realtime and it is not known ahead of time how long the recording process will take, SuperCollider .wav files will lack that information. This can be a problem for some audio players. If you are having trouble listening to your recording, please download Audacity. Open the file in Audacity and then export it as a .wav file. Audacity will fix this particular issue. It is an unfortunate work around but it will solve the problem.

DX7 Patch - Bass 1 C

The final exercise is to recreate one of the patches from the original Yamaha DX7 which was the first synthesizer to use digital FM synthesis. The original DX7 came with 32 presets, many of which became iconic sounds of the 1980s. As a final wrap up on FM synthesis, we’ll recreate one of the bass sounds, eloquently called “Bass 1”. First, take a listen to someone playing the original preset on the original DX7 (note that there is reverb so it is not an unadulterated representation).

Many songs have used the DX7. One famous example of the “Bass 1” preset is Kenny Loggins’ “Danger Zone”, which was used in the movie Top Gun. Take a listen. The “Bass 1” is the very first sound in the song and pervades throughout.

IMPORTANT: A special note about the DX7. The oscillators in the DX7 technically use phase modulation and not frequency modulation. Your implementation should use phase modulation. Fortunately, SinOsc has a parameter for phase and therefore it is very straightforward to modulate the phase of a sine wave. See the lecture code on phase modulation.

Overview of Oscillators

To get started on creating this sound, we first need to know a little bit about the structure of the DX7. The DX7 contained six sine wave oscillators. Any one of the sine wave oscillators can serve as a modulator or carrier. Complex sounds can be created by using multiple modulators both in parallel and in series. A particular arrangement of the oscillators was referred to by Yamaha as an “algorithm”. Below is a visualization of algorithm 16 which is the basis for “Bass 1”.

Algorithm 16 from the Dx7

The output we hear comes from the sine oscillator numbered 1. This oscillator though is modulated by a complex combination of the remaining 5 oscillators. Oscillator 1 is modulated by the addition of the outputs of Oscillators 2, 3, and 5. Oscillator 3 is phase modulated by Oscillator 4. Oscillator 5 is phase modulated by Oscillator 6. Oscillator 6, though, is unique because it also modulates itself using feedback (i.e., the output of oscillator 6 becomes its input). We will not worry about how to implement oscillator feedback in this course. To do so would require us to write our own classes. Instead, we will simply use SinOscFB.ar with a feedback level of 7 and then use its output to phase modulate Oscillator 5.

The frequency of each sine wave oscillator should be a ratio of the provided frequency (i.e., the frequency we hear). The table below lists those ratios.

  Osc1 Osc2 Osc3 Osc4 Osc5 Osc6
Ratio 1 0.5 0.5 5 0.5 9

Envelopes

In addition to the six sine wave oscillators, each DX7 oscillator has its own amplitude envelope. Recall that the amplitude of the modulator affects the amplitude of the partials produced by FM and PM synthesis. Thus, creating an amplitude envelope for a modulator will change the amplitude of the partials over time. Here are the shapes of each of the envelopes for the five modulating oscillators. These envelopes are fixed-time envelopes. The envelope of oscillator 1 is determined by the player. You should use an ADSR envelope with a gate to trigger the onset and release.

Envelope 2: should last about 5 seconds and go from an amplitude of 1 to 0

Envelope 2

Envelope 3: should last about half a second and go from an amplitude of 0.6 to 0

Envelope 3

Envelope 4: should last about 0.3 seconds and go from an amplitude of 1 to 0.8 and then cut straight to silence.

Envelope 4

Envelope 5: should last about seven seconds and go from an amplitude of 1 to 0

Envelope 5

Envelope 6: should last about a tenth of a sceond and go from an amplitude of 1 to 0.2 and then cut to silence.

Envelope 6

Additional Requirements

Testing and Development

There is no exact, perfect answer to this assignment other than meeting the specifications detailed above. I have provided most of the information to get you quite close but you will need to do some fine tuning on your own to get the best approximation. A lot of audio computer engineers use the theoretical framework to generate sound and then their ears to fine tune them to something musical. It is truly a balance between musical understanding and digital signal processing. I will not grade you on whether your patch sounds exactly like the original DX7 or my attempt. A reasonable facsimile will suffice.

Your first step should be to simply implement the algorithm verbatim as I have described. Your second step should then be to fine tune the parameters of your various oscillators to get closer. How do you do this? The biggest adjustments you can make is varying the proportion of each modulating oscillator. The effect of a modulator we can be adjusted by simply using a scaling factor. Recall that the amplitude of the modulating wave affects the strength of the partials for the carrier its modulating. Most of my fine tuning was spent adjusting the overall amplitude of each modulator. That is where the remaining portion of your time should be spent.

In Summary: Each modulating oscillator is a sine wave or sine wave with feedback. The output of each sine wave is multiplied by an amplitude envelope and then some scaling factor to adjust the overall strength of the sine wave. The scaling factor is the only piece of information I have not explicitly given you. I want you to use your ears to figure out what the right value is to approximate this bass sound. As a hint, all my scaling factors were in the range of 0.5 to 10. The final result is then used to control the phase of some other sine wave.

To test the sound, you can simply create a synth and then set the gate to 0 to turn it off. Additionally, I have provided some additional code to play your SynthDef on a digital keyboard. Simply plug in a keyboard into your computer and run the code once to connect. Feel free to try this on the MIDI keyboards in the Sound Lab.

If you would like to hear how my implementation sounds, here is a recording:

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%.