HW1, ECE301, Prof. Boutin

In this homework assignment, we were asked to write a Matlab code to play the "Hail Purdue" song with different speeds and pitch. Here are my results:


Sound Files

MATLAB Code

% Scott Erdbruegger
% Homework 1.1
% Note this Code takes a while to run due to the number of calculations(5000*28) but can be done through software remote
format compact
clc
clear
delta = .00005;
i=1;
C=261.626;A=5*C/3;B=15*C/8;D=9*C/8;E=5*C/4;F=4*C/3;G=3*C/2;
notes=[E,F,G,A,B,C*2,C*2,D*2,D*2,D*2,A,B,B,C*2,C*2,C*2,B,A,B,C*2,C*2,B,F,G,A,G,F,B];
Lengthofnote=.25;%Note Each syllable has one note aproximently .25 of a second long
numnotes=28;
t=0;
while t<numnotes*Lengthofnote-.05
    if(mod(i,5000)==0)
        x(i)=0;z(i)=0;t
    else
         x(i)=sin(2*pi*notes(ceil(i/5000))*t);%normal
         z(i)=sin(2*pi*2*notes(ceil(i/5000))*t);%twice frequency
    end
    t=t+delta;i=i+1;
end
t=0;i=1;
while t<numnotes*Lengthofnote/2-.05
    if(mod(i,2500/2)==0)
        y(i)=0;t
    else        
        y(i)=sin(2*pi*notes(ceil(i/2500))*t);%twice as fast
    end
    t=t+delta;i=i+1;
end
wavwrite(x,'hw1normal.wav');
wavwrite(y,'hw1faster.wav');
wavwrite(z,'hw1frequency.wav');

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn