Biomedical Engineering Reference
In-Depth Information
erent compression algorithms. The for-
mat tag entry in the fmt chunk indicates the type of compression used. A value of 1 indi-
cates linear pulse-code modulation (PCM), which is a straight, or uncompressed, encoding
of the samples, which is just the exact amplitude of each sample. The fmt chunk describes
the sample format (Table 6.4), and the data chunk contains the sample data (Table 6.5). All
numeric data
The .wav speci
fi
cation supports a number of di
ff
fields are in the Intel format of low-high byte (usually referred to as little-
endian ). Eight-bit samples are stored as unsigned bytes, ranging from 0 to 255; 16-bit sam-
ples are stored as 2's-complement signed integers, ranging from -32768 to 32767.
If you are a Matlab user, you can avoid the hassle of
fi
file formatting by playing a data
stream directly from within the Matlab environment using the “sound” command. Matlab can
also write .wav
fi
file PCM-encoded signal into data
that can be manipulated by Matlab. Another possibility is to use a professional waveform
fi
files from data variables or read the .wav
fi
TABLE 6.4
Contents of the Format Chunk of a .wav File
Offset
Length (bytes)
Contents
12
4
fmt
16
4
0x00000010
which is the length of the fmt data (16 bytes)
20
2
0x0001
which is the data-encoding format tag: 1 PCM
22
2
channels
which defines the number of channels: 1, mono; 2, stereo
24
4
sample rate
in samples per second (e.g., 44,100)
28
4
bytes/second
sample rate block align
32
2
block align
channels bits/sample/8
34
2
bits/sample
8 or 16
TABLE 6.5
The Data Chunk of a .wav File Contains the Actual Sample Data
Offset
Length (bytes)
Contents
36
4
data
40
4
length of the data block
44
As needed for data
sample data
For multichannel data, samples are interleaved
between channels:
sample 0 for channel 0
sample 0 for channel 1
sample 1 for channel 0
sample 1 for channel 1
.
.
.
where channel 0 is the left channel and channel 1
is the right channel; the sample data must end
on an even byte boundary.
 
Search WWH ::




Custom Search