(→Playing Music - MATLAB Code) |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
%Declarations | %Declarations | ||
delta=0.00005; | delta=0.00005; | ||
− | finish=0.4 | + | finish=0.4; |
− | + | ||
A = 220; | A = 220; | ||
B = 246.942; | B = 246.942; | ||
Line 17: | Line 16: | ||
Gb = 369.994; | Gb = 369.994; | ||
G = 391.995; | G = 391.995; | ||
− | + | sNotes = [A, B, Db, D, E, Gb, Gb, G, G, G, D, E, F, Gb ]; | |
− | + | ||
t = 0:delta:finish; | t = 0:delta:finish; | ||
− | for | + | for T = 1 : length(sNotes) |
− | + | notes = sin(2 * pi * t * sNotes(T)); | |
− | sound( | + | sound(notes, 1/delta); |
end | end | ||
+ | wavwrite(notes,1/delta,32,'Naman_hail_purdue1.wav'); | ||
pause(1); | pause(1); | ||
+ | %Part 2 | ||
t = 0:delta:finish/2; | t = 0:delta:finish/2; | ||
− | for T = 1 : length( | + | for T = 1 : length(sNotes) |
− | + | notes = sin(2 * pi * t * sNotes(T)); | |
− | sound( | + | sound(notes, 1/delta); |
end | end | ||
+ | wavwrite(notes,1/delta,32,'Naman_hail_purdue2.wav'); | ||
pause(1); | pause(1); | ||
+ | %Part 3 | ||
t = 0:delta:finish; | t = 0:delta:finish; | ||
− | + | f or T = 1 : length(sNotes) | |
− | + | notes = sin(4 * pi * t * sNotes(T)); | |
− | sound( | + | sound(notes, 1/delta); |
end | end | ||
+ | wavwrite(notes,1/delta,32,'Naman_hail_purdue3.wav'); | ||
+ | |||
+ | |||
+ | ==Files== | ||
+ | [[Media: Naman_hail_purdue1_ECE301Fall2008mboutin.wav]], | ||
+ | [[Media: Naman_hail_purdue2_ECE301Fall2008mboutin.wav]], | ||
+ | [[Media: Naman_hail_purdue3_ECE301Fall2008mboutin.wav]] | ||
+ | |||
+ | These files play the last note. I know why that is happening. I just don't know how to get the full thing. |
Latest revision as of 12:24, 5 September 2008
Playing Music - MATLAB Code
% Naman Chopra % ECE 301 %Initializing clear clc %Declarations delta=0.00005; finish=0.4; A = 220; B = 246.942; Db = 277.183; D = 293.665; E = 329.628; F = 349.228; Gb = 369.994; G = 391.995; sNotes = [A, B, Db, D, E, Gb, Gb, G, G, G, D, E, F, Gb ]; t = 0:delta:finish; for T = 1 : length(sNotes) notes = sin(2 * pi * t * sNotes(T)); sound(notes, 1/delta); end wavwrite(notes,1/delta,32,'Naman_hail_purdue1.wav'); pause(1); %Part 2 t = 0:delta:finish/2; for T = 1 : length(sNotes) notes = sin(2 * pi * t * sNotes(T)); sound(notes, 1/delta); end wavwrite(notes,1/delta,32,'Naman_hail_purdue2.wav'); pause(1); %Part 3 t = 0:delta:finish; f or T = 1 : length(sNotes) notes = sin(4 * pi * t * sNotes(T)); sound(notes, 1/delta); end wavwrite(notes,1/delta,32,'Naman_hail_purdue3.wav');
Files
Media: Naman_hail_purdue1_ECE301Fall2008mboutin.wav, Media: Naman_hail_purdue2_ECE301Fall2008mboutin.wav, Media: Naman_hail_purdue3_ECE301Fall2008mboutin.wav
These files play the last note. I know why that is happening. I just don't know how to get the full thing.