Record from sound card
Audio Toolbox / Sources
The Audio Device Reader block reads audio samples using your computer's audio device. The Audio Device Reader block specifies the driver, the device and its attributes, and the data type and size output from your Audio Device Reader block.
A
— Output signalThe output of the Audio Device Reader block is determined by the block’s parameters. If the block output is a matrix, the columns correspond to independent channels.
Data Types: single
| double
| int16
| int32
| uint8
O
— Number of samples overrunThis port outputs the number of samples overrun while acquiring a frame of data (one output matrix).
To enable this port, select the Output number of samples overrun parameter.
Data Types: uint32
Driver
— Driver used to access your audio deviceDirectSound
(default) | ASIO
| WASAPI
ASIO drivers do not come pre-installed on
Windows machines. To use the
ASIO
driver option,
install an ASIO driver outside of MATLAB®.
Note
If Driver is set to
ASIO
, open the ASIO UI
outside of MATLAB to set the sound card buffer size to
the value specified by the Samples per
frame parameter. See the documentation
of your ASIO driver for more information.
WASAPI drivers are supported for exclusive-mode only.
ASIO and WASAPI drivers do not provide sample rate conversion. For ASIO and WASAPI drivers, set Sample rate (Hz) to a sample rate supported by your audio device.
This parameter applies only on Windows machines. Linux machines always use the ALSA driver. Mac machines always use the CoreAudio driver.
Device
— Device used to acquire audio samplesThe device list is populated with devices available on your computer.
Info
— View information about your audio input configurationThis button opens a dialog box that lists your selected audio driver, the full name of your audio device, and the maximum input channels for your configuration. For example:
Sample rate (Hz)
— Sample rate your device uses to acquire audio data44100
(default) | integerThe possible range of Sample rate (Hz) depends on your audio hardware.
Number of channels
— Number of channels acquired by your audio device1
(default) | integerThe number of input channels is also the number of channels (matrix columns) output by the Audio Device Reader block.
To specify which input channels your audio device acquires, on the Advanced tab, select the Use default channel mapping parameter.
Samples per frame
— Frame size read from audio device1024
(default) | integerSamples per frame is also the device buffer size, and the frame size (number of matrix rows) output by the Audio Device Reader block.
Device bit depth
— Data type used by device to acquire audio data16-bit
integer
(default) | 8-bit
integer
| 16-bit
integer
| 24-bit
integer
| 32-bit
integer
Use default channel mapping
— Toggle channel mapping sourceWhen you select this parameter, the block uses the default mapping between the sound card’s input channels and the matrix columns output by this block. When you clear this parameter, you specify the mapping in Device input channels.
Device input channels
— Specify nondefault channel mapping[1:MaximumInputChannels]
(default) | scalar | vectorNondefault map of device channels and matrix output by the Audio Device Reader block, specified as a scalar or vector. For example:
If Device input
channels is specified as
1:3
, then:
Channel 1 maps to the first column of the output matrix.
Channel 2 maps to the second column of the output matrix.
Channel 3 maps to the third column of the output matrix.
If Device input
channels is specified as
[3,1,2]
, then:
Channel 3 maps to the first column of the output matrix.
Channel 1 maps to the second column of the output matrix.
Channel 2 maps to the third column of the output matrix.
To specify a nondefault mapping, clear the Use default mapping between sound card’s input channels and columns of output of this block parameter.
Output number of samples overrun
— Specify additional output port for number of samples overrunWhen you select this parameter, an additional output port, O, is added to the block. The O port outputs the number of samples overrun while acquiring a frame of data (one output matrix).
Output data type
— Data type output from blockdouble
(default) | single
| int32
| int16
| uint8
The executable generated from this block relies on prebuilt
dynamic library files (.dll files) included with MATLAB. Use the packNGo
function
to package the code generated from this object and all the
relevant files in a compressed zip file. Using this zip
file, you can relocate, unpack, and rebuild your project in
another development environment where MATLAB is not installed. For more details, see Run Audio I/O Features Outside MATLAB and Simulink.