WAV file format detailed

Source: Internet
Author: User

WAV (waveform audio format) is a sound encoding format developed by Microsoft and IBM that complies with the riff (Resource Interchange File format) files specification for saving the audio information resources of the Windows platform. Widely supported by the Windows platform and its applications, it is also one of the specified specifications commonly used by its music enthusiasts. Because this audio format is not compressed, there is no distortion in the sound quality, but the volume of the archive is larger in many audio formats. The format supports a variety of audio numbers, sampling frequency and channels, standard formatted WAV file and CD format, as well as 44.1K sampling frequency, 16-bit quantization number, so the sound file quality and CD-like. The WAV Open tool is a media player for Windows. The first four bytes of each wave file are "RIFF". Wave files consist of two main parts: the file header and the data body. The file header is divided into riff/wav file identification segment and sound data Format Description Section two parts. The contents and formats of wave files are shown in the table below.

Offset address

Number of bytes

Type

Content

00h~03h

4

Character

Resource Exchange file Flags (RIFF)

04h~07h

4

Long integers

The total number of bytes from the next address to the end of the file

08h~0bh

4

Character

WAV file Flag (WAVE)

0ch~0fh

4

Character

Waveform format flag (FMT)

10h~13h

4

Integer

Filter bytes (typically 00000010H)

14h~15h

2

Integer

Type of format (value 1 o'clock, indicates data is linear PCM encoded)

16h~17h

2

Integer

Number of channels, mono is 1, dual sound is 2

18h~1bh

4

Long integers

Sampling frequency

1ch~1fh

4

Long integers

Waveform data transfer rate (average bytes per second)

20h~21h

2

Integer

Number of adjustments in data (in bytes)

22h~23h

2

Integer

Number of sample data bits

File header

Sound data block

Offset address

Number of bytes

Type

Content

24h~27h

4

Character

Data identifiers

28h~2bh

4

Long integer type

Total sampled data

2CH ...

...

Sampled data

Example

The following image is a partial screenshot of a WAV file opened with UltraEdit

This WAV file is completed using the window recorder software, generated 16 of the content of the file, using a small segment storage format (high-address storage, low-address storage) in bytes storage (8bit)

Supplemental header File Sample Description:

(1) "52 49 46 46" This is the ASCII character "RIFF", which is part of a fixed format that indicates that this is a wave file header.
(2) "22 60 28 00" This is the data size of my WAV file, which includes all bytes except for the previous 4 bytes, which is equal to the total number of bytes of the file minus 8. The 16 binary "22 60 28 00" corresponds to the decimal "2646050".
(3) "6D 74 20" is also the ASCII character "Wavefmt", which is a fixed format.
Later is the Pcmwaveformat part

(4) "12 00 00 00", this is a DWORD, corresponding to the number 18, this corresponds to the size of the pcmwaveformat part of the definition, you can see that the following paragraph content is exactly 18 bytes. In general, the size is 16, when the last additional information is not, the above file has more than two bytes of additional information.
(5) "01 00", which is a word that corresponds to the encoding format (WAVE_FORMAT_PCM format is generally used for this).
(6) "01 00", which is a word, corresponds to the number 1, which indicates the number of channels is 1, is a mono wav.
(7) "22 56 00 00" Corresponds to the number 22050, which represents the sampling frequency 22050, sample rate (samples per second), indicating the playback speed of each channel
(8) "8 AC 00 00" Corresponds to the number 44100, which represents the amount of data per second, the waveform audio data transfer rate, the value is the number of channels x samples per second x per sample of data bits/(1*22050*16/8). The playback software uses this value to estimate the size of the buffer.
(9) "02 00" corresponds to the number 2, which represents the content of the block alignment. The number of adjustments (in bytes) of the data block whose value is the number of channels x data bit value per sample/8. The playback software needs to process more than one byte of this value at a time in order to use its value for buffer adjustment.
(10) "10 00" value is 16, the sample size is 16Bits, the number of bits per sample, indicating the number of data bits for each sample in each channel. If there are multiple channels, the sample size is the same for each channel.
(11) "00 00" Here is the additional information (optional), and the size in (4) corresponds.

(a) "four-to-one" fact is an optional field, typically when a WAV file is converted from some software, it is included, the "XX" fact field is 4 bytes in size, "f82f 14 00" is the fact data.

(13) "64 61 74 61", this is the ASCII character "data", which marks the end of the header and begins the data area.
(+) "F0 5F 28 00" hexadecimal number is "0x285ff0", corresponding to the decimal 2646000, is the beginning of the data area, the total number of data, look at the front just can see, the file size is 2646050, From (2) to (13) including (13) is exactly the 2646050-2646000=50 byte.

To the back is the real wave file data body, the parsing of the header file is here.

There are two main types of sound files, which correspond to mono (11.025KHz sample rate, 8Bit sample value) and dual channel (44.1KHz sample rate, 16Bit sample value). The sampling rate is the number of times the sound signal is sampled in units of time during the "modulo → number" conversion process. The sampled value refers to the integral value of the sound analog signal during each sampling period.
For mono sound files, the sampled data is a eight-bit short integer (00H-FFH), whereas for a two-channel stereo sound file, each sampled data is a 16-bit integer (int), and the high eight-bit and low eight-bit respectively represent the left and right two channels.
Wave file data blocks contain samples expressed in pulse-coded modulation (PCM) format. Wave files are organized by samples. In a mono wave file, Channel 0 represents the left channel and Channel 1 represents the right channel. In a multichannel wave file, the sample is alternately present.
 

How PCM data is stored:
Sample 1 Sample 2
8-bit mono 0-Channel 0-Channel
8-bit stereo 0-channel (left) 1-channel (right) 0-channel (left) 1-channel (right)
16-bit mono 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

Other digest borrowing---wav conversion MP3 format

MP3 Everyone must be very familiar with, but to convert the WAV format sound file to MP3 format, you may first think of looking for a special format conversion tool, in fact, not so complicated, you have a ready-made tool, which is the windows attached to the "recorder", Using this tool can be the easiest way to implement the WAV format to MP3 format, the specific operation is as follows.

Click start → programs → accessories → entertainment → Sound Recorder, open the Sound Recorder program, click the File menu, open the WAV file that you want to convert from the file, click file → save As, click the Change button in the Save As dialog box, select MPEG layer-3 in the Format box Format, everything will be OK.

In the conversion, if you want to control the size of the file, such as to make the sound better or to make the file more compact, you can select the "Properties" in the "sound selection" in the window, select the lower or higher sampling frequency in the bar, how, is not very convenient, try it quickly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.