audiorecorder
Object for recording audio.
📝 Syntax
recorder = audiorecorder()
recorder = audiorecorder(Fs, nBits, nChannels)
recorder = audiorecorder(Fs, nBits, nChannels, ID)
📥 Input argument
Fs - a double value: sampling rate in Hz (default: 8000).
nBits - a double value: bits per sample (default: 8; valid: 8, 16, 24).
nChannels - a double value: number of channels (default: 1; valid: 1, 2).
ID - a double value: audio device identifier (default: -1).
📤 Output argument
recorder - audiorecorder object
📄 Description
audiorecorder creates an audiorecorder object for recording audio from an input device such as a microphone.
The audiorecorder object provides properties and methods to control audio recording, including pausing, resuming, and defining callbacks.
Creation:
recorder = audiorecorder() creates an audiorecorder object with default properties: SampleRate = 8000, BitsPerSample = 8, NumChannels = 1.
recorder = audiorecorder(Fs, nBits, nChannels) sets the sample rate, bits per sample, and number of channels.
recorder = audiorecorder(Fs, nBits, nChannels, ID) sets the audio input device to the specified device identifier.
Properties of audiorecorder:
SampleRate
positive scalar (Read-only)
Sample rate in Hz.
BitsPerSample
Read-only: 8, 16, 24
Bits per sample.
NumChannels
Read-only: 1, 2
Number of audio channels.
DeviceID
integer (Read-only)
Audio device identifier.
CurrentSample
positive integer (Read-only)
Sample currently recording.
TotalSamples
nonnegative integer (Read-only)
Total length of audio data.
Running
Read-only: 'off' (default) or 'on'
Status of the audio recorder.
StartFcn
character vector or function handle
Callback executed at recording start.
StopFcn
character vector or function handle
Callback executed when recording ends.
TimerFcn
character vector or function handle
Callback executed periodically during recording; interval controlled by TimerPeriod.
TimerPeriod
0.05 (default) or positive scalar
Seconds between TimerFcn callbacks.
Tag
string scalar or character vector
Label for the audiorecorder object.
UserData
[] (default) or any data type
Arbitrary user-defined data stored with the object.
Type
'audiorecorder' (Read-only)
Class name identifier for the object.
Object Functions:
getaudiodata - Store recorded audio signal in numeric array
getplayer - Create associated audioplayer object
isrecording - Determine if recording is in progress
pause - Pause recording
play - Play audio from audiorecorder object
record - Record audio to audiorecorder object
recordblocking - Record audio and block until complete
resume - Resume recording from paused state
stop - Stop recording
💡 Examples
Record Audio from Input Device
Callback example
🔗 See also
audioplayer, getaudiodata, record, recordblocking, pause, resume, stop, getplayer.
🕔 History
1.16.0
initial version
Last updated
Was this helpful?