You are on page 1of 1

1. The following outline shows how to use MATLAB to sample audio input.

fs = 8,000;
tmax = 4;
nbits = 16;
nchan = 1;
Recorder = audiorecorder(fs, nbits, nchan);
record(Recorder);
fprintf(1, ‘Recording ... \n’);
pause(tmax);
stop(Recorder);
% convert to floating-point vector and play back
yi = getaudiodata(Recorder, ‘int16’);
y = double(yi);
y = y/max(abs[y]);
plot(y);
sound(y, fs);
(a) Sample your own voice, using the MATLAB code above.
(b) Determine the size of the sample vector. Does this correspond to the sample
rate you selected when saving the file?
(c) Plot the entire waveform (as above), and portions of it using vector subscripting.
Note how the 16 - bit audio samples are converted to floating - point values for
calculation.

You might also like