DSP Blockset    
From Wave File

Read audio data from a Microsoft Wave (.wav) file. (32-bit Windows operating systems only)

Library

Platform-specific I/O / Windows (WIN32)

Description

The From Wave File block reads 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 PCM (pulse code modulation) format.

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. If 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 in either case.

If the audio file contains two channels (stereo), the block's output is an M-by-2 matrix containing one frame (M consecutive samples) of audio data from each of the two channels. If the audio file contains a single channel (mono), the block's output is an M-by-1 matrix containing one frame (M consecutive samples) of mono audio data. The frame size, M, is specified by the Samples per 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 (L M). For L <M, the block instead acquires M consecutive samples during each access. Larger values of L result in fewer file accesses, which reduces run-time overhead.

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.

Dialog Box

File name
The path and name of the file to read. Paths can be relative or absolute.
Samples per output frame
The number of samples in each output frame, M.
Minimum number of samples for each read from file
The number of consecutive samples to acquire from the file with each file access, L.
Data Type
The output data type: double-precision, single-precision, signed 16-bit integer, or unsigned 8-bit integer. The data type setting determines the output's amplitude range, as shown in the table above.

Supported Data Types

To learn how to convert data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.

See Also

From Wave Device
DSP Blockset
Signal From Workspace
DSP Blockset
To Wave File
DSP Blockset
wavread
MATLAB

See Importing WAV Files for related information. Also see Windows (WIN32) for a list of all the blocks in the Windows (WIN32) library.


  From Wave Device Histogram