Reprinted --- Analysis of the wave file format
As one of the acoustic file formats used in multimedia, the wave file is in the riff format as the standard.
Riff is the abbreviation of resource interchange file format. The first four
The byte is "riff ". A wave file consists of a file header and a data body. The file header is divided
It is the identifier segment of the riff/WAV file and the description segment of the audio data format. The contents and
The format is shown in the appendix.
There are two types of common audio files, which correspond to the single-channel (11.025khz sampling rate, 8 bit
And dual-channel (44.1khz sampling rate, 16-bit sampling value ). Sampling Rate refers to: Sound Signal
Number of times of sampling per unit time during "modulo → count" conversion. Sample value refers to each sampling period
The integral value of the internal voice analog signal.
For single-channel audio files, the sample data is an eight-bit short INTEGER (short int 00h-ffh );
For dual-channel stereo audio files, each sampling data is a 16-bit integer (INT), 8 in height.
Bits and bits represent the left and right channels.
The data block of the wave file contains samples in Pulse-Coded Modulation (PCM) format. Wave
Parts are organized by samples. In a single channel wave file, channel 0 indicates the left channel, and channel 1 indicates the right channel.
Audio channel. In a multi-channel wave file, samples are generated alternately.
Wave file format description
Offset address byte data type capacity
File Header
00 H 4 char "riff" flag
04 H 4 long int file length
08 H 4 char "wave" flag
0ch 4 char "FMT" flag
10 H 4 transition byte (optional)
14 H 2 int format category (10 h is PCM sound data)
16 h, 2 int channels, 1 single channel, 2 dual channels
18 h 2 int sampling rate (number of samples per second), indicating the playback speed of each channel,
1ch 4 long int waveform audio data transmission rate. The value is the number of channels × number of data digits per second × per sample
The number of bits/8. The playback software can use this value to estimate the buffer size.
Adjust the number of 20 H 2 int data blocks (calculated in bytes). The value is the number of channels × data bit per sample.
Value/8. The playback software needs to process multiple bytes of data of this value at a time
The value is used to adjust the buffer.
22 h 2 indicates the number of data digits of each sample in each channel. If there are many
Channels. The sample size is the same for each channel.
24 h 4 char data tag "data"
28 H 4 long int Voice Data Length
Storage Method of PCM Data:
Sample 1 sample 2
8-bit single-channel 0-channel 0-Channel
8-bit stereo sound, 0 channels (left), 1 channel (right), 0 channels (left), 1 channel (right)
16-bit single-channel 0-channel low byte 0-channel high byte 0-channel low byte 0-channel high byte
16-bit stereo 0-channel (left) Low byte 0-channel (left) high byte 1-channel (right) Low byte 1-channel (right) high byte
Each sample value in the wave file is included in an integer I. The length of I is required to accommodate the specified sample length.
The minimum number of bytes. First, store low valid bytes, indicating that the bit of the sample amplitude is placed on the high valid bit of I,
The remaining position is 0, so the data format of the 8-bit and 16-bit PCM waveform samples is as follows.
Sample size data format maximum value minimum value
8-bit PCM unsigned int 225 0
16-bit PCM int 32767
Author: easily injured man |
This post address: http://club.yesky.com/bbs/jsp/view.jsp? ArticleID = 275485 |