Play to sound card
The audioDeviceWriter
System object™ writes audio samples to an audio output device. Properties of the audio device
writer specify the driver, the device, and device attributes such as sample rate, bit depth,
and buffer size.
Data Flow of Audio Device Writer
Call the object to input an audio signal frame to the
audioDeviceWriter
.
The audioDeviceWriter
uses the specified driver to pass the frame
(device input) to the buffer of your specified audio device.
The audio device performs digital-to-analog conversion at the specified sample rate and bit depth.
The audio device outputs an analog chunk to your speaker.
To stream data to an audio device:
Create the audioDeviceWriter
object and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?.
returns a
System object, deviceWriter
= audioDeviceWriterdeviceWriter
, that writes audio samples to an audio
output device in real time.
sets the SampleRate property to
deviceWriter
= audioDeviceWriter(sampleRateValue
)sampleRateValue
.
sets each property deviceWriter
= audioDeviceWriter(___,Name,Value
)Name
to the specified Value
.
Unspecified properties have default values.
deviceWriter = audioDeviceWriter(48000,'BitDepth','8-bit
integer')
creates a System object, deviceWriter
, that operates at a 48 kHz sample rate and
an 8-bit integer bit depth.
writes one frame of audio samples, numUnderrun
= deviceWriter(audioToDevice
)audioToDevice
, to the selected
audio device and returns the number of audio samples underrun since the last call to
deviceWriter
.
Note: When you call the audioDeviceWriter
System object, the audio device specified by the Device
property is
locked. An audio device can be locked by only one audioDeviceWriter
at a
time. To release the audio device, call release
on your
audioDeviceWriter
System object.
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named obj
, use
this syntax:
release(obj)
Audio Device Writer | dsp.AudioFileReader
| dsp.AudioFileWriter
| asiosettings
(Audio Toolbox) | getAudioDevices
(Audio Toolbox)