Assignment 9: Amplitude and Pitch Tracking

You can analyze the amplitude and pitch of audio, either live or played from sound files, and use the resulting data to influence the audio generated by the computer or to trigger events. This kind of analysis is frequently known as amplitude or pitch tracking.

When you analyze the amplitude of an audio signal, you look at all the individual sample points that flow by at the sampling rate. The sample point that has the highest absolute value within a particular span of time is the peak amplitude for that span of time. Looking for the peak amplitudes drawn from short (e.g., 50 millisecond) contiguous time spans turns out to be a good way of tracking, or following, the envelope of a sound. In Max, we can do this with the peakamp~ object.

To track pitch, we can use the sigmund~ object. This doesn’t come with Max5, so you have to download it and either install it or keep it in the same folder as your patches that use it. The sigmund~ object emits a continuously varying pitch and amplitude estimate for an input signal. The signal needs to be a clear, monophonic melodic source, like someone singing into a microphone with no additional processing. The pitch estimate can be used to do many different things. Simple examples include doubling or harmonizing a vocal with a synthetic line, or triggering a sound when the vocalist sings a middle C.

  1. Download the example patches for this assignment.
  2. Play around with the “amptrack” patch, until you understand how it works. When the peak amplitude of the input sound exceeds a threshold, then the > object outputs a 1; when the peak falls below the threshold, > outputs a 0. The togedge object sends a bang out its left outlet when it detects a transition from 0 to 1. So every time the peak amplitude rises above the threshold, we get a bang from togedge and use this to play a MIDI drum note. You have to tune the threshold carefully for this to work.

    (There is a more complex, but better, way to handle the threshold logic. You can see this at work in the “bliptrig” folder in the MSP Quickstart tutorials.)

  3. Make a patch that works like the “amptrack” patch, but instead of triggering a MIDI note, make it trigger an audio event of your choice (such as playing back a sound file).

    Suggestions...

  4. Study the “pitchtrack” patch, and see how the pitch estimate responds to different kinds of input signals. The left outlet of sigmund~ is a MIDI note number, but with a fractional component. Rounding this number to its nearest integer is optional. In the example patch, the pitch estimate is used to control the pitch of a square wave oscillator that doubles the input sound. The result is pretty glitchy, sometimes in an interesting way. You could control this better by using a split object to exclude MIDI pitch numbers that are obviously out of range, as can happen with unvoiced sounds from a vocalist, silence, or notes that are too low to be tracked.
  5. Make a patch that uses sigmund~ to track the pitch of an input source. When the pitch falls within a certain narrow range, use that as a trigger to play a sound.

    Suggestions...

©2011, John Gibson