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.

Handwritten Questions

  1. Define the terms filter, amplitude response, and phase response. Do filters change the pitch of a sound?

  2. Consider the signal $x[n] = [1, 0, -1, 1]$.

    1. What is the signal that results after passing $x[n]$ through a feedforward comb filter with $M = 2$ and $g_f = 0.5$?

    2. What is $x[n - 1.25]$ using linear interpolation?

    3. What is the signal that results after passing $x[n]$ through a feedback comb filter with $M = 2$ and $g_b = 0.5$?

  3. How many samples of delay would be necessary to create an infinite, quarter-second echo in a feedback comb filter with a sample rate of 48000Hz?

  4. Explain how to create a band reject (also known as a bandstop) filter from a lowpass filter and highpass filter.

  5. A sine wave has an amplitude of 0.25. What is an equivalent measure in Decibels?

Delay Coding Questions

To get started, open up a new blank .scd file in the SuperCollider IDE.

  1. Start out by writing a SynthDef called \saw that plays back a mono bandlimited sawtooth wave. It should have a simple attack/release amplitude envelope and a doneAction to free the Synth when the envelope is completed.

    Copy and paste the code below and implement the SynthDef.

    (
    SynthDef(\saw, {
          arg out = 0, freq = 440, amp = 0.1, atkTime = 0.03, relTime = 0.1;
          var sig;
            
        // Your code here
                
    }).add;
    )
    

    Create a Synth to test it. If done correctly, we should only hear sound out of the left speaker because it is a mono signal.

  2. Write a SynthDef called \one_echo that reads in a mono signal and outputs the signal to the left speaker unaffected. It should also output the read signal with a delay of a tenth of second at half the amplitude to the right speaker. Thus, the signal is copied to both channels but only has a delay in the right speaker. You should hear a ping pong effect where noise is initially heard in the left speaker but then echoed in the right speaker.

    You should test this by creating a Synth for \one_echo and a bus for \one_echo to read from. Create Synths using \saw that output to the bus that \one_echo is reading from.

  3. Start by coping your SynthDef for \one_echo and rename it to \one_echo_verb. Add a line of code that passes the signal through reverb. It is very common for delay to be passed to reverb as it creates a nicer sense of space. You can use the UGen FreeVerb. Reverb should be applied after it has gone through the delay system. Create the following default arguments for the reverb: mix = 0.5, room = 0.5. Test in the same way as Exercise 2.

  4. Write a SynthDef called \many_echo_verb that reads in a mono signal and passes it through the following delay network. The left speaker should take the mono signal and pass it through a feedback comb filter with delay time of 0.1 seconds and whose echoes last 10 seconds. The right speaker should also take the mono signal and pass it through a feedback comb filter with delay time of 0.11 seconds and whose echoes last 10 seconds. Apply reverb after the signal has gone through this delay network. Create default arguments for the reverb: mix = 0.5, room = 0.5.

    Here is some code to test this. The recording below was played by executing these four lines in various different orders. Note that you will need to change the variable ~bus to whatever you have named your bus.

     Synth(\saw, [\freq, 440, \out, ~bus]);
     Synth(\saw, [\freq, 392, \out, ~bus]);
     Synth(\saw, [\freq, 293, \out, ~bus]);
     Synth(\saw, [\freq, 330, \out, ~bus]); 
    

    The recording:

Filter Coding Questions

  1. Write a SynthDef called \saw_lowpass that creates a non-bandlimited sawtooth wave, passes it through a lowpass filter, and then is multiplied by a fixed-time amplitude envelope that has an attack, sustain and release portion. The envelope should have a done action to free the synth when it is done. The output should be a stereo signal. Test it by creating a Synth and override the default argument with a cutoff frequency of your choosing. Feel free to play around and use a highpass filter or bandpass filter.

    (
    SynthDef(\saw_lowpass, {
        arg out = 0, freq = 80, amp = 0.1, atkTime = 0.03, susTime = 1, relTime = 0.1, cutoff = 1000;
        var sig;
      // Your code here
    
    }).add;
    )
    
  2. Start by copying your code for \saw_lowpass and rename it to \saw_lowpass_sweep. Here we are going to modulate the cutoff frequency of the saw wave over time. This is a very common strategy to give a sound more life in synthesized music. Because the partials of real instruments change over time, it is nice to mimic that behavior when we generated synthesized instruments. Create an envelope that takes the cutoff frequency supplied from the user, ramps up to five times that value, and ramps down back to the supplied cutoff frequency. The ramp up and the ramp down should each take 0.5 seconds. Now when you play the Synth, you should get a “WAH” kind of sound as the filter opens and closes.

  3. Start by copying your code for \saw_lowpass_sweep and rename it to \saw_lowpass_sweep_mono. Just make one simple change to the code. Make the output signal mono instead of stereo. Now create Synths and pass them through an instance of \many_echo_reverb that you created earlier.

    Here are some synths I used to test it. Again, you will need to use your variable name for the bus that \many_echo_reverb will be reading from.

    Synth(\saw_lowpass_sweep_mono, [\amp, 0.05, \freq, 440, \out, ~bus]);
    Synth(\saw_lowpass_sweep_mono, [\amp, 0.05, \freq, 392, \out, ~bus]);
    Synth(\saw_lowpass_sweep_mono, [\amp, 0.05, \freq, 293, \out, ~bus]);
    Synth(\saw_lowpass_sweep_mono, [\amp, 0.05, \freq, 330, \out, ~bus]);
    

    Here is a sample recording:

Solutions

Solutions to the lab will be posted after the lab is over.

lab_delay_filters_solns.pdf
lab_delay_filters_solns.scd