Stream from audio file
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?.
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(File name
)afr
, with
Filename
property set to File
name
.
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.
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.
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)
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.
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.