Go WAVE PCM sound file format

Source: Internet
Author: User

The wave file format is part of Microsoft's riff specification for storing multimedia. A riff file starts with a file header and then a series of data blocks. A wave file is often made up of only one wave block, which contains a format-formatted FMT block and a data block that stores the sampled information.

Standard wave file format

Offset

Length (bytes)

Variable name

Describe

Note

0

4

Chunkid

ASCII character "RIFF", big-endian form

Riff Head

4

4

ChunkSize

36+subchunk2size, i.e.: 4 + (8 + subchunk1size) + (8 + subchunk2size), refers to the number of bytes after the first 8 bytes of the file

Riff Head

8

4

Format

ASCII character "WAVE", big-endian form

Riff Head

12

4

Subchunk1id

ASCII character "FMT", big-endian form

FMT Sub-block

16

4

Subchunk1size

For PCM files is 16. Refers to the FMT block size except the first 8 bytes

FMT Sub-block

20

2

Audioformat

Pcm=1, other values are compressed in some way (see table 2)

FMT Sub-block

22

2

Numchannels

Mono = 1, stereo =2

FMT Sub-block

24

4

Samplerate

Sampling rate, take 16000

FMT Sub-block

28

4

Byterate

Samplerate * Numchannels * BITSPERSAMPLE/8

FMT Sub-block

32

2

Blockalign

Numchannels * bitspersample/8, Total bytes of one sample data in all channels

FMT Sub-block

34

2

BitsPerSample

8 or 16

FMT Sub-block

36

4

Subchunk2id

ASCII string "Data"

Data sub-block

40

4

Subchunk2size

NumSamples * Numchannels * BITSPERSAMPLE/8, refers to the number of bytes in the data

Data sub-block

44

*

Data

The actual sound data

Table 2 Format Code encoding

Format encoding

preprocessing symbols

Data

0x0001

Wave_format_pcm

Pcm

0x0003

Wave_format_ieee_float

Ieee float

0x0006

Wave_format_alaw

8bits ITU-T G.711 A-law

0x0007

Wave_format_mulaw

8-bit ITU-T G.711 U-law

0xFFFE

Wave_format_extensible

Attention:

1) wave file default byte order is the small end order, if the big-endian order with RIFX instead of riff logo

2) The sampled data must be even bytes

3) 8-bit sampling data is stored as an unsigned number, from 0 to 255.16 bits of sampled data is stored as a complement, from 32768 to 32767

4) There may be additional sub-blocks in the wave data stream. Each sub-block has char subchunkid[4],unsigned long subchunksize and subchunksize bytes of data

5) Riff represents resource interchange File Format

Transferred from: http://blog.csdn.net/foxwit/article/details/5802389

Go WAVE PCM sound file format

Related Article

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.