(→MATLAB CODE) |
|||
Line 1: | Line 1: | ||
== MATLAB CODE == | == MATLAB CODE == | ||
+ | %Daniel Barjum | ||
+ | %ECE 301 HW 1.1 | ||
+ | %HAIL PURDUE (FIGHT SONG) | ||
+ | |||
+ | %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]; | ||
+ | |||
+ | lcv = 1; | ||
+ | t = 0:dt:lngth(lcv); | ||
+ | |||
+ | while lcv < 14 | ||
+ | y = sin(2 * pi * sng(lcv) * t); | ||
+ | sound(y, 1/dt); | ||
+ | lcv = lcv + 1; | ||
+ | t = 0:dt:lngth(lcv); | ||
+ | end | ||
== SOUND FILE == | == SOUND FILE == |
Revision as of 15:23, 3 September 2008
MATLAB CODE
%Daniel Barjum %ECE 301 HW 1.1 %HAIL PURDUE (FIGHT SONG)
%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];
lcv = 1; t = 0:dt:lngth(lcv);
while lcv < 14 y = sin(2 * pi * sng(lcv) * t); sound(y, 1/dt); lcv = lcv + 1; t = 0:dt:lngth(lcv); end