Next: , Up: Audio Processing   [Contents][Index]

33.1 Audio File Utilities

The following functions allow you to read, write and retrieve information about audio files. Various formats are supported including wav, flac and ogg vorbis.

Loadable Function: info = audioinfo (filename)

Return information about an audio file specified by filename.

Loadable Function: [y, fs] = audioread (filename)
Loadable Function: [y, fs] = audioread (filename, samples)
Loadable Function: [y, fs] = audioread (filename, datatype)
Loadable Function: [y, fs] = audioread (filename, samples, datatype)

Read the audio file filename and return the audio data y and sampling rate fs.

The audio data is stored as matrix with rows corresponding to audio frames and columns corresponding to channels.

The optional two-element vector argument samples specifies starting and ending frames.

The optional argument datatype specifies the datatype to return. If it is "native", then the type of data depends on how the data is stored in the audio file.

Loadable Function: audiowrite (filename, y, fs)
Loadable Function: audiowrite (filename, y, fs, name, value, …)

Write audio data from the matrix y to filename at sampling rate fs with the file format determined by the file extension.

Additional name/value argument pairs may be used to specify the following options:


Number of bits per sample, valid values are 8, 16, 24 and 32. Default is 16.


Valid argument name, but ignored. Left for compatibility with MATLAB.


Quality setting for the Ogg Vorbis compressor. Values can range between 0 and 100 with 100 being the highest quality setting. Default is 75.


Title for the audio file.


Artist name.



Next: , Up: Audio Processing   [Contents][Index]