y = audiorecorder
y = audiorecorder(Fs, nbits, nchans)
y = audiorecorder(Fs, nbits, channels,
id)
Note To use all of the features of the audiorecorder object, your system must have a properly installed and configured sound card with 8- and 16-bit I/O and support for sampling rates of up to 48 kHz. |
y = audiorecorder creates an 8000 Hz, 8-bit, 1 channel audiorecorder object. y is a handle to the object. The audiorecorder object supports methods and properties that you can use to record audio data.
y = audiorecorder(Fs, nbits, nchans) creates an audiorecorder object using the sampling rate Fs (in Hz), the sample size nbits, and the number of channelsnchans. Fs can be any sampling rate supported by the audio hardware. Common sampling rates are 8000, 11025, 22050, and 44100 (only 44100 on Macintosh® systems). The value of nbits must be 8, 16, or 24, on Microsoft® Windows®, and 8 or 16 on UNIX®. The number of channels, nchans must be 1 (mono) or 2 (stereo).
y = audiorecorder(Fs, nbits, channels, id) creates an audiorecorder object using the audio device specified by its id for input. If id equals -1, the default input device will be used. This option is only available on Windows.
Using a microphone, record your voice, using a sample rate of 44100 Hz, 16 bits per sample, and one channel. Speak into the microphone, then pause the recording. Play back what you have recorded so far. Record some more, then stop the recording. Finally, return the recorded data to MATLAB® as an int16 array.
r = audiorecorder(44100, 16, 1); record(r); % speak into microphone... pause(r); p = play(r); % listen resume(r); % speak again stop(r); p = play(r); % listen to complete recording mySpeech = getaudiodata(r, 'int16'); % get data as int16 array
The current implementation of audiorecorder is not intended for long, high-sample-rate recording because it uses system memory for storage and does not use disk buffering. When large recordings are attempted, MATLAB performance may degrade.
After you create an audiorecorder object, you can use the methods listed below on that object. y represents the name of the returned audiorecorder object
Method | Description |
---|---|
Starts recording. Records for length number of seconds. | |
Same as record, but does not return control until recording completes. | |
Stops recording. | |
Pauses recording. | |
Restarts recording from where recording was paused. | |
Indicates the status of recording. If 0, recording is not in progress. If 1, recording is in progress. | |
Creates an audioplayer, plays the recorded audio data, and returns a handle to the created audioplayer. | |
Creates an audioplayer and returns a handle to the created audioplayer. | |
Returns the recorded audio data to the MATLAB workspace. type is a string containing the desired data type. Supported data types are double, single, int16, int8, or uint8. If type is omitted, it defaults to 'double'. For double and single, the array contains values between -1 and 1. For int8, values are between -128 to 127. For uint8, values are from 0 to 255. For int16, values are from -32768 to 32767. If the recording is in mono, the returned array has one column. If it is in stereo, the array has two columns, one for each channel. | |
Displays all property information about audio recorder y. |
Audio recorder objects have the properties listed below. To set a user-settable property, use this syntax:
set(y, 'property1', value,'property2',value,...)
To view a read-only property,
get(y,'property') %displays 'property' setting.
© 1984-2008 The MathWorks, Inc.