dsp.AudioFileWriter
Stream to audio file
Description
The dsp.AudioFileWriter
System object™ writes audio samples to an audio file.
To write audio samples to an audio file:
Create the
dsp.AudioFileWriter
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?
Creation
Syntax
Description
returns an
audio file writer System object, afw
= dsp.AudioFileWriterafw
. This object writes audio samples to an
audio file.
returns an audio file writer System object, afw
= dsp.AudioFileWriter(Filename
)afw
. This object has the
Filename
property set to
Filename
.
returns an audio file writer object with each specified property set to the
specified value. Enclose each property name in single quotes. Unspecified
properties have default values.afw
= dsp.AudioFileWriter(Name,Value
)
Properties
Usage
Syntax
Description
Input Arguments
Object Functions
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)
Examples
Limitations
The following platform-specific restrictions apply when writing these files:
Versions Windows 7 and later
Only sample rates of 44100 Hz and 48000 Hz are supported for the MPEG-4 AAC file format. For other file formats, there is no restriction on the sample rate.
Only mono or stereo outputs are allowed for the MPEG-4 AAC file format. For all other formats, more than two audio output channels are allowed.
The output data is padded on both the front and back of the signal, with extra samples of silence.
Windows AAC encoder places sharp fade-in and fade-out on audio signals, causing the signals to be slightly longer in samples when written to disk.
A minimum of 1025 samples per channel must be written to the MPEG-4 AAC file.
macOS
Only mono or stereo outputs are allowed for MPEG-4 AAC file format. For all other formats, more than two audio output channels are allowed.
Not all sampling rates are supported, although the Mac Audio Toolbox™ API does not explicitly specify a restriction.
Linux
To support OPUS file format on a Linux machine, you must have
libsndfile 1.0.29
or a later version installed. On Windows and Mac, this file is shipped with MATLAB and is available under$MATLABROOT/bin/<platform>
.To write MP3 files on Linux, you must have
libsndfile 1.1.0
or a later version installed.
Algorithms
This object implements the algorithm, inputs, and outputs described on the To Multimedia File block reference page. The object properties correspond to the block parameters, except:
The object
FileFormat
property does not support video-only file formats.The object has no corresponding property for the Write parameter. The object writes only audio content to files.
The object has no corresponding property for the Video compressor parameter.
The object has no corresponding property for the File color format parameter.
The object has no corresponding property for the Image signal parameter.