Revision as of 07:55, 19 January 2011 by Seabraha (Talk | contribs)

%ECE 301 HW 1

%Sarah Abraham

%Professor Boutin

%Part 1

%play melody of Smoke On the Water at original tempo

%G Bf C G Bf Df C G Bf C Bf G

%H = 1/2 note

%Q = 1/4 note

%E = 1/8 note

%DQ = dotted quarter

clc

clear

delta = 5e-5; %sampling rate

bpm = 112; %beats per minute

bps = 60/bpm; %seconds per beat

H = 2*bps; % seconds required for half note

Q = 1*bps; % seconds required for quarter note

E = .5*bps; % seconds required for eighth note

DQ = 1.5*bps; % seconds required for dotted quarter note

%time

H_t = 0:delta:H;

Q_t = 0:delta:Q;

E_t = 0:delta:E;

DQ_t = 0:delta:DQ;

%frequencies for notes

fa = 440; %Hz

fg = 2^(-2/12)*fa;

fbf = 2^(1/12)*fa;

fc =2^(3/12)*fa;

fdf = 2^(4/12)*fa;

%notes with appropriate times

g = sin(2*pi*fg*Q_t);

bf = sin(2*pi*fbf*Q_t);

c_dq = sin(2*pi*fc*DQ_t);

c_h = sin(2*pi*fc*H_t);

df = sin(2*pi*fdf*E_t);

%song at regular tempo

song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; 

%plays

song sound(song, 1/delta); 

%write song to wavfile

wavwrite(song, 1/delta, 'Regular_Tempo.wav')

Media:Regular_Tempo.wav

%PART 1B

bpm = 224; %beats per minute

bps = 60/bpm; %seconds per beat

H = 2*bps; % seconds required for half note

Q = 1*bps; % seconds required for quarter note

E = .5*bps; % seconds required for eighth note

DQ = 1.5*bps; % seconds required for dotted quarter note

%time

H_t = 0:delta:H;

Q_t = 0:delta:Q;

E_t = 0:delta:E;

DQ_t = 0:delta:DQ;

%notes with appropriate times

g = sin(4*pi*fg*Q_t);

bf = sin(4*pi*fbf*Q_t);

c_dq = sin(4*pi*fc*DQ_t);

c_h = sin(4*pi*fc*H_t);

df = sin(4*pi*fdf*E_t);

%song at faster tempo

song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; 

%plays song sound(song, 1/delta); 

%write song to wavfile

wavwrite(song, 1/delta, 'Faster_Tempo.wav')

Media:Faster_Tempo.wav

%PART 1C

bpm = 112; %beats per minute

bps = 60/bpm; %seconds per beat

H = 2*bps; % seconds required for half note

Q = 1*bps; % seconds required for quarter note

E = .5*bps; % seconds required for eighth note

DQ = 1.5*bps; % seconds required for dotted quarter note

%time

H_t = 0:delta:H;

Q_t = 0:delta:Q;

E_t = 0:delta:E;

DQ_t = 0:delta:DQ;

%frequencies for notes

fa = 880; %Hz

fg = 2^(-2/12)*fa;

fbf = 2^(1/12)*fa;

fc =2^(3/12)*fa;

fdf = 2^(4/12)*fa;

%notes with appropriate times

g = sin(2*pi*fg*Q_t);

bf = sin(2*pi*fbf*Q_t);

c_dq = sin(2*pi*fc*DQ_t);

c_h = sin(2*pi*fc*H_t);

df = sin(2*pi*fdf*E_t);

%song at regular tempo

song = [g, bf, c_dq, g, bf, df, c_h, g, bf, c_dq, bf, g]; 

%plays

song sound(song, 1/delta); 

%write song to wavfile

wavwrite(song, 1/delta, 'Higher_Octave.wav')

Media:Higher_Octave.wav


 %Part 2

%load Beatles clip and frequency

[beatles,fs] = wavread('Beatles.wav'); %plays clip sound(beatles, fs);

%The repeated message seems to be 'Number Nine' repeated over and over %again.

%reverses the sound matrix

reverse = flipud(beatles); 

%plays reversed clip

sound(reverse, fs) 

%The repeated message seems like it says 'Turn me on dead man'

Alumni Liaison

Recent Math PhD now doing a post-doctorate at UC Riverside.

Kuei-Nuan Lin