| Signal Processing Blockset™ | ![]() |
Signal Processing Sources
dspsrcs4

The From Wave File block streams audio data from a Microsoft Wave (.wav) file and generates a signal with one of the data types and amplitude ranges in the following table.
| Output Data Type | Output Amplitude Range |
|---|---|
double | ±1 |
single | ±1 |
int16 | -32768 to 32767 (-215 to 215 - 1) |
uint8 | 0 to 255 |
The audio data must be in uncompressed pulse code modulation (PCM) format.
y = wavread('filename') % Equivalent MATLAB code
The block supports 8-, 16-, 24-, and 32-bit Microsoft Wave (.wav) files.
The File name parameter can specify an absolute or relative path to the file. When the file is on the MATLAB® path or in the current directory (the directory returned by typing pwd at the MATLAB command line), you need only specify the file's name. You do not need to specify the.wav extension.
For an audio file containing C channels, the block's output is an M-by-C matrix containing one frame (M consecutive samples) of audio data from each channel. The frame size, M, is specified by the Samples per output frame parameter. For M=1, the output is sample based; otherwise, the output is frame based.
The output frame period, Tfo, is
![]()
where Fs is the data sample rate in Hz.
To reduce the required number of file accesses, the block acquires L consecutive samples from the file during each access,
where L is specified by the Minimum number
of samples for each read from file parameter (
). For
, the block instead
acquires M consecutive samples during each access.
Larger values of L result in fewer file accesses,
which reduces run-time overhead.
Use the Data type parameter to specify the data type of the block's output. Your choices are double, single, uint8, or int16.
Select the Loop check box if you want to play the file more than once. Then, enter the number of times to play the file. The number you enter must be a positive integer or inf.
Use the Number of times to play file parameter to enter the number of times to play the file. The number you enter must be a positive integer or inf, to play the file until you stop the simulation.
The Samples restart parameter determines whether the samples from the audio file repeat immediately or repeat at the beginning of the next frame output from the output port. When you select immediately after last sample, the samples repeat immediately. When you select at beginning of next frame, the frame containing the last sample value from the audio file is zero padded until the frame is filled. The block then places the first sample of the audio file in the first position of the next output frame.
Use the Output start-of-file indicator parameter to determine when the first audio sample in the file is output from the block. When you select this check box, a Boolean output port labeled SOF appears on the block. The output from the SOF port is 1 when the first audio sample in the file is output from the block. Otherwise, the output from the SOF port is 0.
Use the Output end-of-file indicator parameter to determine when the last audio sample in the file is output from the block. When you select this check box, a Boolean output port labeled EOF appears on the block. The output from the EOF port is 1 when the last audio sample in the file is output from the block. Otherwise, the output from the EOF port is 0.
The block icon shows the name, sample rate (in Hz), number of channels (1 or 2), and sample width (in bits) of the data in the specified audio file. All sample rates are supported; the sample width must be either 8, 16, 24, or 32 bits.

Enter the path and name of the file to read. Paths can be relative or absolute.
Enter the number of samples in each output frame, M. When the value of this parameter is 1, the block outputs a sample-based signal.
Enter the number of consecutive samples to acquire from the file with each file access, L.
Select the output data type: double, single, uint8, or int16. The data type setting determines the output's amplitude range, as shown in the preceding table.
Select this check box if you want to play the file more than once.
Enter the number of times you want to play the file.
Select immediately after last sample to repeat the audio file immediately. Select at beginning of next frame to place the first sample of the audio file in the first position of the next output frame.
Use this check box to determine whether the output contains the first audio sample in the file.
Use this check box to determine whether the output contains the last audio sample in the file.
Double-precision floating point
Single-precision floating point
16-bit signed integer
8-bit unsigned integer
| From Audio Device | Signal Processing Blockset |
| Signal From Workspace | Signal Processing Blockset |
| To Wave File | Signal Processing Blockset |
| wavread | MATLAB |
![]() | From Wave Device | G711 Codec | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |