Line 2: Line 2:
  
 
load handel; %Loads 2 variables, y and Fs.  y is a signal containing  
 
load handel; %Loads 2 variables, y and Fs.  y is a signal containing  
%information: a vector of numbers representing an audio clip.  Fs is the
+
information: a vector of numbers representing an audio clip.  Fs is the
%sampling frequency.
+
sampling frequency.
  
 
sound(y,Fs); %play the audio file at the appropriate sampling frequency.
 
sound(y,Fs); %play the audio file at the appropriate sampling frequency.
Line 11: Line 11:
 
downsample = 4; %factor to decrease sampling rate by
 
downsample = 4; %factor to decrease sampling rate by
 
sound(y(1:downsample:end)*downsample,Fs/downsample); %Plays the same signal with only  
 
sound(y(1:downsample:end)*downsample,Fs/downsample); %Plays the same signal with only  
%1/4 of the original "information." Note the degradation in quality
+
1/4 of the original "information." Note the degradation in quality
  
 
input('Press enter to hear the same audio with 1/100 of the original samples')
 
input('Press enter to hear the same audio with 1/100 of the original samples')
Line 17: Line 17:
 
downsample = 100; %factor to decrease sampling rate by
 
downsample = 100; %factor to decrease sampling rate by
 
sound(y(1:downsample:end)*downsample,Fs/downsample); %Plays the same signal with only  
 
sound(y(1:downsample:end)*downsample,Fs/downsample); %Plays the same signal with only  
%1/100 of the original "information." Original audio is nearly unrecognizable.
+
1/100 of the original "information." Original audio is nearly unrecognizable.
  
 
input('Press enter to hear a constant tone note A')
 
input('Press enter to hear a constant tone note A')

Revision as of 06:32, 15 June 2009

Here is a Matlab script reflecting Lecture 1. The script plays various audio signals. Copy and paste the script into an m-file and play:

load handel; %Loads 2 variables, y and Fs. y is a signal containing information: a vector of numbers representing an audio clip. Fs is the sampling frequency.

sound(y,Fs); %play the audio file at the appropriate sampling frequency.

input('Press enter to hear the same audio with 1/4 the samples')

downsample = 4; %factor to decrease sampling rate by sound(y(1:downsample:end)*downsample,Fs/downsample); %Plays the same signal with only 1/4 of the original "information." Note the degradation in quality

input('Press enter to hear the same audio with 1/100 of the original samples')

downsample = 100; %factor to decrease sampling rate by sound(y(1:downsample:end)*downsample,Fs/downsample); %Plays the same signal with only 1/100 of the original "information." Original audio is nearly unrecognizable.

input('Press enter to hear a constant tone note A')

delta = 0.00005; %Sampling period t = 1:delta:3; %a vector representing 3 seconds of time x = sin(2*pi*440*t); %a vector representing the sinusoid tone A

sound(x,1/delta);

input('Press enter to hear a tone note A an octave higher') x = sin(2*pi*880*t); %a vector representing the sinusoid tone A an octave higher

sound(x,1/delta);

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood