MUMT 307: Homework

Homework Submission Process

Homework Policy

"Collaboration Policy": Students can often learn a great deal from their peers. Feel free to seek help from other students (as well as the instructor and TA) when you are having difficulty. But DO NOT COPY assignments. We expect you to write your own patches and code.

Max/MSP Patch Remarks: Design your interfaces in order to group the elements (i.e., buttons, displays, sliders) in an intuitive way. Verify the implementation of the patch so that default parameters are initialized at the load time. Add small comments to help the user get started and to understand how the patch works. Test your patch (before delivering it) as if you were a real user that does not know anything about the way it has been implemented. For example, make a copy in another folder, quit Max/MSP, reload the patch and test it. Design each patch in a small window that can be printed on one page only.

Matlab and C++ Code Remarks: Your Matlab and C++ programs should be easy to read and understand. At the top of each program, provide the program name, your name, and information about the program and how to use it. For C++ programs, included a g++ compiler statement that can be used to compile the program in the working directory. In your code, be liberal with comments. Even when a program does not execute properly, partial credit may be given based on comments that show good understanding of the issues and ways to approach the solutions. Use the C++ style guide to uniformly format your code.

Homework #8Due: Tuesday, 28 March 2017 at 22:00

  1. Read pages 277-287 of Computer Music by Dodge & Jerse.
  2. Choose a sound to model using modal synthesis (one not already in STK). It is best if the object being modeled is excited by striking or plucking and its sound consists of a relatively small number (5-10) of strong resonances (there should be a reasonable sense of pitch to the sound). You will need to obtain a recording of the sound, either from the McGill University Master Samples, the University of Iowa Musical Instrument Samples, Free Sound Samples from wiki.laptop.org, by making a recording yourself, or from another source. Estimate the resonance frequencies, decay rates, and relative gains using the fft functions in Matlab or a spectrum analyzer of your choice. Write a Matlab script that implements a bank of resonant filters to resynthesize the sound (and also show in the script how you performed the parameter estimation). You should also record a "dry" strike sound to use to excite the filters and/or add directly to the resultant sound. Experiment with the parameters to improve the synthesized sound quality. [15 pts]
Homework #7Due: Tuesday, 21 March 2017 at 22:00

  1. Read pages 115-139 and 220-258 of Computer Music by Dodge & Jerse.
  2. Modify the stkbrass.cpp program to implement the FM Clarinet algorithm ((DUR = 0.5 seconds; fc = 900 Hz; fm = 600 Hz [fc : fm ratio of 3 : 2]; IMIN = 2; IMAX = 4) described on pages 125-127 of Computer Music by Dodge & Jerse. The program should take optional input arguments that specify the fundamental frequency and duration (DUR) of the resulting sound. [10 pts]
Homework #6Due: Tuesday, 14 March 2017 at 22:00

  1. Create an STK program that generates random pentatonic pitches of short duration using the SineWave class and an envelope type of your choice (Envelope, Asymp, or ADSR). The program should run in realtime and use command-line arguments to control the duration of each tone and the total duration of the program (see the STK Filters section of the notes for an example program that takes input arguments). Make sure your program provides a usage statement if the necessary arguments are missing or inappropriate values are specified. [5 pts]
Homework #5Due: Tuesday, 14 February 2017 at 22:00

  1. Read pages 87-95, 99-100 and 158-167 of Computer Music by Dodge & Jerse.
  2. In Matlab, create a unit impulse signal and use it as input to a Schroeder allpass filter with g = 0.7 and a delay of 357 samples. Then use the output of that filter as input to a feedback comb filter specified by the difference equation y[n] = x[n] - 0.95 y[n-1037]. Plot the resulting impulse response and the corresponding magnitude frequency response. [3 pts]
  3. Choose a continuously excited sound (ex., wind or bowed-string instruments) to model using additive synthesis. You will need to obtain a recording of the sound (options include the McGill University Master Samples, the University of Iowa Musical Instrument Samples, Free Sound Samples from wiki.laptop.org, by making a recording yourself, or from another source). Single tones are fine. Estimate the time-varying resonance frequencies and amplitudes using the fft or spectrogram functions in Matlab or another software spectrum analyzer. Then resynthesize the sound in either Matlab or Max/MSP using sinusoidal oscillators and the estimated parameters. Include the original soundfile with your submission, as well as the analysis information you derived from it. You should interpolate the sinusoidal amplitudes and frequencies over time as needed. [10 pts]
  4. Note that piece-wise linear envelopes can be generated in Matlab using the interp1 function as follows:

    fs = 44100;                      % sample rate
    T = 1/fs;                        % sample period
    x = [0 30 700 1000];             % time breakpoints in milliseconds
    y = [0.0 1.0 0.8 0.0];           % corresponding amplitude breakpoints at times given by vector x
    n = 0:44099;                     % time in samples (1 second at 44.1 kHz)
    env = interp1(x, y, 1000*n*T);   % scale the time steps to milliseconds
    
Homework #4Due: Tuesday, 7 February 2017 at 22:00

  1. Read pages 72-87 and 262-275 of Computer Music by Dodge & Jerse.
  2. Build a Max/MSP patch that implements a dynamic range compressor as shown in the flow chart below. The compressor should be for monophonic sounds. The patch should process input from either a sinusoidal oscillator or an adc~ object.

    The output signal of the compressor should be a scaled version of the input signal. The scaling is determined by a transfer function relating output signal power (in dB) to input signal power (in dB), parameterized by a threshold T and a compression ratio R, where R = input signal power (in dB) / output signal power (in dB) above the threshold T. When the input signal power is less than the threshold T, R = 1.0 (no compression occurs). Input signals are expected to be amplitude normalized within the range -1.0 to +1.0 so that R = 1.0 for all input signals if T = 0 dB.

    The user should be able to:

    The gain evaluation, or compression curve, should be displayed using the MSP function object. The display of the "transfer function" will be the output level in dB on the y-axis and the input level in dB on the x-axis. The ranges will be defined from -100 to 0 dB for both axes. Since the minimum value for the x-axis when using the function object is 0, you should implement a shift-in, shift-out offset before and after the function object. The compression curve display should be automatically updated when modifications are made to the compression ratio and threshold slider values. [20 pts]

-
Homework #3Due: Tuesday, 31 January 2017 at 22:00

  1. Read pages 289-308 of Computer Music by Dodge & Jerse.
  2. Build a Max/MSP patch that simulates a very simple monophonic synthesizer. This synthesizer must include a controlled generator and a controlled amplifier.

    The user should be able to select any one of the following three waveforms for the generator: sinusoid, sawtooth, or resonant filtered noise. Pitch will be controlled using the Max keyboard (kslider) object and will include a vibrato effect (i.e., a frequency modulation of 5 to 10 Hz with a deviation of 5-10%).

    A note should continue as long as a key on the kslider is depressed (change the "Display Mode" to "Touchscreen" in the inspector) and then stop when the key is released. Use line~ objects to envelope each note attack and release, with key velocity controlling the attack and release durations (higher velocity should equal shorter times). The interface should include two number boxes to allow the specification of the maximum attack and release durations (when the velocity is 0).

    Other required features:

    Remarks: Think of the implementation in a modular way (you might use subpatches); design the interface in order to group the parameters into a control front panel (you may use routing objects to clarify the structure of the patch); verify the implementation of the patch so that default parameters are initialized at load time; add small comments to help the user get started and to understand how the patch works; Test your patch (before delivering it) as if you were a real user that does not know anything about the way it has been implemented. For example, make a copy in another folder, quit Max/MSP, reload the patch and test it. Design each patch/subpatch in a small window that can be printed on one page only. [10 pts]

  3. Write Matlab syntax to define the following two filter structures, as well as commands to plot their frequency responses [2 pts]:
Homework #2Due: Tuesday, 24 January 2017 at 22:00

Figure 1: A second-order digital filter.

  1. Read pages 169-219 of Computer Music by Dodge & Jerse.
  2. Consider the digital filter described by the block diagram in Fig. 1 above:
    1. Write the difference equation for the filter. [1 pt]
    2. Use this difference equation to calculate the first 5 values of the filter's impulse response (write out the operations by hand). [1 pt]
    3. In four lines or less (one instruction per line), write Matlab syntax to define the filter and calculate its impulse response (minimum of 50 values). [1 pt]
    4. Add one more line of Matlab syntax to calculate and plot the filter frequency response (magnitude and phase). [1 pt]
    5. Is the filter stable? Explain your answer. [1 pt]
  3. Digital Resonance Filters:
    1. Write Matlab syntax to define a digital resonance filter with a center frequency of 2000 Hz at a sample rate of 44100 Hz (let r = 0.99). The filter gain at the center frequency should be normalized. Verify the design by plotting the filter frequency response. [2 pts]
    2. Use the Matlab rand function to generate a one-second noise sequence (scale it to a range from -1.0 < x < +1.0 with zero mean) and use this as input to the filter. Use the spectrogram() function to view the spectrum of the resulting filtered noise. [2 pts]
Homework #1Due: Tuesday, 17 January 2017 at 22:00

  1. Read chapters 1-3 of Computer Music by Dodge & Jerse, pp. 1-71.
  2. Write a matlab script that performs the following operations on the audio file triangle.wav:

  3. [5 pts]

  4. Write another Matlab script that computes and displays the mean, power, rms power, and variance of the waveform in trumpet.wav. These metrics should be calculated over "blocks" of M samples (define M near the top of your script with a default value of 4275) and the plotted metric values should be superposed over the signal as horizontal lines that vary every M samples. Provide a legend in the plot. The Matlab reshape() function can be used to simplify the calculations. The example sinemetrics.m script should provide a good starting point. In the end, the plot should look like the figure below. [7 pts]


McGill ©2004-2017 McGill University. All Rights Reserved.
Maintained by Gary P. Scavone.