Play to sound card
Audio Toolbox / Sinks
DSP System Toolbox / Sinks
The Audio Device Writer block writes audio samples to an audio output device.
Parameters of the Audio Device Writer block specify the driver, the device, and device attributes such as sample rate and bit depth.
Port_1
— Input signalIf input to the Audio Device Writer block is
of data type double
or single
,
the block clips values outside the range [–1, 1]. For other
data types, the allowed input range is [min, max] of the specified
data type.
Data Types: single
| double
| int16
| int32
| uint8
Port_1
— Number of samples underrunThis port outputs the number of samples underrun while writing a frame of data (one input matrix).
To enable this port, select the Output number of samples underrun 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 frame
size (number of rows) input to the Audio Device
Writer block. 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, supply an audio stream with 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.
To specify nondefault Driver values, you must install Audio Toolbox™. If the toolbox is not installed, specifying nondefault Driver values returns an error.
Device
— Device used to play audio samplesThe device list is populated with devices available on your computer.
Info
— View information about your audio output configurationThis button opens a dialog box that lists your selected audio driver, the full name of your audio device, and the maximum output channels for your configuration. For example:
Inherit sample rate from input
— Specify source of input sample rateWhen you select this parameter, the block inherits its sample rate from the input signal. When you clear this parameter, you specify the sample rate in Sample rate (Hz).
Sample rate (Hz)
— Sample rate used by device to play audio data44100
(default) | positive scalarThe possible range of Sample rate (Hz) depends on your audio hardware.
To enable this parameter, clear the Inherit sample rate from input parameter.
Device bit depth
— Data type used by device to perform digital-to-analog conversion16-bit integer
(default) | 8-bit integer
| 24-bit integer
| 32-bit float
Before performing digital-to-analog conversion, the input data is cast to a data type specified by this parameter.
Note
To specify a nondefault Device bit depth, you must install Audio Toolbox. If the toolbox is not installed, specifying a nondefault Device bit depth returns an error.
Use default channel mapping
— Toggle channel mapping sourceWhen you select this parameter, the block uses the default mapping between columns of the matrix input to this block and the channels of your device. When you clear this parameter, you specify the mapping in Device output channels.
Device output channels
— Specify nondefault channel mapping[1:MaximumOutputChannels]
(default) | scalar | vectorNondefault mapping between columns of matrix input to the Audio Device Writer block and channels of output device, specified as a scalar or vector. For example:
If Device output channels is specified as
1:3
, then:
The first column of the input matrix maps to channel 1.
The second column of the input matrix maps to channel 2.
The third column of the input matrix maps to channel 3.
If Device output channels is specified as
[3,1,2]
, then:
The first column of the input matrix maps to channel 3.
The second column of the input matrix maps to channel 1.
The third column of the input matrix maps to channel 2.
Note
To selectively map between columns of the input matrix and your sound card's output channels, you must install Audio Toolbox. If the toolbox is not installed, specifying nondefault values for Device output channels returns an error.
To enable this parameter, clear the Use default mapping between columns of input of this block and sound card’s output channels parameter.
Output number of samples underrun
— Specify output port for number of samples underrunWhen you select this parameter, an output port is added to the block. The port outputs the number of samples underrun while writing a frame of data (one input matrix).
The following code generation limitations apply:
Host computer only. Excludes Simulink® Desktop Real-Time™ code generation.
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 block 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.