Revision as of 08:11, 19 January 2011 by Nfritz (Talk | contribs)

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

clc clear % Part 1

x = 1; %initializes counter for iterations

for i = 1:1:3  %% a loop to perform three iterations for parts a,b,c

delta = 0.00005 ;  %sampling rate if x == 2

   bpm = 2*112  ; %beats per minute for parts a and c

else

   bpm = 112 ; %beats per minute for part b

end bps = 60/bpm ; %beats per second

rest= 0:delta:3*bps;  % there is a three beat rest at the end of the song

q = 0:delta:bps ; % length of a quarter note in terms of tempo h = 0:delta:2*bps  ; % length of a half note in terms of tempo e = 0:delta:0.5*bps  ; % length of an eighth note in terms of tempo dq = 0:delta:1.5*bps  ; % length of a dotted quarter note in terms of tempo

if x==3 A_note = 2*440 ;  %Pitch frequency for A4 G_note = 2^(-2/12)*A_note  ;%Pitch frequency for G Bflat_note = 2^(1/12)*A_note  ;%Pitch frequency for B flat C_note = 2^(3/12)*A_note  ;%Pitch frequency for C Dflat_note = 2^(4/12)*A_note  ;%Pitch frequency for D flat

else  %%changes the pitch by multiplying the A4 frequency by twosound

A_note = 440 ;  %Pitch frequency for A4 G_note = 2^(-2/12)*A_note  ;%Pitch frequency for G Bflat_note = 2^(1/12)*A_note  ;%Pitch frequency for B flat C_note = 2^(3/12)*A_note  ;%Pitch frequency for C Dflat_note = 2^(4/12)*A_note  ;%Pitch frequency for D flat

end


Gq = sin(2*pi*G_note*q) ;  %% Standard function for quarter note, G pitch Bfq = sin(2*pi*Bflat_note*q) ;  %% Standard function for quarter note, B flat pitch Ch = sin(2*pi*C_note*h) ;  %% Standard function for half note, C pitch Cdq = sin(2*pi*C_note*dq) ;  %% Standard function for dotted quarter note, C pitch

Dfe = sin(2*pi*Dflat_note*e) ;  %% Standard function for eighth note, D flat pitch


smoke_song = [Gq,Bfq,Cdq,Gq,Bfq,Dfe,Ch,Gq,Bfq,Cdq,Bfq,Gq,rest];

if x==1 sound(smoke_song, 1/delta); wavwrite(smoke_song,1/delta, 'normal_smoke_on_the_water'); elseif x==2 sound(smoke_song, 1/delta); wavwrite(smoke_song,1/delta, 'fast_smoke_on_the_water'); else sound(smoke_song, 1/delta); wavwrite(smoke_song,1/delta, 'highpitch_smoke_on_the_water');

end

x=x+1;

end


%%Part 2

[song, fs] = wavread('Beatles.wav'); %Original clip says 'Number 9' repeatedly reverse = flipud(song); sound(20*reverse,fs);  %% could not hear the song so had to amplify it wavwrite(reverse,fs,'reverse_Beatles') %reversed clip sounds like 'Let me on, Desmond' repeatedly

Media:normal_smoke_on_the_water.wav
Media:fast_smoke_on_the_water.wav
Media:highpitch_smoke_on_the_water.wav
Media:reverse_Beatles.wav

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood