dsp.AudioFileReader
Stream from audio file
Description
The dsp.AudioFileReader
System object™ reads audio samples from an audio file.
To read audio samples from an audio file:
Create the
dsp.AudioFileReader
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 reader System object, afr
= dsp.AudioFileReaderafr
that reads audio from an audio file.
returns an audio file reader object, afr
= dsp.AudioFileReader(Filename
)afr
, with
Filename
property set to
Filename
.
returns an audio file reader System object, afr
= dsp.AudioFileReader(Name,Value
)afr
, with each specified property set to the
specified value. Enclose each property name in single quotes. Unspecified
properties have default values.
Properties
Usage
Description
outputs one frame of
audio samples, audio
= afr()audio
. You can specify the number of times
to play the file using the PlayCount
property. After
playing the file for the number of times you specify, audio
contains silence.
Output 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
For MP3, MPEG-4 AAC, and AVI audio files on Windows 7 or later and Linux® platforms,
dsp.AudioFileReader
object can read fewer samples than expected. On Windows platforms, this is due to a limitation in the underlying Media Foundation framework. On Linux platforms, this is due to a limitation in the underlying GStreamer framework. If you require sample-accurate reading, work with WAV or FLAC files.To read OPUS files on a Linux machine, ensure that you have installed
libsndfile 1.0.29
or a later version. On Windows and Mac, this file is shipped with MATLAB and is available under$MATLABROOT/bin/<platform>
.
Algorithms
This object implements the algorithm, inputs, and outputs described on the From Multimedia File block reference page. The object properties correspond to the block parameters, except:
The object has no corresponding property for the Inherit sample time from file block parameter. The object always inherits the sample time from the file.
The object has no corresponding property for the Output end-of-file indicator parameter. The object always outputs
EOF
as the last output.The object has no corresponding property for the Multimedia Outputs parameter because audio is the only supported output.
The object has no corresponding property for the Image signal block parameter.
The object has no corresponding property for the Output color format parameter.
The object has no corresponding property for the Video output data type parameter.