Audio Device Writer
Play to sound card
Libraries:
Audio Toolbox /
Sinks
DSP System Toolbox /
Sinks
Description
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.
Examples
Decrease Underrun
Examine the Audio Device Writer block in a Simulink® model, determine underrun, and decrease underrun.
Channel Mapping
Examine the Audio Device Writer block in a Simulink® model and specify a nondefault channel mapping.
Ports
Input
Port_1 — Input signal
scalar | vector | matrix
If 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
Output
Port_1 — Number of samples underrun
scalar
This port outputs the number of samples underrun while writing a frame of data (one input matrix).
Dependencies
To enable this port, select the Output number of samples underrun parameter.
Data Types: uint32
Parameters
Driver — Driver used to access your audio device
DirectSound
(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 have an Audio Toolbox™ license.
Device — Device used to play audio samples
default audio device (default)
The device list is populated with devices available on your computer.
Info — View information about your audio output configuration
button
This 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 rate
on (default) | off
When 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 data
44100
(default) | positive scalar
The possible range of Sample rate (Hz) depends on your audio hardware.
Dependencies
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 conversion
16-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 have an Audio Toolbox license.
Use default channel mapping — Toggle channel mapping source
on (default) | off
When 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 | vector
Nondefault 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 have an Audio Toolbox license.
Dependencies
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 underrun
off (default) | on
When 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).
Block Characteristics
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
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 thepackNGo
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.
Version History
Introduced in R2016a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)