Line 57: | Line 57: | ||
sound(anthem, 1/Delta); | sound(anthem, 1/Delta); | ||
end | end | ||
− |
Latest revision as of 18:12, 4 September 2008
% link- NATIONAL ANTHEM OF INDIA [http://www.youtube.com/watch?v=r3TtgYuaVFk&feature=related] %Monil Goklani %September 5, 2008 %hw 1 % NATIONAL ANTHEM OF INDIA %Definitions of Note Frequencies A = 220; B = 247; C = 262; D = 294; E = 330; F = 349; G = 392; A2 = A *2; B2 = B * 2; C2 = C * 2; D2 = D * 2; E2 = E * 2; F2 = F * 2; G2 = G * 2; %THE FOLLOWING COMMANDS DEFINE THE LENTGH OF EACH NOTE ( I HAVE ASSUMED THE %SPEED AS 180 QUARTER NOTES PER MINUTE) Pause = 0; Q = 60/180;%quarter note HQ = Q / 2;%half quarter TH = (3*Q)/4;% 3/4th of a quarter H = Q * 2;%half note DH = H + Q; %3/4th note Delta = 0.00005; %sampling frequency % The following command defines the array of notes in the order to be % played notes = [C,D,E,E,E,E,E,E,E,E,E,E,D,E,F,E,E,E,D,D,D,C,C,C,Pause,... C,G,G,G,G,G,F,G,G,G,F,G,G,F,F,F,E,E,F,D,F,E,Pause,... E,E,E,E,E,D,G,G,G,F,F,E,E,E,D,D,D,D,D,C,Pause,... C,D,E,E,E,E,D,E,F,Pause,E,F,G,G,G,F,E,D,F,E,Pause... E,E,D,D,D,D,D,C,Pause,C2,B2,C2,B2,A2,B2,A2,B2,A2,C,C,D,D,E,E,D,E,F]; %The following command defines the array of the duration of the notes to be %played in the corresponding order duration=[Q,Q,Q,Q,Q,Q,HQ,H,Q,Q,TH,Q,Q,Q,H,Q,Q,Q,Q,Q,Q,TH,TH,H,HQ,... H,TH,TH,TH,H,Q,TH,TH,TH,TH,TH,H,DH,H,Q,Q,Q,H,TH,TH,TH,H,HQ,... H,TH,TH,TH,Q,Q,Q,Q,H,H,Q,H,Q,Q,TH,TH,TH,Q,TH,DH,HQ,... TH,TH,TH,TH,Q,Q,Q,TH,H,HQ,TH,TH,TH,TH,Q,TH,TH,Q,TH,H,HQ... H,H,TH,TH,TH,TH,Q,H,HQ,H,Q,DH,H,Q,DH,H,Q,DH,TH,TH,TH,TH,TH,TH,TH,TH,DH]; for n = 1:length(duration) t = 0:Delta:duration(n); anthem = sin(2*pi*notes(n)*t); sound(anthem, 1/Delta); end