What do the bytes in a .wav file represent?

后端 未结 6 1007
醉话见心
醉话见心 2020-12-04 08:40

When I store the data in a .wav file into a byte array, what do these values mean? I\'ve read that they are in two-byte representations, but what exactly is contained in the

6条回答
  •  悲&欢浪女
    2020-12-04 09:17

    The WAVE (.wav) file contain a header, which indicates the formatting information of the audio file's data. Following the header is the actual audio raw data. You can check their exact meaning below.

    Positions  Typical Value Description
    
    1 - 4      "RIFF"        Marks the file as a RIFF multimedia file.
                             Characters are each 1 byte long.
    
    5 - 8      (integer)     The overall file size in bytes (32-bit integer)
                             minus 8 bytes. Typically, you'd fill this in after
                             file creation is complete.
    
    9 - 12     "WAVE"        RIFF file format header. For our purposes, it
                             always equals "WAVE".
    
    13-16      "fmt "        Format sub-chunk marker. Includes trailing null.
    
    17-20      16            Length of the rest of the format sub-chunk below.
    
    21-22      1             Audio format code, a 2 byte (16 bit) integer. 
                             1 = PCM (pulse code modulation).
    
    23-24      2             Number of channels as a 2 byte (16 bit) integer.
                             1 = mono, 2 = stereo, etc.
    
    25-28      44100         Sample rate as a 4 byte (32 bit) integer. Common
                             values are 44100 (CD), 48000 (DAT). Sample rate =
                             number of samples per second, or Hertz.
    
    29-32      176400        (SampleRate * BitsPerSample * Channels) / 8
                             This is the Byte rate.
    
    33-34      4             (BitsPerSample * Channels) / 8
                             1 = 8 bit mono, 2 = 8 bit stereo or 16 bit mono, 4
                             = 16 bit stereo.
    
    35-36      16            Bits per sample. 
    
    37-40      "data"        Data sub-chunk header. Marks the beginning of the
                             raw data section.
    
    41-44      (integer)     The number of bytes of the data section below this
                             point. Also equal to (#ofSamples * #ofChannels *
                             BitsPerSample) / 8
    
    45+                      The raw audio data.            
    

    I copied all of these from http://www.topherlee.com/software/pcm-tut-wavformat.html here

提交回复
热议问题