(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | [[Media:FastFightSong_ECE301Fall2008mboutin.wav]] | |
− | [[ | + | |
− | [[RescaledFightSong_ECE301Fall2008mboutin.wav]] | + | [[Media:FightSong_ECE301Fall2008mboutin.wav]] |
+ | |||
+ | [[Media:RescaledFightSong_ECE301Fall2008mboutin.wav]] | ||
<pre> | <pre> | ||
%Tyler Johnson | %Tyler Johnson | ||
Line 12: | Line 14: | ||
%Frequencies for each note | %Frequencies for each note | ||
%using the frequencies from the homework page, the A note will have a frequency of 440 Hz | %using the frequencies from the homework page, the A note will have a frequency of 440 Hz | ||
− | %some of the frequencies | + | %some of the frequencies given were way off so I used integer values that I |
+ | %got from the internet at http://www.phy.mtu.edu/~suits/notefreqs.html | ||
x = 264; | x = 264; | ||
− | UC = 2*x | + | |
− | B =(15*x)/8 | + | UC = 2*x %523 |
− | A =415 | + | B =(15*x)/8 %493 |
− | G =(3*x)/2 | + | A =415 %415 |
− | F =(4*x)/3 | + | G =(3*x)/2 %392 |
− | E =311 | + | F =(4*x)/3 %349 |
− | D =(17*x)/8 %554 | + | E =311 %311 |
+ | D =(17*x)/8 %554 | ||
MC =x | MC =x | ||
Line 39: | Line 43: | ||
Lengths = [H, Q, Q, Q+EI, EI, Q, Q, Q, EI, EI, Q, EI, EI, H+Q]; | Lengths = [H, Q, Q, Q+EI, EI, Q, Q, Q, EI, EI, Q, EI, EI, H+Q]; | ||
+ | FightSong = []; | ||
for counter = 1:14 | for counter = 1:14 | ||
t=0:delta:Lengths(counter); | t=0:delta:Lengths(counter); | ||
d=sin(2*pi*t*Notes(counter)); | d=sin(2*pi*t*Notes(counter)); | ||
sound(d,1/delta); | sound(d,1/delta); | ||
+ | FightSong=[FightSong, d]; | ||
end | end | ||
+ | %Save a wav file: | ||
+ | wavwrite(FightSong,20000,32,'N:\ECE301\Homework 1\FightSong.wav'); | ||
+ | |||
pause(2); | pause(2); | ||
%Play twice as fast | %Play twice as fast | ||
+ | FastFightSong = []; | ||
for counter = 1:14 | for counter = 1:14 | ||
t=0:delta:Lengths(counter)/2; | t=0:delta:Lengths(counter)/2; | ||
d=sin(2*pi*t*Notes(counter)); | d=sin(2*pi*t*Notes(counter)); | ||
sound(d,1/delta); | sound(d,1/delta); | ||
+ | FastFightSong=[FastFightSong, d]; | ||
end | end | ||
+ | wavwrite(FastFightSong,20000,16,'N:\ECE301\Homework 1\FastFightSong.wav'); | ||
pause(2); | pause(2); | ||
%Rescaled | %Rescaled | ||
+ | RescaledFightSong = []; | ||
for counter = 1:14 | for counter = 1:14 | ||
t=0:delta:Lengths(counter); | t=0:delta:Lengths(counter); | ||
d=sin(2*pi*(t*2)*Notes(counter)); | d=sin(2*pi*(t*2)*Notes(counter)); | ||
sound(d,1/delta); | sound(d,1/delta); | ||
+ | RescaledFightSong=[RescaledFightSong, d]; | ||
end | end | ||
+ | wavwrite(RescaledFightSong,20000,16,'N:\ECE301\Homework 1\RescaledFightSong.wav'); | ||
</pre> | </pre> |
Latest revision as of 06:57, 5 September 2008
Media:FastFightSong_ECE301Fall2008mboutin.wav
Media:FightSong_ECE301Fall2008mboutin.wav
Media:RescaledFightSong_ECE301Fall2008mboutin.wav
%Tyler Johnson %September 3rd, 2008 %clear memory clear; %clear console clc; %Frequencies for each note %using the frequencies from the homework page, the A note will have a frequency of 440 Hz %some of the frequencies given were way off so I used integer values that I %got from the internet at http://www.phy.mtu.edu/~suits/notefreqs.html x = 264; UC = 2*x %523 B =(15*x)/8 %493 A =415 %415 G =(3*x)/2 %392 F =(4*x)/3 %349 E =311 %311 D =(17*x)/8 %554 MC =x %Length of note delta = .00005; EI = .125; %Eigth Note Q = .25; %Quarter Note H = .5; %Half Note T = .75; %Three Quarters Note W = 1; %Whole Note %Song verticies %Song plays "Hail Hail to old Purdue! All hail to our old gold and black" Notes = [E, F, G, A, B, UC, UC, D, D, D, A, B, B, UC]; Lengths = [H, Q, Q, Q+EI, EI, Q, Q, Q, EI, EI, Q, EI, EI, H+Q]; FightSong = []; for counter = 1:14 t=0:delta:Lengths(counter); d=sin(2*pi*t*Notes(counter)); sound(d,1/delta); FightSong=[FightSong, d]; end %Save a wav file: wavwrite(FightSong,20000,32,'N:\ECE301\Homework 1\FightSong.wav'); pause(2); %Play twice as fast FastFightSong = []; for counter = 1:14 t=0:delta:Lengths(counter)/2; d=sin(2*pi*t*Notes(counter)); sound(d,1/delta); FastFightSong=[FastFightSong, d]; end wavwrite(FastFightSong,20000,16,'N:\ECE301\Homework 1\FastFightSong.wav'); pause(2); %Rescaled RescaledFightSong = []; for counter = 1:14 t=0:delta:Lengths(counter); d=sin(2*pi*(t*2)*Notes(counter)); sound(d,1/delta); RescaledFightSong=[RescaledFightSong, d]; end wavwrite(RescaledFightSong,20000,16,'N:\ECE301\Homework 1\RescaledFightSong.wav');