Line 1: Line 1:
 +
% Author: Matt Mabry % Class: ECE 301 % Assignment: HW 1 % Date: January 19, 2011
  
% Author: Matt Mabry
+
% Part 1 % Description: Play the melody "Smoke on the Water" in three ways. One: in % the original tune. Two: twice as fast. Three: Rescale the tune
% Class: ECE 301
+
% Assignment: HW 1
+
% Date: January 19, 2011
+
  
% Part 1
+
clear all; clc;
% Description: Play the melody "Smoke on the Water" in three ways. One: in
+
% the original tune. Two: twice as fast. Three: Rescale the tune
+
  
clear all;
+
bps = 112/60; %beats per second bt = bps^(-1); %time length of each beat
clc;  
+
  
bps = 112/60; %beats per second
+
delt = 5e-5; %Time span between each beat  
bt = bps^(-1); %time length of each beat
+
 
+
delt = 5e-5; %Time span between each beat  
+
  
 
% Part a: "Smoke on the Water" in normal speed  
 
% Part a: "Smoke on the Water" in normal speed  
  
% Notes in "Smoke on the Water"
+
% Notes in "Smoke on the Water" half = 0:delt:(bt*2); quarter = 0:delt:bt; dotquarter = 0:delt:(bt*3/2); eighth = 0:delt:(bt/2);  
half = 0:delt:(bt*2);
+
quarter = 0:delt:bt;
+
dotquarter = 0:delt:(bt*3/2);
+
eighth = 0:delt:(bt/2);  
+
  
%Note Used
+
%Note Used hc = sin(2*pi*(2^(1/4)*440)*half); dqc = sin(2*pi*(2^(1/4)*440)*dotquarter); hg = sin(2*pi*(2^(-1/6)*440)*half); qg = sin(2*pi*(2^(-1/6)*440)*quarter); qbf = sin(2*pi*(2^(1/12)*440)*quarter); edf = sin(2*pi*(2^(1/3)*440)*eighth);  
hc = sin(2*pi*(2^(1/4)*440)*half);
+
dqc = sin(2*pi*(2^(1/4)*440)*dotquarter);
+
hg = sin(2*pi*(2^(-1/6)*440)*half);
+
qg = sin(2*pi*(2^(-1/6)*440)*quarter);
+
qbf = sin(2*pi*(2^(1/12)*440)*quarter);
+
edf = sin(2*pi*(2^(1/3)*440)*eighth);  
+
  
% Construction of Normal Song
+
% Construction of Normal Song Smoke = [qg,qbf,dqc,qg,qbf,edf,hc,qg,qbf,dqc,qbf,qg]; sound(Smoke,1/delt) wavwrite(Smoke, 1/delt, 32, 'Smoke_normal.wav'); pause(6)  
Smoke = [qg,qbf,dqc,qg,qbf,edf,hc,qg,qbf,dqc,qbf,qg];
+
sound(Smoke,1/delt)
+
wavwrite(Smoke, 1/delt, 32, 'Smoke_normal.wav');
+
pause(6)  
+
  
 
% Part b: "Smoke on the Water" in faster speed  
 
% Part b: "Smoke on the Water" in faster speed  
  
% Notes in "Smoke on the Water"
+
% Notes in "Smoke on the Water" half = 0:delt:bt; quarter = 0:delt:(bt/2); dotquarter = 0:delt:(bt*3/4); eighth = 0:delt:(bt/4);  
half = 0:delt:bt;
+
quarter = 0:delt:(bt/2);
+
dotquarter = 0:delt:(bt*3/4);
+
eighth = 0:delt:(bt/4);  
+
  
%Note Used
+
%Note Used hc = sin(2*pi*(2^(1/4)*440)*half); dqc = sin(2*pi*(2^(1/4)*440)*dotquarter); hg = sin(2*pi*(2^(-1/6)*440)*half); qg = sin(2*pi*(2^(-1/6)*440)*quarter); qbf = sin(2*pi*(2^(1/12)*440)*quarter); edf = sin(2*pi*(2^(1/3)*440)*eighth);  
hc = sin(2*pi*(2^(1/4)*440)*half);
+
dqc = sin(2*pi*(2^(1/4)*440)*dotquarter);
+
hg = sin(2*pi*(2^(-1/6)*440)*half);
+
qg = sin(2*pi*(2^(-1/6)*440)*quarter);
+
qbf = sin(2*pi*(2^(1/12)*440)*quarter);
+
edf = sin(2*pi*(2^(1/3)*440)*eighth);  
+
  
% Construction of Faster Song
+
% Construction of Faster Song Smoke_Fast = [qg,qbf,dqc,qg,qbf,edf,hc,qg,qbf,dqc,qbf,qg]; sound(Smoke_Fast,1/delt) wavwrite(Smoke_Fast, 1/delt, 32, 'Smoke_faster.wav'); pause(6)  
Smoke_Fast = [qg,qbf,dqc,qg,qbf,edf,hc,qg,qbf,dqc,qbf,qg];
+
sound(Smoke_Fast,1/delt)
+
wavwrite(Smoke_Fast, 1/delt, 32, 'Smoke_faster.wav');
+
pause(6)  
+
  
 
% Part c: "Smoke on the Water" transformation to higher pitch  
 
% Part c: "Smoke on the Water" transformation to higher pitch  
  
% Notes in "Smoke on the Water"
+
% Notes in "Smoke on the Water" half = 0:delt:(bt*2); quarter = 0:delt:bt; dotquarter = 0:delt:(bt*3/2); eighth = 0:delt:(bt/2);  
half = 0:delt:(bt*2);
+
quarter = 0:delt:bt;
+
dotquarter = 0:delt:(bt*3/2);
+
eighth = 0:delt:(bt/2);  
+
  
%Note Used
+
%Note Used hc = sin(4*pi*(2^(1/4)*440)*half); dqc = sin(4*pi*(2^(1/4)*440)*dotquarter); hg = sin(4*pi*(2^(-1/6)*440)*half); qg = sin(4*pi*(2^(-1/6)*440)*quarter); qbf = sin(4*pi*(2^(1/12)*440)*quarter); edf = sin(4*pi*(2^(1/3)*440)*eighth);  
hc = sin(4*pi*(2^(1/4)*440)*half);
+
dqc = sin(4*pi*(2^(1/4)*440)*dotquarter);
+
hg = sin(4*pi*(2^(-1/6)*440)*half);
+
qg = sin(4*pi*(2^(-1/6)*440)*quarter);
+
qbf = sin(4*pi*(2^(1/12)*440)*quarter);
+
edf = sin(4*pi*(2^(1/3)*440)*eighth);  
+
  
% Construction of Transformed Song
+
% Construction of Transformed Song Smoke_Pitch = [qg,qbf,dqc,qg,qbf,edf,hc,qg,qbf,dqc,qbf,qg]; sound(Smoke_Pitch,1/delt) wavwrite(Smoke_Pitch, 1/delt, 32, 'Smoke_transformation.wav'); pause(6)  
Smoke_Pitch = [qg,qbf,dqc,qg,qbf,edf,hc,qg,qbf,dqc,qbf,qg];
+
sound(Smoke_Pitch,1/delt)
+
wavwrite(Smoke_Pitch, 1/delt, 32, 'Smoke_transformation.wav');
+
pause(6)
+
  
  
  
 +
% Part 2<br>% Description: Reverse the Beatles song Number 9 and decode 'hidden message'
  
 +
[song, fs, bits] = wavread('Beatles.wav');<br>sound(song, fs, bits)
  
 +
pause(5)
  
% Part 2<br>% Description: Reverse the Beatles song Number 9 and decode 'hidden<br>% message'
+
%When played normally, it repeats the saying 'number 9'
 
+
[song, fs, bits] = wavread('Beatles.wav');<br>sound(song, fs, bits)
+
 
+
pause(5)<br>%When played normally, it repeats the saying 'number 9'
+
  
 
%Now I reverse the sound
 
%Now I reverse the sound
  
reverse = flipud(song);<br>sound(song, fs, bits)
+
reverse = flipud(song);<br>sound(reverse, fs, bits)<br>wavwrite(reverse,fs,32,'Reverse_Beatles.wav');<br>pause(5)
 
+
% To me it sounds like gibberish, but it is notoriously known for saying<br>% "turn me on dead man"
+
 
+
 
+
 
+
  
 +
% To me it sounds like gibberish, but it is notoriously known for saying&lt;br&gt;% "turn me on dead man"
  
 +
<br>
  
 +
[[Media:Smoke_normal.wav]]
  
[[Media:Smoke_normal.wav]]
+
[[Media:Smoke_faster.wav]]  
  
[[Media:Smoke_faster.wav]]
+
[[Media:Smoke_transformation.wav]]  
  
[[Media:Smoke_transformation.wav]]
+
[[Media:Reverse_Beatles.wav]]

Latest revision as of 09:06, 19 January 2011

% Author: Matt Mabry % Class: ECE 301 % Assignment: HW 1 % Date: January 19, 2011

% Part 1 % Description: Play the melody "Smoke on the Water" in three ways. One: in % the original tune. Two: twice as fast. Three: Rescale the tune

clear all; clc;

bps = 112/60; %beats per second bt = bps^(-1); %time length of each beat

delt = 5e-5; %Time span between each beat

% Part a: "Smoke on the Water" in normal speed

% Notes in "Smoke on the Water" half = 0:delt:(bt*2); quarter = 0:delt:bt; dotquarter = 0:delt:(bt*3/2); eighth = 0:delt:(bt/2);

%Note Used hc = sin(2*pi*(2^(1/4)*440)*half); dqc = sin(2*pi*(2^(1/4)*440)*dotquarter); hg = sin(2*pi*(2^(-1/6)*440)*half); qg = sin(2*pi*(2^(-1/6)*440)*quarter); qbf = sin(2*pi*(2^(1/12)*440)*quarter); edf = sin(2*pi*(2^(1/3)*440)*eighth);

% Construction of Normal Song Smoke = [qg,qbf,dqc,qg,qbf,edf,hc,qg,qbf,dqc,qbf,qg]; sound(Smoke,1/delt) wavwrite(Smoke, 1/delt, 32, 'Smoke_normal.wav'); pause(6)

% Part b: "Smoke on the Water" in faster speed

% Notes in "Smoke on the Water" half = 0:delt:bt; quarter = 0:delt:(bt/2); dotquarter = 0:delt:(bt*3/4); eighth = 0:delt:(bt/4);

%Note Used hc = sin(2*pi*(2^(1/4)*440)*half); dqc = sin(2*pi*(2^(1/4)*440)*dotquarter); hg = sin(2*pi*(2^(-1/6)*440)*half); qg = sin(2*pi*(2^(-1/6)*440)*quarter); qbf = sin(2*pi*(2^(1/12)*440)*quarter); edf = sin(2*pi*(2^(1/3)*440)*eighth);

% Construction of Faster Song Smoke_Fast = [qg,qbf,dqc,qg,qbf,edf,hc,qg,qbf,dqc,qbf,qg]; sound(Smoke_Fast,1/delt) wavwrite(Smoke_Fast, 1/delt, 32, 'Smoke_faster.wav'); pause(6)

% Part c: "Smoke on the Water" transformation to higher pitch

% Notes in "Smoke on the Water" half = 0:delt:(bt*2); quarter = 0:delt:bt; dotquarter = 0:delt:(bt*3/2); eighth = 0:delt:(bt/2);

%Note Used hc = sin(4*pi*(2^(1/4)*440)*half); dqc = sin(4*pi*(2^(1/4)*440)*dotquarter); hg = sin(4*pi*(2^(-1/6)*440)*half); qg = sin(4*pi*(2^(-1/6)*440)*quarter); qbf = sin(4*pi*(2^(1/12)*440)*quarter); edf = sin(4*pi*(2^(1/3)*440)*eighth);

% Construction of Transformed Song Smoke_Pitch = [qg,qbf,dqc,qg,qbf,edf,hc,qg,qbf,dqc,qbf,qg]; sound(Smoke_Pitch,1/delt) wavwrite(Smoke_Pitch, 1/delt, 32, 'Smoke_transformation.wav'); pause(6)


% Part 2
% Description: Reverse the Beatles song Number 9 and decode 'hidden message'

[song, fs, bits] = wavread('Beatles.wav');
sound(song, fs, bits)

pause(5)

%When played normally, it repeats the saying 'number 9'

%Now I reverse the sound

reverse = flipud(song);
sound(reverse, fs, bits)
wavwrite(reverse,fs,32,'Reverse_Beatles.wav');
pause(5)

% To me it sounds like gibberish, but it is notoriously known for saying<br>% "turn me on dead man"


Media:Smoke_normal.wav

Media:Smoke_faster.wav

Media:Smoke_transformation.wav

Media:Reverse_Beatles.wav

Alumni Liaison

Sees the importance of signal filtering in medical imaging

Dhruv Lamba, BSEE2010