% ECE301 Homework 1, Craig Lechlitner
% Part 1

clear
clc


song = []; %array that will hold all three versons of the song
n=[-2,1,4,-2,1,6,4,-2,1,4,1,-2]; %number of half steps from A440
length=[1,1,1.5,1,1,.5,2,1,1,1.5,1,1]; %duration of each note (beats)
delta=.00005;
beat_length=60/112; %112 beats per minute


% play original song
for count=1:12; %loop once for each note (12 notes total)
t=0:delta:beat_length*length(count); %duration of each note (seconds)
freq=2*pi*440*(2^(n(count)/12)); % frequency of each note
note=sin(freq*t); % combination of frequency and duration
sound((note),1/delta);
song = [song; note(:)]; % Add note to song
end


% play double speed
for count=1:12; %loop once for each note (12 notes total)
t=0:delta:beat_length*length(count)/2; %duration of each note (seconds)
freq=2*pi*440*(2^(n(count)/12)); % frequency of each note
note=sin(freq*t); % combination of frequency and duration
sound((note),1/delta);
song = [song; note(:)]; % Add note to song
end


% play double frequency
for count=1:12; %loop once for each note (12 notes total)
t=0:delta:beat_length*length(count); %duration of each note (seconds)
freq=2*pi*440*(2^(n(count)/12))*2; % frequency of each note
note=sin(freq*t); % combination of frequency and duration
sound((note),1/delta);
song = [song; note(:)]; % Add note to song
end

wavwrite(song,1/delta,32,'Craig_Lechlitner_1') % writes all three versions to one file

Media:Craig_Lechlitner_1.wav



% ECE301 Homework 1, Craig Lechlitner
% Part 2

clear
clc

[Y,Fs]=wavread('Beatles.wav');
sound(Y,Fs) % plays forward, says "number nine"
Y=flipud(Y); % reverses song
sound(Y,Fs) % plays reversed, I couldn't tell what it said until I looked it up
wavwrite(Y,Fs,'Craig_Lechlitner_2') % writes reversed song to file

Media:Craig_Lechlitner_2.wav

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn