解码Wav标头

时间:2014-11-25 20:40:51

标签: c++ header wav

5249 4646 94e5 3703 5741 5645 666d 7420
1000 0000 0100 0200 44ac 0000 10b1 0200
0400 1000 6461 7461 70e5 3703 0000 0000

我无法解码此标头。据我所知,我正在尝试这个 https://ccrma.stanford.edu/courses/422/projects/WaveFormat/。我希望其中一些类似于:频道:2,采样率:44100,音频格式:pcm ......

我做错了什么?

RIFF

ChunkID         4   5249 4646       "RIFF"  
ChunkSize       4   94e5 3703       2498049795      
Format          4   5741 5645       "WAVE"


FMT

Subchunk1ID     4   666d 7420       "fmt "     
Subchunk1Size   4   1000 0000       268435456    
AudioFormat     2   0100            256       
NumChannels     2   0200            512    
SampleRate      4   44ac 0000       1152122880    
ByteRate        4   10b1 0200       280035840    
BlockAlign      2   0400            1024    
BitsPerSample   2   1000            4096


DATA

Subchuk2ID      4   6461 7461       "data"    
Subchunk2Size   4   70e5 3703       1894070019    
data 

1 个答案:

答案 0 :(得分:2)

您没有考虑到endian。这些值是小端的,但你将它们解释为大端。

正确的细分如下:

RIFF

ChunkID         4   52 49 46 46       "RIFF"  
ChunkSize       4   94 e5 37 03       53994900
Format          4   57 41 56 45       "WAVE"


FMT

Subchunk1ID     4   66 6d 74 20       "fmt "     
Subchunk1Size   4   10 00 00 00       16    
AudioFormat     2   01 00             1       
NumChannels     2   02 00             2    
SampleRate      4   44 ac 00 00       44100    
ByteRate        4   10 b1 02 00       176400    
BlockAlign      2   04 00             4    
BitsPerSample   2   10 00             16


DATA

Subchuk2ID      4   64 61 74 61       "data"    
Subchunk2Size   4   70 e5 37 03       53994864    
data