Main Content

record

Record audio to audiorecorder object

Syntax

record(recorderObj)
record(recorderObj, length)

Description

record(recorderObj) records audio from an input device, such as a microphone connected to your system. recorderObj is an audiorecorder object that defines the sample rate, bit depth, and other properties of the recording.

record(recorderObj, length) records for the number of seconds specified by length.

Examples

Record 5 seconds of your speech with a microphone:

myVoice = audiorecorder;

% Define callbacks to show when
% recording starts and completes.
myVoice.StartFcn = 'disp(''Start speaking.'')';
myVoice.StopFcn = 'disp(''End of recording.'')';

record(myVoice, 5);

To listen to the recording, call the play method:

play(myVoice);

Tips

  • Note

    Security Considerations When Using MATLAB® Online™ or MATLAB Web App Server™: When using record in MATLAB Online or MATLAB Web App Server, recording continues when you switch browser tabs.