Main Content


End-of-file status (logical)



STATUS = isDone(afr) returns a logical value, STATUS. The value of STATUS is true when the file has been read PlayCount number of times. The PlayCount property of the dsp.AudioFileReader System object™ determines the number of times the audio file plays.


collapse all

Read and play back an audio file using the standard audio output device.

Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, obj() becomes step(obj).

You can choose to read the entire data or specify a range of data to read from using the ReadRange property. By default, ReadRange is set to [1 inf], indicating the file reader to read the entire data from the source. In this example, set ReadRange to 3Fs, indicating the file reader to read the first 3 seconds of the data.

afr = dsp.AudioFileReader('speech_dft.mp3','ReadRange',[1 3*22050]);
adw = audioDeviceWriter('SampleRate', afr.SampleRate);

while ~isDone(afr)
    audio = afr();

Input Arguments

collapse all

Audio file reader, specified as a dsp.AudioFileReader System object.

Output Arguments

collapse all

Logical value that indicates if the reader has reached the EOF, returned as:

  • true –– The STATUS is true when the EOF is reached. If the PlayCount property is set to a value greater than 1, STATUS is returned as true only once the reader reaches the EOF PlayCount number of times.

  • false –– The STATUS is false when the EOF has not reached. If PlayCount property is greater than 1, STATUS is returned as false until the EOF has reached PlayCount number of times.

Data Types: logical

Version History

Introduced in R2012a

See Also