Sound Files
Matlab code
%Steve Anderson %September 5, 2009 %ECE 301 Homework 1 %Hail purdue - Beginning of the song clear; clc; %Definitions of Note Frequencies A = 220; Bf = 233; B = 247; C = 262; Df = 277; D = 294; Ef = 311; E = 330; F = 349; G = 392; Af = 415; A2 = A *2; Bf2 = Bf * 2; B2 = B * 2; C2 = C * 2; Df2 = Df * 2; D2 = D * 2; Ef2 = Ef * 2; E2 = E * 2; F2 = F * 2; G2 = G * 2; Af2 = Af * 2; %length of each kind of note (assuming 180 beats per minute) Rest = 0; Q = 60/180; Ei = Q / 2; H = Q * 2; DQ = Q + Ei; DH = H + Q; %sampling frequency Delta = 0.00005; %array of notes in order of song Songnote = [Ef, F, G, Af2, Bf2, C2, C2, Df2, Df2, Df2, Af, Bf2, B2, C2, Rest, C2, C2, Bf2, Af2, Bf2, C2, C2, Bf2, F, G, Af2, G, F, Bf2]; %array of lengths of notes in order of song Notelength = [H, Q, Q, DQ, Ei, Q, Q, Q, Ei, Ei, Q, Ei, Ei, DH, Q, H, Q, Q, DQ, Ei, Q, Q, Q, Ei, Ei, Q, Ei, Ei, DH]; for i = 1:length(Notelength) t = 0:Delta:Notelength(i); normal = sin(2*pi*Songnote(i)*t); sound(normal, 1/Delta); end for i = 1:length(Notelength) t = 0:Delta:0.5*Notelength(i); twice = sin(2*pi*Songnote(i)*t); sound(normal, 1/Delta); end for i = 1:length(Notelength) t = 0:Delta:Notelength(i); partc = sin(2*2*pi*Songnote(i)*t); sound(normal, 1/Delta); end