(New page: 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 se...)
 
 
Line 2: Line 2:
  
 
% John Frey
 
% John Frey
 +
 
% ECE 301
 
% ECE 301
 +
 
% Prof. Boutin
 
% Prof. Boutin
 +
 
% HW 1
 
% HW 1
 +
  
 
delta = 5e-5; % sampling rate in seconds
 
delta = 5e-5; % sampling rate in seconds
 +
 
beat = 15/28; % 112 beats per minute means 28/15 beats per second,  
 
beat = 15/28; % 112 beats per minute means 28/15 beats per second,  
 
% therefore 15/28 seconds per beat.
 
% therefore 15/28 seconds per beat.
 +
  
 
% DEFINING FREQUENCY OF EACH NOTE IN Hz
 
% DEFINING FREQUENCY OF EACH NOTE IN Hz
 +
 
freq_G = (2^(-2/12))*440;
 
freq_G = (2^(-2/12))*440;
 
freq_Bf = (2^(1/12))*440;
 
freq_Bf = (2^(1/12))*440;
 
freq_C = (2^(3/12))*440;
 
freq_C = (2^(3/12))*440;
 
freq_Df = (2^(4/12))*440;
 
freq_Df = (2^(4/12))*440;
 +
  
 
% INITIALIZING VECTORS FOR THE SOUND OF EACH NOTE
 
% INITIALIZING VECTORS FOR THE SOUND OF EACH NOTE
 +
 
sound_G = 2*pi*freq_G;
 
sound_G = 2*pi*freq_G;
 
sound_Bf = 2*pi*freq_Bf;
 
sound_Bf = 2*pi*freq_Bf;
 
sound_C = 2*pi*freq_C;
 
sound_C = 2*pi*freq_C;
 
sound_Df = 2*pi*freq_Df;
 
sound_Df = 2*pi*freq_Df;
 +
  
 
% INITIALIZING NOTE LENGTH VECTORS
 
% INITIALIZING NOTE LENGTH VECTORS
 +
 
quarter = [0 : delta : beat];
 
quarter = [0 : delta : beat];
 
eighth = [0 : delta : (beat / 2)];
 
eighth = [0 : delta : (beat / 2)];
Line 29: Line 40:
 
sixteenth = [0 : delta : (beat / 4)];
 
sixteenth = [0 : delta : (beat / 4)];
 
doteighth = [0 : delta : (beat * 0.75)];
 
doteighth = [0 : delta : (beat * 0.75)];
 +
  
 
% CREATING SONG VECTORS
 
% CREATING SONG VECTORS
 +
 
%normal smoke on the water
 
%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)];
 
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
 
%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)];
 
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"
 
% PLAYING NOTES OF "SMOKE ON THE WATER"
 +
 
sound (smoke1, 1/delta);
 
sound (smoke1, 1/delta);
 
sound (smoke2, 1/delta);
 
sound (smoke2, 1/delta);
Line 49: Line 67:
  
 
the generated .wav files:
 
the generated .wav files:
 +
 
[[Media:John_Frey_ECE301_HW1_a.wav]]
 
[[Media:John_Frey_ECE301_HW1_a.wav]]
 +
 
[[Media:John_Frey_ECE301_HW1_b.wav]]
 
[[Media:John_Frey_ECE301_HW1_b.wav]]
 +
 
[[Media:John_Frey_ECE301_HW1_c.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.
 
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".
 
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:
 
MATLAB code for part 2:
 +
 
% ECE 301 HW 1 part 2
 
% ECE 301 HW 1 part 2
 +
 
% John Frey
 
% John Frey
 +
  
 
% READING AND PLAYING BEATLES WAV FILE
 
% READING AND PLAYING BEATLES WAV FILE
 +
 
[y, fs] = wavread ('Beatles');
 
[y, fs] = wavread ('Beatles');
 
sound (y, fs);
 
sound (y, fs);
 +
  
 
% REVERSING SOUND CLIP AND PLAYING RESULT
 
% REVERSING SOUND CLIP AND PLAYING RESULT
 +
 
reverse = flipud (y);
 
reverse = flipud (y);
 
sound (reverse, fs);
 
sound (reverse, fs);
  
 
% WRITING REVERSED CLIP TO NEW WAV FILE
 
% WRITING REVERSED CLIP TO NEW WAV FILE
 +
 
wavwrite (reverse, fs, 'John_Frey_ECE301_HW1_PT2');
 
wavwrite (reverse, fs, 'John_Frey_ECE301_HW1_PT2');
 +
  
 
Output .wav file:
 
Output .wav file:
 +
 
[[Media:John_Frey_ECE301_HW1_PT2.wav]]
 
[[Media:John_Frey_ECE301_HW1_PT2.wav]]

Latest revision as of 19:09, 18 January 2011

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

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

Kuei-Nuan Lin