Create object for recording audio
recorder = audiorecorder
recorder = audiorecorder(Fs,nBits,nChannels)
recorder = audiorecorder(Fs,nBits,nChannels,ID)
Sampling rate in Hz. Valid values depend on the specific audio hardware installed. 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: 8, 16, or 24.
The number of channels: 1 (mono) or 2 (stereo).
Device identifier. To obtain the ID of a device, use the audiodevinfo function.
Default: -1 (default device)
Note: When calling any method, include the audiorecorder object name using function syntax, such as stop(recorder).
Query properties of audiorecorder object.
Create an array that stores the recorded signal values.
Create an audioplayer object.
Query whether recording is in progress: returns true or false.
Play recorded audio. This method returns an audioplayer object.
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 audiorecorder object.
Number of bits per sample. (Read-only)
Current sample that the audio input device is recording. If the device is not recording, CurrentSample is the next sample to record with record or resume. (Read-only)
Identifier for audio device. (Read-only)
Number of audio channels. (Read-only)
Status of the audio recorder: 'on' or 'off'. (Read-only)
Sampling frequency in Hz. (Read-only)
Total length of the audio data in samples. (Read-only)
String that labels the object.
Name of the class: 'audiorecorder'. (Read-only)
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 audiorecorder object and an event structure.
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 TimerPeriod property.
Time in seconds between TimerFcn callbacks. Default: .05
audiorecorder ignores any specified values for these properties, which will be removed in a future release.
Length of buffer in seconds.
Number of buffers.
Create an 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 audiorecorder object, your system must have a properly installed and configured sound card.
audiorecorder is not intended for long, high-sample-rate recording. audiorecorder uses system memory for storage and does not use disk buffering. When you attempt a large recording, your MATLAB® performance sometimes degrades over time.