clear all
clc
%Austin Melnyk 
%Homework one: Play the first 6 notes to the Hail Purdue Fight song.
%09/04/08
%Defined notes
A=220;
B=512;
C=426;
D=480;
Db=277;
E=320;
F=341;
G=384;
Gb=370;

delta=.00005;
T_0=0:delta:.5;
x=ones(5/delta, 1);
%Notes Vector for the first 6 beats of the Hail Purdue Song entitled "Hail
%Hail To Old Purdue" as required by the assignment.
n_v=[E,F,G,C,D,B];

delta = 0.00005;

T=0:delta:1.0;
n_1 = sin(2*pi*E*T);

T=0:delta:0.5;
n_2 = sin(2*pi*F*T);
n_3 = sin(2*pi*G*T);
n_4 = sin(2*pi*C*T);

T=0:delta:0.5;
n_5 = sin(2*pi*D*T);

T=0:delta:0.4;
n_6 = sin(2*pi*B*T);

fullsong = [n_1 n_2 n_3 n_4 n_5 n_6];

sound(fullsong,1/delta);

pause(1)
%Twice as fast
T=0:delta:(0.5*1.0);
n_1 = sin(2*pi*E*T);

T=0:delta:(0.5*0.5);
n_2 = sin(2*pi*F*T);
n_3 = sin(2*pi*G*T);
n_4 = sin(2*pi*C*T);

T=0:delta:(0.5*0.5);
n_5 = sin(2*pi*D*T);

T=0:delta:(0.5*0.4);
n_6 = sin(2*pi*B*T);

fastsong = [n_1 n_2 n_3 n_4 n_5 n_6];

sound(fastsong, 1/delta);

pause(1)
%Twice the frequency
T=0:delta:(0.5*1.0);
n_1 = sin(2*2*pi*E*T);

T=0:delta:(0.5*0.5);
n_2 = sin(2*2*pi*F*T);
n_3 = sin(2*2*pi*G*T);
n_4 = sin(2*2*pi*C*T);

T=0:delta:(0.5*0.5);
n_5 = sin(2*2*pi*D*T);

T=0:delta:(0.5*0.4);
n_6 = sin(2*2*pi*B*T);

freqsong = [n_1 n_2 n_3 n_4 n_5 n_6];

sound(freqsong, 1/delta);

wavwrite(fullsong, 1/delta, 'hailpurdue.wav');

Heres the song file woot

Alumni Liaison

EISL lab graduate

Mu Qiao