Stream from audio file
Thedsp。AudioFileReader
System object™ reads audio samples from an audio file.
To read audio samples from an audio file:
Create thedsp。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, seeWhat 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
, withFilename
property set toFile 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 thePlayCount
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 namedobj
, use this syntax:
release(obj)
For MP3, MPEG-4 AAC, and AVI audio files onWindows 7or 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 theFrom Multimedia Fileblock reference page. The object properties correspond to the block parameters, except:
The object has no corresponding property for theInherit sample time from fileblock parameter. The object always inherits the sample time from the file.
The object has no corresponding property for theOutput end-of-file indicatorparameter. The object always outputsEOF
as the last output.
The object has no corresponding property for theMultimedia Outputsparameter because audio is the only supported output.
The object has no corresponding property for theImage signalblock parameter.
The object has no corresponding property for theOutput color formatparameter.
The object has no corresponding property for theVideo output data typeparameter.