Create object for recording audio
recorder = audiorecorder
recorder = audiorecorder(Fs,nBits,nChannels)
recorder = audiorecorder(Fs,nBits,nChannels,ID)
an 8000 Hz, 8-bit, 1-channel
recorder = audiorecorder
Sampling rate in Hz. Valid values depend on both the sample rates permitted by MATLAB® and the specific audio hardware on your system. MATLAB has a hard restriction of 1000 Hz <= Fs <= 384000 Hz, although further hardware-dependent restrictions apply. Typical values supported by most sound cards are 8000, 11025, 22050, 44100, 48000, and 96000 Hz.
Bits per sample. Valid values depend on the audio hardware installed:
The number of channels:
Device identifier. To obtain the ID of a device, use the
When calling any method, include the
name using function syntax, such as
Query properties of
Create an array that stores the recorded signal values.
Query whether recording is in progress: returns
Play recorded audio. This method returns an
Record, and do not return control until recording completes.
This method requires a second input for the length of the recording
Restart recording from paused position.
Set properties of
Number of bits per sample. (Read-only)
Current sample that the audio input device is recording.
If the device is not recording,
Identifier for audio device. (Read-only)
Number of audio channels. (Read-only)
Status of the audio recorder:
Sampling frequency in Hz. (Read-only)
Total length of the audio data in samples. (Read-only)
Label of the object.
Name of the class:
Any type of additional data to store with the object.
The following four properties apply to callback
functions. The first two inputs to your callback function
must be the
Function to execute one time when recording starts.
Function to execute one time when recording stops.
Function to execute repeatedly during recording. To specify
time intervals for the repetitions, use the
Time in seconds between
Length of buffer in seconds.
Number of buffers.
audiorecorder object for CD-quality
audio in stereo, and view its properties:
recObj = audiorecorder(44100, 16, 2); get(recObj)
Collect a sample of your speech with a microphone, and plot the signal data:
% Record your voice for 5 seconds. recObj = audiorecorder; disp('Start speaking.') recordblocking(recObj, 5); disp('End of Recording.'); % Play back the recording. play(recObj); % Store data in double-precision array. myRecording = getaudiodata(recObj); % Plot the waveform. plot(myRecording);
To use an
your system must have a properly installed and configured sound card.
audiorecorder is not intended
for long, high-sample-rate recording.
system memory for storage and does not use disk buffering. When you
attempt a large recording, your MATLAB performance sometimes
degrades over time.