(New page:  clc<br>clear all<br>close all %%%%%%%%%%%%%%%%%%%%%%% Part 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Part a<br>%Note Frequencies in Hzs B_flat = 2^(1/12)*440; % B Flat Frequency (H...)
 
Line 1: Line 1:
&nbsp;clc<br>clear all<br>close all
+
&nbsp;clc<br>clear all<br>close all  
  
%%%%%%%%%%%%%%%%%%%%%%% Part 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
%%%%%%%%%%%%%%%%%%%%%%% Part 1&nbsp;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  
%Part a<br>%Note Frequencies in Hzs
+
%Part a<br>%Note Frequencies in Hzs  
  
B_flat = 2^(1/12)*440; % B Flat Frequency (Hz)<br>C = 2^(3/12)*440; % C Frequency (Hz)<br>D_flat = 2^(6/12)*440; % D Flat Frequency (Hz)<br>G = 2^(-2/12)*440; % G Frequecny (Hz)
+
B_flat = 2^(1/12)*440;&nbsp;% B Flat Frequency (Hz)<br>C = 2^(3/12)*440;&nbsp;% C Frequency (Hz)<br>D_flat = 2^(6/12)*440;&nbsp;% D Flat Frequency (Hz)<br>G = 2^(-2/12)*440;&nbsp;% G Frequecny (Hz)  
  
% Length of each type of note<br>beats_per_min = 112; % The given timing of the song<br>beats_per_second = beats_per_min / 60; % The timing of the song in seconds<br>length_of_full_beat = 1 / beats_per_second; % the lenght of a measure of the song<br>delta = .0005; % Step size
+
% Length of each type of note<br>beats_per_min = 112;&nbsp;% The given timing of the song<br>beats_per_second = beats_per_min / 60;&nbsp;% The timing of the song in seconds<br>length_of_full_beat = 1 / beats_per_second;&nbsp;% the lenght of a measure of the song<br>delta = .0005;&nbsp;% Step size  
  
quarter_note = 0:delta:length_of_full_beat; %length of quarter note<br>half_note = 0:delta:(length_of_full_beat*2); %length of half note<br>eighth_note = 0:delta:(length_of_full_beat/2); % length of eight note<br>dotted_quarter_note = 0:delta:(length_of_full_beat*1.5); %length of dotted quarter note
+
quarter_note = 0:delta:length_of_full_beat;&nbsp;%length of quarter note<br>half_note = 0:delta:(length_of_full_beat*2);&nbsp;%length of half note<br>eighth_note = 0:delta:(length_of_full_beat/2);&nbsp;% length of eight note<br>dotted_quarter_note = 0:delta:(length_of_full_beat*1.5);&nbsp;%length of dotted quarter note  
  
song = [sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*D_flat*eighth_note),sin(2*pi*C*half_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*G*quarter_note)]; % Creates the Song using vectors<br>sound(song,1/delta)%plays orginal song
+
song = [sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*D_flat*eighth_note),sin(2*pi*C*half_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*G*quarter_note)];&nbsp;% Creates the Song using vectors<br>sound(song,1/delta)%plays orginal song  
  
wavwrite(song,1/delta,'Smoke on Water (Normal)'); %Writes song to file
+
wavwrite(song,1/delta,'Smoke on Water (Normal)');&nbsp;%Writes song to file  
  
%Part b <br>beats_per_min = 112*2; % The given timing of the song<br>beats_per_second = beats_per_min / 60; % The timing of the song in seconds<br>length_of_full_beat = 1 / beats_per_second; % the lenght of a measure of the song<br>delta = .0005; % Step size
+
%Part b <br>beats_per_min = 112*2;&nbsp;% The given timing of the song<br>beats_per_second = beats_per_min / 60;&nbsp;% The timing of the song in seconds<br>length_of_full_beat = 1 / beats_per_second;&nbsp;% the lenght of a measure of the song<br>delta = .0005;&nbsp;% Step size  
  
quarter_note = 0:delta:length_of_full_beat; %length of quarter note<br>half_note = 0:delta:(length_of_full_beat*2); %length of half note<br>eighth_note = 0:delta:(length_of_full_beat/2); % length of eight note<br>dotted_quarter_note = 0:delta:(length_of_full_beat*1.5); %length of dotted quarter note<br>song_fast = [sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*D_flat*eighth_note),sin(2*pi*C*half_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*G*quarter_note)]; % Creates the Song using vectors<br>sound(song_fast,1/delta)%Plays Song twice as fast<br>wavwrite(song_fast,1/delta,'Smoke on Water (Faster)'); %Writes song to file
+
quarter_note = 0:delta:length_of_full_beat;&nbsp;%length of quarter note<br>half_note = 0:delta:(length_of_full_beat*2);&nbsp;%length of half note<br>eighth_note = 0:delta:(length_of_full_beat/2);&nbsp;% length of eight note<br>dotted_quarter_note = 0:delta:(length_of_full_beat*1.5);&nbsp;%length of dotted quarter note<br>song_fast = [sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*D_flat*eighth_note),sin(2*pi*C*half_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*G*quarter_note)];&nbsp;% Creates the Song using vectors<br>sound(song_fast,1/delta)%Plays Song twice as fast<br>wavwrite(song_fast,1/delta,'Smoke on Water (Faster)');&nbsp;%Writes song to file  
  
%Part C<br>beats_per_min = 112; % The given timing of the song<br>beats_per_second = beats_per_min / 60; % The timing of the song in seconds<br>length_of_full_beat = 1 / beats_per_second; % the lenght of a measure of the song<br>delta = .0005; % Step size
+
%Part C<br>beats_per_min = 112;&nbsp;% The given timing of the song<br>beats_per_second = beats_per_min / 60;&nbsp;% The timing of the song in seconds<br>length_of_full_beat = 1 / beats_per_second;&nbsp;% the lenght of a measure of the song<br>delta = .0005;&nbsp;% Step size  
  
quarter_note = 0:delta:length_of_full_beat; %length of quarter note<br>half_note = 0:delta:(length_of_full_beat*2); %length of half note<br>eighth_note = 0:delta:(length_of_full_beat/2); % length of eight note<br>dotted_quarter_note = 0:delta:(length_of_full_beat*1.5); %length of dotted quarter note
+
quarter_note = 0:delta:length_of_full_beat;&nbsp;%length of quarter note<br>half_note = 0:delta:(length_of_full_beat*2);&nbsp;%length of half note<br>eighth_note = 0:delta:(length_of_full_beat/2);&nbsp;% length of eight note<br>dotted_quarter_note = 0:delta:(length_of_full_beat*1.5);&nbsp;%length of dotted quarter note  
  
song_transformed = [sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*D_flat*eighth_note),sin(2*pi*C*half_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*G*quarter_note)]; % Creates the Song using vectors<br>sound(song_transformed,2/delta)%Plays Song transformes
+
song_transformed = [sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*D_flat*eighth_note),sin(2*pi*C*half_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*G*quarter_note)];&nbsp;% Creates the Song using vectors<br>sound(song_transformed,2/delta)%Plays Song transformes  
  
wavwrite(song_transformed,2/delta,'Smoke on Water (Transformed)'); %Writes song to file
+
wavwrite(song_transformed,2/delta,'Smoke on Water (Transformed)');&nbsp;%Writes song to file  
  
%%%%%%%%%%%%%%%%%%%% Part 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
%%%%%%%%%%%%%%%%%%%% Part 2&nbsp;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  
  
[The_Beatles,Fs] = wavread('Beatles.wav');%Reads the song from the file<br>sound(The_Beatles,Fs) % Plays the song<br>The_Beatles_reversed = flipud(The_Beatles); % flips the song file<br>pause(30) %pauses the songs so they dont overlap<br>sound(The_Beatles_reversed,Fs) % Plays the new song<br>wavwrite(The_Beatles_reversed,Fs,'The Beatles (reversed)') %writes the new song to a file
+
[The_Beatles,Fs] = wavread('Beatles.wav');%Reads the song from the file<br>sound(The_Beatles,Fs)&nbsp;% Plays the song<br>The_Beatles_reversed = flipud(The_Beatles);&nbsp;% flips the song file<br>pause(30)&nbsp;%pauses the songs so they dont overlap<br>sound(The_Beatles_reversed,Fs)&nbsp;% Plays the new song<br>wavwrite(The_Beatles_reversed,Fs,'The Beatles (reversed)')&nbsp;%writes the new song to a file  
  
% The normal Song says 'number nine' over and over again<br>% The reversed Song Says "let me on the money"
+
% The normal Song says 'number nine' over and over again<br>% The reversed Song Says "let me on the money"  
 +
 
 +
<br>

Revision as of 14:10, 18 January 2011

 clc
clear all
close all

%%%%%%%%%%%%%%%%%%%%%%% Part 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Part a
%Note Frequencies in Hzs

B_flat = 2^(1/12)*440; % B Flat Frequency (Hz)
C = 2^(3/12)*440; % C Frequency (Hz)
D_flat = 2^(6/12)*440; % D Flat Frequency (Hz)
G = 2^(-2/12)*440; % G Frequecny (Hz)

% Length of each type of note
beats_per_min = 112; % The given timing of the song
beats_per_second = beats_per_min / 60; % The timing of the song in seconds
length_of_full_beat = 1 / beats_per_second; % the lenght of a measure of the song
delta = .0005; % Step size

quarter_note = 0:delta:length_of_full_beat; %length of quarter note
half_note = 0:delta:(length_of_full_beat*2); %length of half note
eighth_note = 0:delta:(length_of_full_beat/2); % length of eight note
dotted_quarter_note = 0:delta:(length_of_full_beat*1.5); %length of dotted quarter note

song = [sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*D_flat*eighth_note),sin(2*pi*C*half_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*G*quarter_note)]; % Creates the Song using vectors
sound(song,1/delta)%plays orginal song

wavwrite(song,1/delta,'Smoke on Water (Normal)'); %Writes song to file

%Part b
beats_per_min = 112*2; % The given timing of the song
beats_per_second = beats_per_min / 60; % The timing of the song in seconds
length_of_full_beat = 1 / beats_per_second; % the lenght of a measure of the song
delta = .0005; % Step size

quarter_note = 0:delta:length_of_full_beat; %length of quarter note
half_note = 0:delta:(length_of_full_beat*2); %length of half note
eighth_note = 0:delta:(length_of_full_beat/2); % length of eight note
dotted_quarter_note = 0:delta:(length_of_full_beat*1.5); %length of dotted quarter note
song_fast = [sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*D_flat*eighth_note),sin(2*pi*C*half_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*G*quarter_note)]; % Creates the Song using vectors
sound(song_fast,1/delta)%Plays Song twice as fast
wavwrite(song_fast,1/delta,'Smoke on Water (Faster)'); %Writes song to file

%Part C
beats_per_min = 112; % The given timing of the song
beats_per_second = beats_per_min / 60; % The timing of the song in seconds
length_of_full_beat = 1 / beats_per_second; % the lenght of a measure of the song
delta = .0005; % Step size

quarter_note = 0:delta:length_of_full_beat; %length of quarter note
half_note = 0:delta:(length_of_full_beat*2); %length of half note
eighth_note = 0:delta:(length_of_full_beat/2); % length of eight note
dotted_quarter_note = 0:delta:(length_of_full_beat*1.5); %length of dotted quarter note

song_transformed = [sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*D_flat*eighth_note),sin(2*pi*C*half_note),sin(2*pi*G*quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*C*dotted_quarter_note),sin(2*pi*B_flat*quarter_note),sin(2*pi*G*quarter_note)]; % Creates the Song using vectors
sound(song_transformed,2/delta)%Plays Song transformes

wavwrite(song_transformed,2/delta,'Smoke on Water (Transformed)'); %Writes song to file

%%%%%%%%%%%%%%%%%%%% Part 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[The_Beatles,Fs] = wavread('Beatles.wav');%Reads the song from the file
sound(The_Beatles,Fs) % Plays the song
The_Beatles_reversed = flipud(The_Beatles); % flips the song file
pause(30) %pauses the songs so they dont overlap
sound(The_Beatles_reversed,Fs) % Plays the new song
wavwrite(The_Beatles_reversed,Fs,'The Beatles (reversed)') %writes the new song to a file

% The normal Song says 'number nine' over and over again
% The reversed Song Says "let me on the money"


Alumni Liaison

ECE462 Survivor

Seraj Dosenbach