The record operation, is carried out by creation of something called an object (similar to Object-Oriented Programming). The object under consideration for recording is audiorecorder.
Obviously Matlab help covers all the below mentioned, but here is a personal experience touch to it. You instantiate an object by just calling it and assigning a name to it. Also are given a few properties.
y = audiorecorder(8000, 16, 1);
is the most commonly used of the lot. It creates the object, with a Sampling Frequency of 8000Hz, 16bits/sample and mono channel recording. The Sampling Frequency of 8kHz is ideal for speech and voice. But for high pitch music, its ideal to have a higher sampling frequency of the order of 22050Hz or 44.1kHz.
record(y);– starts the recording with control to execute other statements (useful)
pause(y);– pauses recording
resume(y);– resumes recording
play(y);– plays recording done until now and finally
signal = getaudiodata(y);– passes the recording data to the variable called signal
Generally signal processing applications, then would check for saturation, i.e. most of the absolute values of the signal being close to 1 (hampers audibility).
You would now store this recorded signal to your hard disk by
Note that the sampling frequency and no. of bits / sample should be kept the same.
These wav files can be read as
[data, Fs] = wavread(wavfilename);
The data is the actual -1 to 1 audio information, and Fs the sampling frequency, a key information required to do any further processing.
data can be played using
wavplay(data, Fs). This is supported on 32-bit Windows machines. So a better alternative would be to use
soundsc(data, Fs). This automatically scales the data vector amplitudes [MIN,MAX] to [-1,1] and then plays the entire data stream with given sampling rate.
More on audio processing using Matlab to come soon…