MATLAB Function Reference | ![]() ![]() |
Record sound using a PC-based audio input device.
Syntax
y = wavrecord(n,fs)
y = wavrecord(...,ch)
y = wavrecord(...,'dtype'
)
Description
y = wavrecord(n,fs)
records n
samples of an audio signal, sampled at a rate of fs
Hz (samples per second). The default value for fs
is 11025 Hz.
y = wavrecord(...,ch)
uses ch
number of input channels from the audio device. The default value for ch
is 1.
y = wavrecord(...,'
dtype
')
uses the data type specified by the string 'dtype
' to record the sound. The string 'dtype
' can be one of the following:
double
' (default value), 16 bits/samplesingle
', 16 bits/sampleint16
', 16 bits/sampleuint8
', 8 bits/sampleRemarks
Standard sampling rates for PC-based audio hardware are 8000, 11025, 2250, and 44100 samples per second. Stereo signals are returned as two-column matrices. The first column of a stereo audio matrix corresponds to the left input channel, while the second column corresponds to the right input channel.
Examples
Record 5 seconds of 16-bit audio sampled at 11,025 Hz. Play back the recorded sound using wavplay
. Speak into your audio device (or produce your audio signal) while the wavrecord
command runs.
fs = 11025; y = wavrecord(5*fs,fs,'int16'); wavplay(y,fs);
See Also
wavplay
Play recorded sound on a PC-based audio output
device.
![]() | wavread | wavwrite | ![]() |