iOS Development--wave Audio file parsing

Source: Internet
Author: User

WAV files are also divided into several categories, the corresponding non-data information stored in the file's head, the following simple mention, and then at the end of the focus on the 44-byte type, the general use is this.

1, 8KHz sampling, 16-bit quantization of linear PCM voice signal wave file Header Format table (total 44 bytes)

Offset address byte Number data type content file header defined as

00h   4   char      "RIFF"   char riff_id[4]= "RIFF"
&nb Sp  04H   4   long   file length -8     long int size0= Length-8
&nbs P  08H   8   char  "wavefmt "      char wave_fmt[8]
10h&  nbsp  4   long       Filter bytes (typically 10H)   long size1=0x10
14h   2      int      Encoding (01 00h) int fmttag=0x01
16H   2   int channels (1 mono, 2 for two channels) int channel=1  or 2
18H   4   long   Sample rate   Long int samplesper SEC
1ch   4   long     transfer rate         Long int bytepers EC
= Sample Frequency * Number of channels * Quantization/8

20H 2 int block Alignment (sampled bytes) int blockalign= Channels * Quantization number/8
22H 2 int quantization ( sampling accuracy ) int bitpersamples=8 or 16
24H 4 Char "data" char data_id[4]= "data"
28H 4 Long data part length long int size2= Wenchang-44
2CH to end char sample data

2, 8KHz sampling, 8-bit A-law quantization of PCM voice signal wave file Header format table (total 58 bytes)

Offset address byte Number data type content file header defined as
00H 4 Char "RIFF" char riff_id[4]= "RIFF"
04H 4 long int file total length -8-long int size0=-8
08H 8 char "wavefmt" Char wave_fmt[8]
10H 4 long int 12000000H (ALAW) long int size1=0x12
14H 2 int, 00H int fmttag=0x06
16H 2 int channel number int channel=1 or 2
18H 4 long int sample rate long int samplespersec
1CH 4 long int plays bytes per second long int bytepersec
20H 2 int Sampling byte-count int blockalign=0x01
22H 4 Long int quantization number long int bitpersamples=8
26H 4 Char "fact" char wave_fact= "fact"
2AH 8 char 0400000000530700H fixed char temp
32H 4 Char "data" char wave_data= "data"
36H 4 long int sampled data bytes Lont int size2= Wenchang-58

3, 8KHz sampling, 8-bit U-law quantization of PCM voice signal wave file Header format table (total 58 bytes)

Offset address byte Number data type content file header defined as
00H 4 Char "RIFF" char riff_id[4]= "RIFF"
04H 4 long int file total length -8-long int size0=-8
08H 8 char "wavefmt" Char wave_fmt[8]
10H 4 long int 12000000H (ULAW) long int size1=0x12
14H 2 int fmttag=0x07 00H int
16H 2 int channel number int channel=1 or 2
18H 4 long int sample rate long int samplespersec
1CH 4 long int plays bytes per second long int bytepersec
20H 2 int Sampling byte-count int blockalign=0x01
22H 4 Long int quantization number long int bitpersamples=8
26H 4 Char "fact" char wave_fact= "fact"
2AH 8 char 0400000000530700H fixed char temp
32H 4 Char "data" char wave_data= "data"
36H 4 long int sampled data bytes Lont int size2= Wenchang-58

4, ADPCM voice encoded wave file Header format table (total 90 bytes)

Offset address byte Number data type content file header defined as
00H 4 Char "RIFF" char riff_id[4]= "RIFF"
04H 4 long int file total length -8-long int size0=-8
08H 8 char "wavefmt" Char wave_fmt[8]
10H 4 long int 32000000H (ADPCM) long int size1=0x32
14H 2 int 00H int fmttag=0x02
16H 2 int channel number int channel=1 or 2
18H 4 long int sample rate long int samplespersec
1CH 4 long int plays bytes per second long int bytepersec
20H 2 int sampling one time in bytes int blockalign= number of channels * Quantization/8
22H 2 int quantization number int bitpersamples=4
24H Char fixed byte char temp1
46H 4 Char "fact" char wave_fact= "fact"
4AH 8 char 0400000004930600H fixed char temp2
52H 4 Char "data" char wave_data= "data"
56H 4 long int sampled data bytes Lont int size2= Wenchang-90
5AH to end sampled data

5, GSM voice encoded wave file Header format table (total 60 bytes)

Offset address byte Number data type content file header defined as
00H 4 Char "RIFF" char riff_id[4]= "RIFF"
04H 4 long int file total length -8-long int size0=-8
08H 8 char "wavefmt" Char wave_fmt[8]
10H 4 long int 14000000H (GSM) long int size1=0x14
14H 2 int 00H int fmttag=0x31
16H 2 int channel number int channel=1 or 2
18H 4 long int sample rate long int samplespersec
1CH 4 long int plays bytes per second long int bytepersec
20H 8 char 4100000002004001H fixed char Temp1
28H 8 char 6661637404000000H fixed char temp2
30H 4 char E2 00H fixed char Temp3
34H 4 Char "data" char wave_data= "data"
38H 4 long int sampled data bytes Lont int size2= Wenchang-60
3CH to end sampled data

6, SBC Voice encoded wave file Header format table (total 58 bytes)

Offset address byte Number data type content file header defined as
00H 4 Char "RIFF" char riff_id[4]= "RIFF"
04H 4 long int file total length -8-long int size0=-8
08H 8 char "wavefmt" Char wave_fmt[8]
10H 4 long int 12000000H (SBC) long int size1=0x12
14H 2 int 00H int fmttag=0x71
16H 2 int channel number int channel=1 or 2
18H 4 long int sample rate long int samplespersec
1CH 4 long int plays bytes per second long int bytepersec
20H 2 int Sampling byte-count int blockalign=0x25
22H 4 Long int quantization number long int bitpersamples=16
26H 4 Char "fact" char wave_fact= "fact"
2AH 8 char 0400000076280400H fixed char temp
32H 4 Char "data" char wave_data= "data"
36H 4 long int sampled data bytes Lont int size2= Wenchang-59

7, CELP voice encoded wave file Header format table (total 58 bytes)

Offset address byte Number data type content file header defined as
00H 4 Char "RIFF" char riff_id[4]= "RIFF"
04H 4 long int file total length -8-long int size0=-8
08H 8 char "wavefmt" Char wave_fmt[8]
10H 4 long int 12000000H (CELP) long int size1=0x12
14H 2 int 00H int fmttag=0x70
16H 2 int channel number int channel=1 or 2
18H 4 long int sample rate long int samplespersec
1CH 4 long int plays bytes per second long int bytepersec
20H 2 int Sampling byte-count int blockalign=0x0c
22H 4 Long int quantization number long int bitpersamples=16
26H 4 Char "fact" char wave_fact= "fact"
2AH 8 char 0400000060520700H fixed char temp
32H 4 Char "data" char wave_data= "data"
36H 4 long int sampled data bytes Lont int size2= Wenchang-58

iOS Development--wave Audio file parsing

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.