(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...)
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
clc
 
clc
 +
 
clear
 
clear
 +
 
% Part 1
 
% 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
+
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
 
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
 
  
q = 0:delta:bps ; % length of a quarter note in terms of tempo
+
rest= 0:delta:3*bps; 
h = 0:delta:2*bps  ; % length of a half note in terms of tempo
+
% there is a three beat rest at the end of the song
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  
+
 
 +
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
 
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
+
%%changes the pitch by multiplying the A4 frequency by two
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  ;
G_note = 2^(-2/12)*A_note  ;%Pitch frequency for G
+
%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   
+
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 
 +
 
 +
 
 +
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
+
 
 +
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
  
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];
 
smoke_song = [Gq,Bfq,Cdq,Gq,Bfq,Dfe,Ch,Gq,Bfq,Cdq,Bfq,Gq,rest];
 +
  
 
if x==1
 
if x==1
Line 52: Line 126:
 
wavwrite(smoke_song,1/delta, 'normal_smoke_on_the_water');
 
wavwrite(smoke_song,1/delta, 'normal_smoke_on_the_water');
 
elseif x==2
 
elseif x==2
 +
 +
 
sound(smoke_song, 1/delta);
 
sound(smoke_song, 1/delta);
 +
 
wavwrite(smoke_song,1/delta, 'fast_smoke_on_the_water');
 
wavwrite(smoke_song,1/delta, 'fast_smoke_on_the_water');
 
else
 
else
 +
 +
 
sound(smoke_song, 1/delta);
 
sound(smoke_song, 1/delta);
 +
 
wavwrite(smoke_song,1/delta, 'highpitch_smoke_on_the_water');
 
wavwrite(smoke_song,1/delta, 'highpitch_smoke_on_the_water');
 +
  
 
end
 
end
Line 68: Line 149:
 
[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

Latest revision as of 08:18, 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 ; %%changes the pitch by multiplying the A4 frequency by two


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


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

ECE462 Survivor

Seraj Dosenbach