Sound Files

I can't really find a good way to record these, but it does sound really good if you run the code!

Matlab Code

% Eric Zarowny
% ECE 301 HW 1.1

% Just in case...
clear;
clc;

% Setting the sampling frequency (20 kHz)
delta = 0.00005;

% Note frequencies defined at http://www.phy.mtu.edu/~suits/notefreqs.html
RST = 0;
Ef4 = 311.13;
F4 = 349.23;
G4 = 392.00;
Af4 = 415.30;
Bf4 = 466.16;
B4 = 493.88;
C5 = 523.25;
Df5 =  554.37;

% Define note durations => 2/4 @ 164bpm (I asked a guy from the band!)
Q = 60/164; % Quarter Note
H = 2*Q;    % Half Note
E = Q/2;    % Eighth Note
DQ = Q+E;   % Dotted Quarter Note
DH = H+Q;   % Dotted Half Note

% Score for Old Purdue found at
% http://www.purdue.edu/bands/news/scrapbook/aamb/Hail%20Purdue%20Piano%20Sheet.pdf

% Lay out the song in two matrices, one for the notes ...
notes = [Ef4 F4 G4 Af4 Bf4 C5 C5 ...            
         Df5 Df5 Df5 Af4 Bf4 B4 C5 RST...       
         C5 C5 Bf4 Af4 Bf4 C5 C5 Bf4 F4 G4 ...  
         Af4 G4 F4 Bf4 RST Ef4 Ef4 ...
         F4 G4 Af4 Bf4 C5 C5 C5 Df5 Df5 Af4 Bf4 ...
         C5 RST F4 G4 Af4 F4 Ef4 Af4 ...
         C5 Ef4 F4 C5 Bf4 Af4 Af4];
         
% and one for the note lengths     
note_length = [H Q Q DQ E Q Q ...
               Q E E Q E E DH Q ...
               H Q Q DQ E Q Q Q E E ...
               Q E E DH Q DQ E ...
               Q Q DQ E Q E E Q Q Q Q ...
               DH Q DQ E Q Q Q Q ...
               Q Q DQ E DQ E DH];

% Use loops to play the song back at various speeds

% Normal Speed
for i = 1:length(note_length) 
    t = 0:delta:note_length(i);
    y = sin(2 * pi * notes(i) * t);
    sound(y,1/delta)
end

% Double Speed (could also get the same results by doubling the bpm)
for i = 1:length(note_length) 
    t = 0:delta:0.5*note_length(i); % Added a 0.5 times the note length to cut them in half
    y = sin(2 * pi * notes(i) * t);
    sound(y,1/delta)
end

% y(t) = x(2t) transformation
for i = 1:length(note_length) 
    t = 0:delta:note_length(i);
    y = sin(2 * 2 * pi * notes(i) * t); % Added a 2 times the frequency to change the pitch
    sound(y,1/delta)
end

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn