Processing Sound

Reading: none


Code from class:

We will be using the following file in lecture: canon.txt. This file contains the notes of Pachelbel's Canon represented in an unusual format. Each row is a separate note to be played: the first column is the note's frequency, the second column is the note's starting time (in seconds), and the third column is the note's duration.

Wav files:


MATLAB support for sound

Digitized sounds can be manipulated as a one-dimensional array of numbers per channel. We will rely on MATLAB's builtin support

Plotting audio waves

A simple function for plotting stereo sound
function plotStereo(y, fs)
  subplot(2,1,1);
  x = linspace(0, length(y)/fs, length(y));
  plot(x,y(:,1), 'b');      % plot in blue
  ylabel('Left');
  xlabel('seconds');
  axis([0 length(y)/fs -1 1]);
  grid on;
  subplot(2,1,2);
  plot(x,y(:,2), 'r');       % plot in red
  ylabel('Right');
  xlabel('seconds');
  axis([0 length(y)/fs -1 1]);
  grid on;

Synthesizing sounds

We examined how to develop pure tones of a given frequency as a cosine wave, how to create other waves such as square or sawtooth waves, and how to combine different harmonics of a note to create a more realistic sounding instrument. We then examined high-level approaches to representing songs as a series of notes, or as a composition of overlayed notes.