%HW 1 ECE 301
%OLIVER REGELE
%PART 1
%%%%%%%%%Playing Smoke on the Water Normally%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Setting up the Initial Variables
timeofbeat = 1/(112/60); %Finding the time per beat using given bpm
delta = 0.0005; %Step size for the time
tbeat = 0:delta:timeofbeat; %Each Beat or quarter Note
ttwicebeat = 0:delta:2*timeofbeat; %Each Half Note
thalfbeat = 0:delta:1/2*timeofbeat; %Each Eighth Note
tdottedquarter =  0:delta:3/2*timeofbeat; %Each dotted quarter note

frequencyA4 = 440; %Frequency of the A note

Note1 = sin(2*pi*2^(-2/12)*frequencyA4*tbeat); %(G4)
Note2 = sin(2*pi*2^(1/12)*frequencyA4*tbeat); %(Bflat/Asharp)
Note3 = sin(2*pi*2^(3/12)*frequencyA4*tdottedquarter); %(C5)
Note4 = sin(2*pi*2^(-2/12)*frequencyA4*tbeat); %(G4) %Played for 2 ...

Note6 = sin(2*pi*2^(1/12)*frequencyA4*tbeat); %(Bflat/Asharp) 
Note7 = sin(2*pi*2^(4/12)*frequencyA4*thalfbeat); %(Dflat/Csharp)
Note8 = sin(2*pi*2^(3/12)*frequencyA4*ttwicebeat); %(C5 for halfbeat)

Note9 = sin(2*pi*2^(-2/12)*frequencyA4*tbeat); %(G4)
Note10 = sin(2*pi*2^(1/12)*frequencyA4*tbeat); %(Bflat/Asharp)
Note11 = sin(2*pi*2^(3/12)*frequencyA4*tdottedquarter); %C5
Note12 = sin(2*pi*2^(1/12)*frequencyA4*tbeat); % (Bflat/Asharp)...

Note14 = sin(2*pi*2^(-2/12)*frequencyA4*tbeat); % (G4)

Note15 = sin(2*pi*2^(-2/12)*0*ttwicebeat); %For the rest notes

SmokeontheWaterA = [Note1, Note2, Note3, Note4, Note6, Note7, Note8,...
    Note9, Note10, Note11, Note12, Note14, Note15]; %Setting up the Sound file
sound(SmokeontheWaterA, 1/delta); %Playing the Sound File

%%%%%%%%%%%%%%%Playing Smoke on the Water twice as fast%%%%%%%%%%%%%%%%%%%%

%To accomplish this one must simply redefine the time per beat as half that
%and then redefine everything else

timeofbeat = 1/(2*112/60); %Finding the 2x time per beat using given bpm
delta = 0.0005; %Step size for the time
tbeat = 0:delta:timeofbeat; %Each Beat or quarter Note
ttwicebeat = 0:delta:2*timeofbeat; %Each Half Note
thalfbeat = 0:delta:1/2*timeofbeat; %Each Eighth Note
tdottedquarter =  0:delta:3/2*timeofbeat; %Each dotted quarter note

frequencyA4 = 440; %Frequency of the A note

Note1 = sin(2*pi*2^(-2/12)*frequencyA4*tbeat); %(G4)
Note2 = sin(2*pi*2^(1/12)*frequencyA4*tbeat); %(Bflat/Asharp)
Note3 = sin(2*pi*2^(3/12)*frequencyA4*tdottedquarter); %(C5)
Note4 = sin(2*pi*2^(-2/12)*frequencyA4*tbeat); %(G4) %Played for 2 ...

Note6 = sin(2*pi*2^(1/12)*frequencyA4*tbeat); %(Bflat/Asharp) 
Note7 = sin(2*pi*2^(4/12)*frequencyA4*thalfbeat); %(Dflat/Csharp)
Note8 = sin(2*pi*2^(3/12)*frequencyA4*ttwicebeat); %(C5 for halfbeat)

Note9 = sin(2*pi*2^(-2/12)*frequencyA4*tbeat); %(G4)
Note10 = sin(2*pi*2^(1/12)*frequencyA4*tbeat); %(Bflat/Asharp)
Note11 = sin(2*pi*2^(3/12)*frequencyA4*tdottedquarter); %C5
Note12 = sin(2*pi*2^(1/12)*frequencyA4*tbeat); % (Bflat/Asharp)...

Note14 = sin(2*pi*2^(-2/12)*frequencyA4*tbeat); % (G4)

Note15 = sin(2*pi*2^(-2/12)*0*ttwicebeat); %For the rest notes

SmokeontheWaterB = [Note1, Note2, Note3, Note4, Note6, Note7, Note8,...
    Note9, Note10, Note11, Note12, Note14, Note15]; %Set up the Sound File
sound(SmokeontheWaterB, 1/delta); %Playing the sound

%%%%%%%%%%%%%%%%%%Smoke on the Water with x(2t) transformation%%%%%%%%%%%%%

%To do this one must simply put a *2 in all of the sin() for the Notes

%Setting up the Initial Variables
timeofbeat = 1/(112/60); %Finding the time per beat using given bpm
delta = 0.0005; %Step size for the time
tbeat = 0:delta:timeofbeat; %Each Beat or quarter Note
ttwicebeat = 0:delta:2*timeofbeat; %Each Half Note
thalfbeat = 0:delta:1/2*timeofbeat; %Each Eighth Note
tdottedquarter =  0:delta:3/2*timeofbeat; %Each dotted quarter note

frequencyA4 = 440; %Frequency of the A note

Note1 = sin(4*pi*2^(-2/12)*frequencyA4*tbeat); %(G4)
Note2 = sin(4*pi*2^(1/12)*frequencyA4*tbeat); %(Bflat/Asharp)
Note3 = sin(4*pi*2^(3/12)*frequencyA4*tdottedquarter); %(C5)
Note4 = sin(4*pi*2^(-2/12)*frequencyA4*tbeat); %(G4) 

Note6 = sin(4*pi*2^(1/12)*frequencyA4*tbeat); %(Bflat/Asharp) 
Note7 = sin(4*pi*2^(4/12)*frequencyA4*thalfbeat); %(Dflat/Csharp)
Note8 = sin(4*pi*2^(3/12)*frequencyA4*ttwicebeat); %(C5 for halfbeat)

Note9 = sin(4*pi*2^(-2/12)*frequencyA4*tbeat); %(G4)
Note10 = sin(4*pi*2^(1/12)*frequencyA4*tbeat); %(Bflat/Asharp)
Note11 = sin(4*pi*2^(3/12)*frequencyA4*tdottedquarter); %C5
Note12 = sin(4*pi*2^(1/12)*frequencyA4*tbeat); % (Bflat/Asharp)...
 
Note14 = sin(4*pi*2^(-2/12)*frequencyA4*tbeat); % (G4)

Note15 = sin(4*pi*2^(-2/12)*0*ttwicebeat); %For the rest notes

SmokeontheWaterC = [Note1, Note2, Note3, Note4, Note6, Note7, Note8,...
    Note9, Note10, Note11, Note12, Note14, Note15]; %Setting up the Sound File
sound(SmokeontheWaterC, 1/delta); %Playing the Sound

%%%%%%%%%%%%For this part the sound was really strange and did not seem right, but the transformation
%%%%%%%%%%%%Seemed to be appropriate (multiplying by 2 within each sin() function).

wavwrite([SmokeontheWaterA, SmokeontheWaterB, SmokeontheWaterC],...
    1/delta, 32, 'SmokeontheWaterSoundFile'); %Creating the actual WAV sound file





%%%%%%%%%%%%%%Second Part of Assignment

%Second Part of the Assignment

[BeatlesSong, FS, NBITS] = wavread('Beatles.wav'); %Read forwards wav file
sound(BeatlesSong, FS, NBITS); %Play File



fprintf('The forward message is: "Number Nine" repeated over and over \n')



pause(15); %Wait a bit

BackwardsBeatlesSong = flipud(BeatlesSong); %Flip the forwards song
sound(BackwardsBeatlesSong, FS, NBITS); %Play the backwards song



fprintf('The backwards message is: "Turn me on dead man" repeated over and over \n')



wavwrite(BackwardsBeatlesSong, FS, NBITS, 'BackwardsBeatlesSong'); %write file




Media:SmokeontheWaterSoundFile.wav
Media:BackwardsBeatlesSong.wav

Alumni Liaison

Sees the importance of signal filtering in medical imaging

Dhruv Lamba, BSEE2010