%PART 1a

%Constants
a4=440; %Frequency of the note A4
beat=60/112; %Length of a beat in seconds
resolution=.0005; %Time step between points
%Arrays that signify the lengths of notes
eighth=0:resolution:(beat/2); %Eighth note
quarter=0:resolution:beat; %Quarter note
dotted=0:resolution:(beat*1.5); %Dotted quarter note
half=0:resolution:(beat*2); %Half note
%Each note as a singular array lasting the appropriate time period
n1=sin(2*pi*a4*2^(-2/12)*quarter);
n2=sin(2*pi*a4*2^(1/12)*quarter);
n3=sin(2*pi*a4*2^(3/12)*dotted);
n4=sin(2*pi*a4*2^(-2/12)*quarter);
n5=sin(2*pi*a4*2^(1/12)*quarter);
n6=sin(2*pi*a4*2^(4/12)*eighth);
n7=sin(2*pi*a4*2^(3/12)*half);
n8=sin(2*pi*a4*2^(-2/12)*quarter);
n9=sin(2*pi*a4*2^(1/12)*quarter);
n10=sin(2*pi*a4*2^(3/12)*dotted);
n11=sin(2*pi*a4*2^(1/12)*quarter);
n12=sin(2*pi*a4*2^(-2/12)*quarter);
%Addition of all notes, in order, to a single array
smokea=[n1 n2 n3 n4 n5 n6 n7 n8 n9 n10 n11 n12];
%Output as a sound file
sound(smokea,1/.0005)
wavwrite(smokea,1/.0005,'pluce_hw1_1a');

%PART 1b
%Constants
beat=(60/112)/2; %Length of a beat in seconds
%Arrays that signify the lengths of notes
eighth=0:resolution:(beat/2); %Eighth note
quarter=0:resolution:beat; %Quarter note
dotted=0:resolution:(beat*1.5); %Dotted quarter note
half=0:resolution:(beat*2); %Half note
%Each note as a singular array lasting the appropriate time period
n1=sin(2*pi*a4*2^(-2/12)*quarter);
n2=sin(2*pi*a4*2^(1/12)*quarter);
n3=sin(2*pi*a4*2^(3/12)*dotted);
n4=sin(2*pi*a4*2^(-2/12)*quarter);
n5=sin(2*pi*a4*2^(1/12)*quarter);
n6=sin(2*pi*a4*2^(4/12)*eighth);
n7=sin(2*pi*a4*2^(3/12)*half);
n8=sin(2*pi*a4*2^(-2/12)*quarter);
n9=sin(2*pi*a4*2^(1/12)*quarter);
n10=sin(2*pi*a4*2^(3/12)*dotted);
n11=sin(2*pi*a4*2^(1/12)*quarter);
n12=sin(2*pi*a4*2^(-2/12)*quarter);
%Addition of all notes, in order, to a single array
smokeb=[n1 n2 n3 n4 n5 n6 n7 n8 n9 n10 n11 n12];
%Output as a sound file

sound(smokeb,1/.0005)
wavwrite(smokeb,1/.0005,'pluce_hw1_1b');

%PART 1c

%This is equivalent to "speeding up the record"
%We should observe the tune twice as fast and an octave higher
sound(smokea,2/.0005)
wavwrite(smokea,2/.0005,'pluce_hw1_1c');

%PART 2a

%Import the sound file
[beatles,fs]=wavread('Beatles.wav');
beatles=beatles*8; %Amplifies the clip
%Playing the sound file
sound(beatles,fs)
%The clip repeats the phrase "Number 9"

%PART 2b

%Reversing the sound clip
seltaeb=flipud(beatles);
%Playing and writing the reversed version
sound(seltaeb,fs)
wavwrite(seltaeb,fs,'pluce_hw1_2b');
%I could not distinguish any phrase when I first listened to the reversed
%clip. On further inspection I found it was supposed to say "turn me on,
%dead men". When I listened again, I picked up on it.

Smoke on the Water 1a
Smoke on the Water 1b
Smoke on the Water 1c
Beatles Reversed

Alumni Liaison

Basic linear algebra uncovers and clarifies very important geometry and algebra.

Dr. Paul Garrett