%Jitbhat Patmastana
%ECE301 Spring 2011 Homework 01


%PART 1
%Set duration of notes
delta = 0.00005;
beat_norm = 60/112;
beat_fast = beat_norm/2;

%Note lengths for 112bpm tempo
Q = 0:delta:beat_norm;
E = 0:delta:beat_norm/2;
DQ = 0:delta:beat_norm*1.5;
H = 0:delta:beat_norm*2;

%Note lengths for 224bpm tempo ('f' for fast)
Qf = 0:delta:beat_fast;
Ef= 0:delta:beat_fast/2;
DQf = 0:delta:beat_fast*1.5;
Hf = 0:delta:beat_fast*2;

%Frequencies of notes for normal pitch
fA = 440;
fBF = (2^(1/12))*fA;
fC = (2^(3/12))*fA;
fDF = (2^(4/12))*fA;
fG = (2^(-2/12))*fA;

%Frequencies of notes for high pitch ('h for high')
fAh = 440*2;
fBFh = (2^(1/12))*fAh;
fCh = (2^(3/12))*fAh;
fDFh = (2^(4/12))*fAh;
fGh = (2^(-2/12))*fAh;

x = 2*pi;

%Tunes for 112bpm tempo
QG = sin(x*fG*Q);
QBF = sin(x*fBF*Q);
DQC = sin(x*fC*DQ);
EDF = sin(x*fDF*E);
HC = sin(x*fC*H);

%Tunes for 224bpm tempo
QGf = sin(x*fG*Qf);
QBFf = sin(x*fBF*Qf);
DQCf = sin(x*fC*DQf);
EDFf = sin(x*fDF*Ef);
HCf = sin(x*fC*Hf);

%Tunes for 112bpm tempo high pitch
QGh = sin(x*fGh*Q);
QBFh = sin(x*fBFh*Q);
DQCh = sin(x*fCh*DQ);
EDFh = sin(x*fDFh*E);
HCh = sin(x*fCh*H);

%Compile song
smoke_norm = [QG, QBF, DQC, QG, QBF, EDF, HC, QG, QBF, DQC, QBF, QG];
smoke_fast = [QGf, QBFf, DQCf, QGf, QBFf, EDFf, HCf, QGf, QBFf, DQCf, QBFf, QGf];
smoke_high = [QGh, QBFh, DQCh, QGh, QBFh, EDFh, HCh, QGh, QBFh, DQCh, QBFh, QGh];

%Play song (3 variations)
sound(smoke_norm,1/delta); %normal speed normal pitch
pause(3);
sound(smoke_fast,1/delta); %double speed normal pitch
pause(3);
sound(smoke_high,1/delta); %normal speed higher pitch
pause(3);

%Create WAV files
wavwrite(smoke_norm,1/delta,'part1_A');
wavwrite(smoke_fast,1/delta,'part1_B');
wavwrite(smoke_high,1/delta,'part1_C');

%Part 2
[beatles, Fs] = wavread('Beatles.wav'); %Load sound file to "beatles"
reversed = flipud(beatles); %Reverse signal stored in "beatles"
sound(reversed,Fs); %Played reversed signal
wavwrite(reversed,Fs,'part2'); %Create WAV file

%Sounds much like "let me on dead man"

File:Part1 A.wav

File:Part1 B.wav

File:Part1 C.wav

File:Part2.wav

Alumni Liaison

Sees the importance of signal filtering in medical imaging

Dhruv Lamba, BSEE2010