Audio Toolkit - dsp.AudioFileReader


dsp.AudioFileReader

Read audio samples from a audio file

obj = AudioFileReader ()
obj = AudioFileReader (filename)
obj = AudioFileReader (propertyname, propertyvalue …)

Create a AudioFileReader object

Inputs

filename - filename to read
propertyname, propertyvalue - properties to set on the object.

Properties

Known creation properties are:

Filename

Filename to load data from.

OutputDataType

Output data type of ’single’ or ’double’ (default ’double’)

SamplesPerFrame

Samples per frame as returned from () (default 1024)

PlayCount

Number of times to play the file (default 1)

ReadRange

Vector start, stop range of the samples within the file (default [1 Inf])

Read-only properties accessable after file is loaded:

SampleRate

sample rate of the data

NumChannels

Number of channels in the data

TotalSamples

Number of samples in the data

TotalDuration

Approximate time of the data during playback

Outputs

obj - AudioFileReader object

Examples

Create a audio reader for reading in a sample file, and then extract each from ntil the file is completed.

 afr = dsp.AudioFileReader("sample.wav")
 while ! isDone(afr)
   data = afr();
 endwhile
 

Read in a file using 4096 frames, file playes twice.

 afr = dsp.AudioFileReader("Filename", "sample.wav", "SamplesPerFrame", 4096, "PlayCount", 2)
 while ! isDone(afr)
   data = afr();
 endwhile
 
[data. iseof] = obj()

Generate a frame of waveform data from the generator function, iseof will be true if the end of file was reached at any point during reading the frame.

Inputs

obj - AudioFileReader object

Outputs

data - waveform data

release(obj)

Release resources of generator

Inputs

obj - AudioFileReader object

Outputs

None

tf = isDone(obj)

Return status of iterating the data.

Inputs

obj - AudioFileReader object

Outputs

tf - true if at end of file and data has been iterated playcount times