(→Sound File) |
(→MATLAB Code) |
||
Line 5: | Line 5: | ||
== MATLAB Code == | == MATLAB Code == | ||
+ | <pre> | ||
+ | % Scott Erdbruegger | ||
+ | % Homework 1.1 | ||
+ | % Note this Code takes a while to run due to the number of calculations(5000*28) | ||
+ | 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 aproixamently .25 of a second | ||
+ | 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'); | ||
+ | </pre> |
Revision as of 06:51, 1 September 2008
Sound File
- Hail Purdue at normal speed using
- Hail Purdue at double speed
- Hail Purdue at twice the frequency
MATLAB Code
% Scott Erdbruegger % Homework 1.1 % Note this Code takes a while to run due to the number of calculations(5000*28) 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 aproixamently .25 of a second 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');