Revision as of 16:44, 18 January 2011 by Jkohnert (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

delta = .00005;

% Beat bpm = 112;  %beat per minute beat_interval = 60/bpm;

% Notes quarter = 0:delta:beat_interval; eighth = 0:delta:(beat_interval/2); haft = 0:delta:(beat_interval*2); dot_qrtr = 0:delta:(beat_interval*1.5);

%Frequencies of Notes G = (2^(-2/12))*440; Bf = (2^(1/12))*440; C = (2^(3/12))*440; Df = (2^(4/12))*440;

%Note Sounds quarter_G = sin(2*pi*G*quarter); quarter_Bf = sin(2*pi*Bf*quarter); dot_qrtr_C = sin(2*pi*C*dot_qrtr); eighth_Df = sin(2*pi*Df*eighth); haft_C = sin(2*pi*C*haft); haft_G = sin(2*pi*G*haft);

%Note Array note_array = [quarter_G, quarter_Bf, dot_qrtr_C, quarter_G, quarter_Bf, eighth_Df, haft_C, quarter_G, quarter_Bf, dot_qrtr_C, quarter_Bf, quarter_G];

%Song on Regular Speed sound(note_array, 1/delta); wavwrite(note_array, 1/delta, '301_hw1_1A');

%Prob 1b -- Double Speed = half the beat interval beat_interval2 = (beat_interval / 2);

% Notes 2x Speed quarter2 = 0:delta:beat_interval2; eighth2 = 0:delta:(beat_interval2 / 2); haft2 = 0:delta:(beat_interval2 * 2); dot_qrtr2 = 0:delta:(beat_interval2 * 1.5);

%Note Sounds 2x Speed quarter_G2 = sin(2*pi*G*quarter2); quarter_Bf2 = sin(2*pi*Bf*quarter2); dot_qrtr_C2 = sin(2*pi*C*dot_qrtr2); eighth_Df2 = sin(2*pi*Df*eighth2); haft_C2 = sin(2*pi*C*haft2); haft_G2 = sin(2*pi*G*haft2);

%Note Array 2x Speed note_array2 = [quarter_G2 quarter_Bf2 dot_qrtr_C2 quarter_G2 quarter_Bf2 eighth_Df2 haft_C2 quarter_G2 quarter_Bf2 dot_qrtr_C2 quarter_Bf2 quarter_G2];

%Song on 2x Speed sound(note_array2, 1/delta); wavwrite(note_array2, 1/delta, '301_hw1_1B');

%Prob 1c -- Twice the pitch

%Note Sounds 2x Pitch quarter_G3 = sin(2*pi*G*quarter); quarter_Bf3 = sin(2*pi*Bf*quarter); dot_qrtr_C3 = sin(2*pi*C*dot_qrtr); eighth_Df3 = sin(2*pi*Df*eighth); haft_C3 = sin(2*pi*C*haft); haft_G3 = sin(2*pi*G*haft);

%Note Array 2x Pitch note_array3 = [quarter_G3 quarter_Bf3 dot_qrtr_C3 quarter_G3 quarter_Bf3 eighth_Df3 haft_C3 quarter_G3 quarter_Bf3 dot_qrtr_C3 quarter_Bf3 quarter_G3];

%Song on 2x Pitch sound(note_array3, 1/ delta); wavwrite(note_array3, 1/delta, '301_hw1_1C');

%Problem 2 %Read and play the original song [y, Fs] = wavread('Beatles.wav'); sound(y, Fs);

%Flip the song and save this version flip = flipud(y); sound(flip, Fs); wavwrite(flip, Fs, 'Beatles_flip');

% 1. Number 9 is repeated. % 2. It sounds mostly like gibberish but if I had to guess it ends in dead man.

Alumni Liaison

Have a piece of advice for Purdue students? Share it through Rhea!

Alumni Liaison