DSP Blockset | ![]() ![]() |
Write audio data to file in the Microsoft Wave (.wav
) format (Windows only).
Library
Description
The To Wave File block writes audio data to a Microsoft Wave (.wav
) file in the uncompressed PCM (pulse code modulation) format. For compatibility reasons, the sample rate of the discrete-time input signal should typically be one of the standard Windows audio device rates (8000, 11025, 22050, or 44100 Hz), although the block supports arbitrary rates.
The input to the block, u, can contain audio data from a mono or stereo signal. A mono signal is represented as either a sample-based scalar or frame-based length-M vector, while a stereo signal is represented as a sample-based length-2 vector or frame-based M-by-2 matrix. The amplitude of the input should be in the range ±1. Values outside this range are clipped to the nearest allowable value.
wavwrite(u,Fs,bits,'filename
') % Equivalent MATLAB code
The Sample Width (bits) parameter specifies the number of bits used to represent the signal samples in the file. Two settings are available:
The 16-bit sample width setting requires more memory but yields better fidelity for double-precision inputs.
The File name parameter can specify an absolute or relative path to the file. You do not need to specify the.wav
extension. To reduce the required number of file accesses, the block writes L consecutive samples to the file during each access, where L is specified by the Minimum number of samples for each write to file parameter (L M). For L <M, the block instead writes M consecutive samples during each access. Larger values of L result in fewer file accesses, which reduces run-time overhead.
Dialog Box
See Also
From Wave File |
DSP Blockset |
To Wave Device |
DSP Blockset |
To Workspace |
Simulink |
wavwrite |
MATLAB |
See Exporting and Playing WAV Files for related information.
![]() | To Wave Device | Transpose | ![]() |