MATLAB Function Reference Previous page   Next Page
audiorecorder

Create audio recorder object

Syntax

Description

y = audiorecorder returns a handle to an 8-kHz, 8-bit, mono audio recorder object. The audio recorder object supports methods and properties that you can use to record audio data.

y = audiorecorder(Fs,nbits,channels) returns a handle to an audio recorder object using the sampling rate Fs (in Hz), the sample size of nbits, and the number of channels. Fs can be any sampling rate supported by the audio hardware. Common sampling rates are 8000, 11025, 22050, and 44000. The value of nbits must be 8 or 16 (or 24, if a 24-bit device is installed). For mono or stereo, channels must be 1 or 2, respectively.

y = audiorecorder(Fs,nbits,channels,id) returns a handle to an audio recorder object using the audio device specified by its id for input.

Examples

Example 1

Using a microphone, record 3.5 seconds of 44.1-kHz, 16-bit, stereo data, and then return the data to the MATLAB workspace as a double array.

Example 2

Using a microphone, record 8-bit, 22-kHz mono data, play it back, record again, and return the data to the MATLAB workspace as a uint8 array.

Remarks

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.

Methods

After you create an audio recorder object, you can use the methods listed below on that object. y represents the name of the returned audio recorder.

Method
Description
record(y)
record(y,length)
Starts recording.
Records for length number of seconds.
recordblocking(y,length)
Same as record, but does not return control until recording completes.
stop(y)
Stops recording.
pause(y)
Pauses recording.
resume(y)
Restarts recording from where recording was paused.
isrecording(y)
Indicates the status of recording. If 0, recording is not in progress. If 1, recording is in progress.
play(y)
Creates an audioplayer, plays the recorded audio data, and returns a handle to the created audioplayer.
getplayer(y)
Creates an audioplayer and returns a handle to the created audioplayer.
getaudiodata(y)
getaudiodata(y,'type')
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.
display(y)
disp(y)
get(y)
Displays all property information about audio recorder y.

Properties

Audio recorder objects have the properties listed below. To set a user-settable property, use this syntax:

To view a read-only property,

See Also

audioplayer, wavread, wavrecord, wavwrite, get, set, methods


Previous page  audioplayer aufinfo Next page

© 1994-2005 The MathWorks, Inc.