(New page: %% MATLAB CODE %%) |
|||
Line 1: | Line 1: | ||
− | %% | + | == Matlab Code == |
+ | % Homework 1.1 Hail Purdue | ||
+ | %David Record | ||
+ | %September 3rd 2008 | ||
+ | |||
+ | %%Song Notes and Lyrics: | ||
+ | %%http://www.purdue.edu/bands/media/Sounds/aamb/Hail%20Purdue%20Piano%20Sheet.pdf | ||
+ | |||
+ | %Lyrics | ||
+ | %Hail, to Old Purdue, All hail to our gold and black! | ||
+ | |||
+ | %Notes: | ||
+ | %E, F, G, A_, B_, C5, D5_, B | ||
+ | |||
+ | %Corresponding Frequencies: http://www.phy.mtu.edu/~suits/notefreqs.html | ||
+ | E = 311.13; %HZ | ||
+ | F = 349.23; %HZ | ||
+ | G = 392.00; %HZ | ||
+ | A_ = 415.30; %HZ | ||
+ | B_ = 466.16; %HZ | ||
+ | C5 = 523.25; %HZ | ||
+ | D5_ = 554.37; %HZ | ||
+ | B = 493.3; %HZ | ||
+ | |||
+ | %Durations | ||
+ | delta = 0.00005; %As defined in class | ||
+ | quarter = .25; %Quarter Note | ||
+ | half = .5; %Half Note | ||
+ | whole = 1; %Whole Note | ||
+ | eigth = .125; %Eighth Note | ||
+ | |||
+ | notes = [E, F, G, A_, B_, C5, C5, D5_, D5_, D5_, A_, B_, B, C5]; | ||
+ | durations = [half, quarter, quarter, (quarter+eighth), eighth, quarter, quarter, quarter, eighth, eighth, quarter, eigth, eigth, (half+quarter) ]; | ||
+ | |||
+ | |||
+ | x=1; | ||
+ | for counter = 1: length(notes) | ||
+ | t = 0:delta:durations(counter); | ||
+ | y = sin(2*pi*notes(counter)*t); | ||
+ | sound (y, 1/delta); | ||
+ | |||
+ | end |
Revision as of 15:25, 3 September 2008
Matlab Code
% Homework 1.1 Hail Purdue %David Record %September 3rd 2008
%%Song Notes and Lyrics: %%http://www.purdue.edu/bands/media/Sounds/aamb/Hail%20Purdue%20Piano%20Sheet.pdf
%Lyrics %Hail, to Old Purdue, All hail to our gold and black!
%Notes: %E, F, G, A_, B_, C5, D5_, B
%Corresponding Frequencies: http://www.phy.mtu.edu/~suits/notefreqs.html E = 311.13; %HZ F = 349.23; %HZ G = 392.00; %HZ A_ = 415.30; %HZ B_ = 466.16; %HZ C5 = 523.25; %HZ D5_ = 554.37; %HZ B = 493.3; %HZ
%Durations delta = 0.00005; %As defined in class quarter = .25; %Quarter Note half = .5; %Half Note whole = 1; %Whole Note eigth = .125; %Eighth Note
notes = [E, F, G, A_, B_, C5, C5, D5_, D5_, D5_, A_, B_, B, C5]; durations = [half, quarter, quarter, (quarter+eighth), eighth, quarter, quarter, quarter, eighth, eighth, quarter, eigth, eigth, (half+quarter) ];
x=1; for counter = 1: length(notes) t = 0:delta:durations(counter); y = sin(2*pi*notes(counter)*t); sound (y, 1/delta);
end