(→SOUND FILE) |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | <pre> | |
+ | %Daniel Barjum | ||
+ | %ECE 301 HW 1.1 | ||
+ | %HAIL PURDUE (FIGHT SONG) | ||
− | == SOUND | + | clear |
+ | clc | ||
+ | |||
+ | %NOTES AND THEIR FREQUENCIES IN HERTZ | ||
+ | |||
+ | Eb = 311.13; | ||
+ | F = 349.23; | ||
+ | G = 392.00; | ||
+ | Ab = 415.30; | ||
+ | Bb = 466.16; | ||
+ | B = 493.88; | ||
+ | C5 = 523.25; | ||
+ | Db5 = 554.37; | ||
+ | |||
+ | dt = 0.00005; %change in time | ||
+ | |||
+ | %NOTE ORDER AND THEIR TIMES | ||
+ | sng = [Eb, F, G, Ab, Bb, C5, C5, Db5, Db5, Db5, Ab, Bb, B, C5]; | ||
+ | lngth = [1/2, 1/4, 1/4, 5/8, 1/8, 1/4, 1/4, 1/4, 1/8, 1/8, 1/4, 1/8, 1/8, 3/4]; | ||
+ | |||
+ | %TO PLAY AT NORMAL SPEED | ||
+ | |||
+ | lcv = 1; | ||
+ | t = 0:dt:lngth(lcv); | ||
+ | |||
+ | while lcv <= 14 | ||
+ | y = sin(2 * pi * sng(lcv) * t); | ||
+ | sound(y, 1/dt); | ||
+ | lcv = lcv + 1; | ||
+ | if lcv < 15 | ||
+ | t = 0:dt:lngth(lcv); | ||
+ | end | ||
+ | end | ||
+ | |||
+ | %TO PLAY AT 2x SPEED | ||
+ | |||
+ | lcv = 1; | ||
+ | lngth = lngth / 2; %DIVIDE LENGTH OF TIME BY 2 | ||
+ | t = 0:dt:lngth(lcv); | ||
+ | |||
+ | while lcv <= 14 | ||
+ | y = sin(2 * pi * sng(lcv) * t); | ||
+ | sound(y, 1/dt); | ||
+ | lcv = lcv + 1; | ||
+ | if lcv < 15 | ||
+ | t = 0:dt:lngth(lcv); | ||
+ | end | ||
+ | end | ||
+ | |||
+ | %TO RESCALE THE SONG FROM y(t) = x(2t) | ||
+ | |||
+ | sng = sng * 2 %DOUBLE THE FREQUENCY | ||
+ | lcv = 1; | ||
+ | t = 0:dt:lngth(lcv); | ||
+ | |||
+ | while lcv <= 14 | ||
+ | y = sin(2 * pi * sng(lcv) * t); | ||
+ | sound(y, 1/dt); | ||
+ | lcv = lcv + 1; | ||
+ | if lcv < 15 | ||
+ | t = 0:dt:lngth(lcv); | ||
+ | end | ||
+ | end | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | == SOUND FILES == | ||
+ | |||
+ | [[Media:hail_purdue1_ECE301Fall2008mboutin.wav]] | ||
+ | |||
+ | [[Media:hail_purdue2_ECE301Fall2008mboutin.wav]] | ||
+ | |||
+ | [[Media:hail_purdue3_ECE301Fall2008mboutin.wav]] |
Latest revision as of 15:07, 5 September 2008
%Daniel Barjum %ECE 301 HW 1.1 %HAIL PURDUE (FIGHT SONG) clear clc %NOTES AND THEIR FREQUENCIES IN HERTZ Eb = 311.13; F = 349.23; G = 392.00; Ab = 415.30; Bb = 466.16; B = 493.88; C5 = 523.25; Db5 = 554.37; dt = 0.00005; %change in time %NOTE ORDER AND THEIR TIMES sng = [Eb, F, G, Ab, Bb, C5, C5, Db5, Db5, Db5, Ab, Bb, B, C5]; lngth = [1/2, 1/4, 1/4, 5/8, 1/8, 1/4, 1/4, 1/4, 1/8, 1/8, 1/4, 1/8, 1/8, 3/4]; %TO PLAY AT NORMAL SPEED lcv = 1; t = 0:dt:lngth(lcv); while lcv <= 14 y = sin(2 * pi * sng(lcv) * t); sound(y, 1/dt); lcv = lcv + 1; if lcv < 15 t = 0:dt:lngth(lcv); end end %TO PLAY AT 2x SPEED lcv = 1; lngth = lngth / 2; %DIVIDE LENGTH OF TIME BY 2 t = 0:dt:lngth(lcv); while lcv <= 14 y = sin(2 * pi * sng(lcv) * t); sound(y, 1/dt); lcv = lcv + 1; if lcv < 15 t = 0:dt:lngth(lcv); end end %TO RESCALE THE SONG FROM y(t) = x(2t) sng = sng * 2 %DOUBLE THE FREQUENCY lcv = 1; t = 0:dt:lngth(lcv); while lcv <= 14 y = sin(2 * pi * sng(lcv) * t); sound(y, 1/dt); lcv = lcv + 1; if lcv < 15 t = 0:dt:lngth(lcv); end end
SOUND FILES
Media:hail_purdue1_ECE301Fall2008mboutin.wav