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:
      [samples freq bitsPerSample aux] = audioread(filename)
      
  
      audiowrite(samples, filename)
      audiowrite(samples, freq, filename)
      audiowrite(samples, freq, bitsPerSample, filename)
      
  
      audioplay(samples, freq)
      audioplay(samples, freq, 'async')    %  call returns even while sound is still playing
      audioplay(samples, freq, 'sync')     %  call waits until sound is complete before returning
      
  sound(samples, freq) %call returns while sound is playing
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;
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.