(New page: 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...)
 
Line 2: Line 2:
 
clear
 
clear
 
% Part 1
 
% Part 1
  x = 1; %initializes counter for iterations
+
  x = 1;  
for i = 1:1:3  %% a loop to perform three iterations for parts a,b,c
+
%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
  
delta = 0.00005 ;  %sampling rate
 
 
if x == 2
 
if x == 2
    bpm = 2*112  ; %beats per minute for parts a and c
+
  bpm = 2*112  ;  
 +
%beats per minute for parts a and c
 +
 
 
else
 
else
     bpm = 112 ; %beats per minute for part b
+
     bpm = 112 ;  
 +
%beats per minute for part b
 +
 
 
end
 
end
 +
 
bps = 60/bpm ; %beats per second
 
bps = 60/bpm ; %beats per second
  
rest= 0:delta:3*bps;  % there is a three beat rest at the end of the song
+
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
+
q = 0:delta:bps ;  
h = 0:delta:2*bps  ; % length of a half note in terms of tempo
+
% length of a quarter 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  
+
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
 
if x==3
A_note = 2*440 ;  %Pitch frequency for A4
+
A_note = 2*440 ;   
G_note = 2^(-2/12)*A_note  ;%Pitch frequency for G
+
%Pitch frequency for A4
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
+
G_note = 2^(-2/12)*A_note ;
 +
%Pitch frequency for G
  
A_note = 440 ;  %Pitch frequency for A4
+
Bflat_note =  2^(1/12)*A_note  ;
G_note = 2^(-2/12)*A_note  ;%Pitch frequency for G
+
%Pitch frequency for B flat
Bflat_note =  2^(1/12)*A_note  ;%Pitch frequency for B flat
+
 
C_note = 2^(3/12)*A_note  ;%Pitch frequency for C
+
C_note = 2^(3/12)*A_note  ;
Dflat_note = 2^(4/12)*A_note  ;%Pitch frequency for D flat   
+
%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 two
 +
 
 +
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
 
end
  
  
Gq = sin(2*pi*G_note*q) ;  %% Standard function for quarter note, G pitch
+
Gq = sin(2*pi*G_note*q) ;   
Bfq = sin(2*pi*Bflat_note*q) ;  %% Standard function for quarter note, B flat pitch
+
%% Standard function for quarter note, G 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
+
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
  
  
Line 68: Line 112:
 
[song, fs] = wavread('Beatles.wav');
 
[song, fs] = wavread('Beatles.wav');
 
%Original clip says 'Number 9' repeatedly
 
%Original clip says 'Number 9' repeatedly
 +
 
reverse = flipud(song);
 
reverse = flipud(song);
sound(20*reverse,fs);  %% could not hear the song so had to amplify it
+
 
 +
sound(20*reverse,fs);   
 +
%% could not hear the song so had to amplify it
 +
 
 
wavwrite(reverse,fs,'reverse_Beatles')
 
wavwrite(reverse,fs,'reverse_Beatles')
 
%reversed clip sounds like 'Let me on, Desmond' repeatedly
 
%reversed clip sounds like 'Let me on, Desmond' repeatedly

Revision as of 09:15, 19 January 2011

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 two

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

Ph.D. on Applied Mathematics in Aug 2007. Involved on applications of image super-resolution to electron microscopy

Francisco Blanco-Silva