## WAVREAD Read a WAV Audio File

Section: Input/Ouput Functions

### Usage

The `wavread` function (attempts) to read the contents of a linear PCM audio WAV file. This function could definitely use improvements - it is based on a very simplistic notion of a WAV file. The simplest form for its use is

       y = wavread(filename)

where `filename` is the name of the WAV file to read. If no extension is provided, FreeMat will add a '.wav' extension. This loads the data from the WAV file into `y`, and returns it in `double` precision, normalized format. If you want additional information on, for example, the WAV sampling rate or bit depth, you can request it via

      [y, SamplingRate, BitDepth] = wavread(filename)

where `SamplingRate` and `BitDepth` are the sampling rate (in Hz) and the bit depth of the original data in the WAV file. If you only want to load part of the WAV file, you can use

      [...] = wavread(filename, N)

where `N` indicates the number of samples to read from the file. Alternately, you can indicate a range of samples to load via

      [...] = wavread(filename, [N1 N2])

which returns only the indicated samples from each channel in the file. By default, the output format is `double` precision. You can cntrol the format of the output by indicating

      [...] = wavread(filename, format)

where `format` is either `'double'` for double precision output, or `'native'` for native precision output (meaning whatever bitdepth that was present in the original file). Finally, you can use the `'size'` flag

      y_siz = wavread(filename,'size')

which returns a vector `[samples channels]` indicating the size of the data present in the WAV file.