Revision as of 19:59, 18 January 2011 by Freyja (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

1. Here is the MATLAB code for part 1.

% John Frey % ECE 301 % Prof. Boutin % HW 1

delta = 5e-5; % sampling rate in seconds beat = 15/28; % 112 beats per minute means 28/15 beats per second, % therefore 15/28 seconds per beat.

% DEFINING FREQUENCY OF EACH NOTE IN Hz freq_G = (2^(-2/12))*440; freq_Bf = (2^(1/12))*440; freq_C = (2^(3/12))*440; freq_Df = (2^(4/12))*440;

% INITIALIZING VECTORS FOR THE SOUND OF EACH NOTE sound_G = 2*pi*freq_G; sound_Bf = 2*pi*freq_Bf; sound_C = 2*pi*freq_C; sound_Df = 2*pi*freq_Df;

% INITIALIZING NOTE LENGTH VECTORS quarter = [0 : delta : beat]; eighth = [0 : delta : (beat / 2)]; dotquarter = [0 : delta : (beat * 1.5)]; half = [0 : delta : (beat * 2)]; sixteenth = [0 : delta : (beat / 4)]; doteighth = [0 : delta : (beat * 0.75)];

% CREATING SONG VECTORS %normal smoke on the water smoke1 = [sin(sound_G*quarter), sin(sound_Bf*quarter), sin(sound_C*dotquarter), sin(sound_G*quarter), sin(sound_Bf*quarter), sin(sound_Df*eighth), sin(sound_C*half), sin(sound_G*quarter), sin(sound_Bf*quarter), sin(sound_C*dotquarter), sin(sound_Bf*quarter), sin(sound_G*quarter)];

%smoke on the water sped up x2 smoke2 = [sin(sound_G*eighth), sin(sound_Bf*eighth), sin(sound_C*doteighth), sin(sound_G*eighth), sin(sound_Bf*eighth), sin(sound_Df*sixteenth), sin(sound_C*quarter), sin(sound_G*eighth), sin(sound_Bf*eighth), sin(sound_C*doteighth), sin(sound_Bf*eighth), sin(sound_G*eighth)];


% PLAYING NOTES OF "SMOKE ON THE WATER" sound (smoke1, 1/delta); sound (smoke2, 1/delta); sound (smoke1, 2/delta);


wavwrite (smoke1, 1/delta, 'John_Frey_ECE301_HW1_a'); wavwrite (smoke2, 1/delta, 'John_Frey_ECE301_HW1_b'); wavwrite (smoke1, 2/delta, 'John_Frey_ECE301_HW1_c');

the generated .wav files: Media:John_Frey_ECE301_HW1_a.wav Media:John_Frey_ECE301_HW1_b.wav Media:John_Frey_ECE301_HW1_c.wav

Note: MATLAB indicated that data was clipped during the write to file for each of the wavwrite operations. I tried changing the delta value to decrease the amount of data generated, and was able to write the file for a delta of 5e-3, however the sounds were not audible at that frequency.

2. The repeated forward phrase is "Number Nine". When reversed with the MATLAB code below, it sounds like "Turn me on dead man".

MATLAB code for part 2: % ECE 301 HW 1 part 2 % John Frey

% READING AND PLAYING BEATLES WAV FILE [y, fs] = wavread ('Beatles'); sound (y, fs);

% REVERSING SOUND CLIP AND PLAYING RESULT reverse = flipud (y); sound (reverse, fs);

% WRITING REVERSED CLIP TO NEW WAV FILE wavwrite (reverse, fs, 'John_Frey_ECE301_HW1_PT2');

Output .wav file: Media:John_Frey_ECE301_HW1_PT2.wav

Alumni Liaison

Meet a recent graduate heading to Sweden for a Postdoctorate.

Christine Berkesch