Skip to Main Content Skip to Search
Product Documentation

wavwrite - Write WAVE (.wav) sound file

Syntax

wavwrite(y,filename)
wavwrite(y,Fs,filename)
wavwrite(y,Fs,N,filename)

Description

wavwrite(y,filename) writes the data stored in the variable y to a WAVE file called filename. The filename input is a string enclosed in single quotes. The data has a sample rate of 8000 Hz and is assumed to be 16-bit. Each column of the data represents a separate channel. Therefore, stereo data should be specified as a matrix with two columns.

wavwrite(y,Fs,filename) writes the data stored in the variable y to a WAVE file called filename. The data has a sample rate of Fs Hz and is assumed to be 16-bit.

wavwrite(y,Fs,N,filename) writes the data stored in the variable y to a WAVE file called filename. The data has a sample rate of Fs Hz and is N-bit, where N is 8, 16, 24, or 32.

Input Data Ranges

The range of values in y depends on the number of bits specified by N and the data type of y. The following tables list the valid input ranges based on the value of N and the data type of y.

If y contains integer data:

N Bitsy Data Typey Data RangeOutput Format
8uint80 <= y <= 255uint8
16int16–32768 <= y <= +32767int16
24int32–2^23 <= y <= 2^23 – 1int32

If y contains floating-point data:

N Bitsy Data Typey Data RangeOutput Format
8single or double–1.0 <= y < +1.0uint8
16single or double–1.0 <= y < +1.0int16
24single or double–1.0 <= y < +1.0int32
32single or double–1.0 <= y <= +1.0single

For floating point data where N < 32, amplitude values are clipped to the range –1.0 <= y < +1.0.

See Also

audioplayer | audiorecorder | mmfileinfo | sound | wavfinfo | wavread

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS