Files

Media:Hail_Normal_ECE301Fall2008mboutin.ogg

Media:Hail_Fast_ECE301Fall2008mboutin.ogg

Media:Hail_High_ECE301Fall2008mboutin.ogg

Matlab File

%Travis Safford (tsafford@purdue.edu
%9/5/08 
%Hw 1.1


clear;
clc;


%Google found me this lovely site
%http://www.phy.mtu.edu/~suits/notefreqs.html
%from the lads at MIT that has the note frequencies on it
A = 440;
Bb = 466.16;
B = 493.88;
Cb = 523.25;
C = 523.25;
Db = 554.37;
D = 587.33;
Eb = 622.25;
E = 659.26;
F = 698.46;
Gb = 739.99;
G = 783.99;
Ab = 830.61;

%And that's that.

%Mimi used this in class, so i'll use it too
delta =1/20000;

%Assuming 4/4 quarter notes are 172 bpm
%Thus 1 quarter note is 60/172 minutes
Q = 60/172; %Quarter Note
Ei = 0.5*Q; %Eighth note (can't be E because of note)
H = 2*Q;    %Half Note
W = 4*Q;    %Whole Note
DQ = 1.5*Q; %Dotted Quarter
DH = 3*Q;   %Dotted Half

%timing fot the notes

Lengths =[H,Q,Q,DQ,Ei,Q,Q,Q,Ei,Ei,Q,Ei,Ei,DH,H,Q,Q,DQ,E,Q,Q,Q,Ei,Ei,Q,Ei,Ei,W,DQ,Ei,...
    Q,Q,DQ,Ei,Q,Ei,Ei,Q,Q,Q,Q,W,DQ,Ei,Q,Q,Q,Q,Q,Q,DQ,Ei,Dq,Ei,W,W];
%notes for song

Notes =[A,B,Db,D,E,Gb,Gb,G,G,G,D,E,F,Gb,Gb,Gb,E,D,E,Gb,Gb,E,B,Db,D,Db,B,E,...
    A,A,B,Db,D,E,Gb,Gb,Gb,G,G,D,E,Gb,B,Db,D,B,A,D,Gb,A,B,Gb,E,D,D];

%array declarations

allsound = [];
allsound2 = [];
allsound3 = [];


%the allsound portions of the code are concatenating the most recent note
%that is being played to an initially empty array.  Then, once the
%whole song segment has played, it writes that array to a sound file
%that we can then download and listen to at our leisure :)


%regular speed 
for i = 1:length(Notes)
	t = 0:delta:Lengths(i);
	wave = sin(2*pi*t*Notes(i));
	sound(wave,1/delta);
        allsound = cat(2, allsound, wave);
end


pause(5)

%double speed
%Cut lengths in half

for j =1:length(Notes)
	t =0:delta:0.5*Lengths(j); 
	wave =sin(2*pi*t*Notes(j));
	sound(wave,1/delta);
	allsound2 = cat(2, allsound2, wave);
end

pause(5)


%doubles the frequencies for the transformation
%y(t)=x(2t)
for k =1:length(Notes)
	t =0:delta:Lengths(k);
	wave =sin(2*2*pi*t*Notes(k)); 
	sound(wave,1/delta);
	allsound3 = cat(2, allsound3, wave);
end
wavwrite(allsound,1/delta,'Regular.wav');
wavwrite(allsound2,1/delta,'Fast.wav');
wavwrite(allsound3,1/delta,'High_Pitch.wav');

Alumni Liaison

To all math majors: "Mathematics is a wonderfully rich subject."

Dr. Paul Garrett