%Ben Winski %ECE 301 Homework 1 %January 17, 2011

clear clc

A_Freq = 440; %Sets Freq of A to 440 Hz G_Freq = 2^(-2/12)*A_Freq; %Sets Freq of G BFlat_Freq = 2^(0.5/12)*A_Freq; %Sets Freq of B Flat C_Freq = 2^(3/12)*A_Freq; %Sets Freq of C DFlat_Freq = 2^(4/12)*A_Freq; %Sets Freq of D Flat

BPM = 112; %Sets the beats per minutes BPS = BPM/60; %Calculates beats per second Rev_time = 1/BPS; %Calculates the time per revolution

t = 0.0001; %Sets the time step interval

Eighth = 0:t:0.5*Rev_time; %Sets the time for Eighth notes Quarter = 0:t:1*Rev_time; %Sets the time for quarter notes Dotted_Quarter = 0:t:1.5*Rev_time; %Sets the time for Dotted Quarter Notes Half = 0:t:2*Rev_time; %Sets the time for half notes

One = sin(2*pi*G_Freq*Quarter); %Sets 1st note - G as a quarter note Two = sin(2*pi*BFlat_Freq*Quarter); %Sets 2nd note - B Flat as a quarter note Three = sin(2*pi*C_Freq*Dotted_Quarter); %Sets 3rd note - C as a dotted quarter note Four = sin(2*pi*G_Freq*Quarter); %Sets 4th note - G as a quarter note Five = sin(2*pi*BFlat_Freq*Quarter); %Sets 5th note - B Flat as a quarter note Six = sin(2*pi*DFlat_Freq*Eighth); %Sets 6th note - D Flat as an eighth note Seven = sin(2*pi*C_Freq*Half); %Sets 7th note - C as a half note Eight = sin(2*pi*G_Freq*Quarter); %Sets 8th note - G as a quarter note Nine = sin(2*pi*BFlat_Freq*Quarter); %Sets 9th note - B Flat as a quarter note Ten = sin(2*pi*C_Freq*Dotted_Quarter); %Sets 10th note - C as a dotted quarter note Eleven = sin(2*pi*BFlat_Freq*Quarter); %Sets 11th note - B Flat as a quarter note Twelve = sin(2*pi*G_Freq*Quarter); %Sets 12th note - G as a quarter note Thirteen = zeros(Eighth/t,1); %Sets an array for eighth note of silence for rest Fourteen = zeros(Half/t,1); %Sets an array for half note of silence for rest

%Sets an array to store all notes to be played Music = [One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen];

%Plays the sound 'Music' at normal speed sound(Music, 1/t);

%Plays the sound 'Music' at twice the normal speed sound(Music, 2/t);

%Below is the transformation from y(t) = x(2t) One = sin(4*pi*G_Freq*Quarter); %Sets 1st note - G as a quarter note Two = sin(4*pi*BFlat_Freq*Quarter); %Sets 2nd note - B Flat as a quarter note Three = sin(4*pi*C_Freq*Dotted_Quarter); %Sets 3rd note - C as a dotted quarter note Four = sin(4*pi*G_Freq*Quarter); %Sets 4th note - G as a quarter note Five = sin(4*pi*BFlat_Freq*Quarter); %Sets 5th note - B Flat as a quarter note Six = sin(4*pi*DFlat_Freq*Eighth); %Sets 6th note - D Flat as an eighth note Seven = sin(4*pi*C_Freq*Half); %Sets 7th note - C as a half note Eight = sin(4*pi*G_Freq*Quarter); %Sets 8th note - G as a quarter note Nine = sin(4*pi*BFlat_Freq*Quarter); %Sets 9th note - B Flat as a quarter note Ten = sin(4*pi*C_Freq*Dotted_Quarter); %Sets 10th note - C as a dotted quarter note Eleven = sin(4*pi*BFlat_Freq*Quarter); %Sets 11th note - B Flat as a quarter note Twelve = sin(4*pi*G_Freq*Quarter); %Sets 12th note - G as a quarter note Thirteen = zeros(2*Eighth/t,1); %Sets an array for eighth note of silence for rest Fourteen = zeros(2*Half/t,1); %Sets an array for half note of silence for rest

%Sets an array to store all notes to be played Music = [One, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Eleven, Twelve, Thirteen, Fourteen];

%Plays the sound 'Music' at normal speed with the transformation sound(Music, 1/t);

% PROBLEM 2 FOR HW 1 clear clc %Reads wav file in [X, Fs] = wavread('Beatles.wav');

%Plays the file in the forward direction wavplay(X,Fs);

%Reverses the wav file data 'X' X_Reverse = flipud(X);

%Plays the file 'Beatles.wav' backwards wavplay(X_Reverse, Fs);

%The forward direction repeated verse is "Number nine. Number nine. Number %nine..."

%The reverse direction repeated verse is "Turn me on dead men, Turn me on %dead men, Turn me on dead men..."

Alumni Liaison

EISL lab graduate

Mu Qiao