home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 February / PCWorld_2000-02_cd.bin / Software / Servis / FFE / SOUND.SWG / 0025_WAV.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-04  |  4.7 KB  |  89 lines

  1. ┌──────────────────────┬─────────────────────────────────────────────────────
  2. │ The RIFF File Format │
  3. └──────────────────────┘
  4.  
  5. WAV  files use the RIFF file structure. The RIFF format was designed for
  6. multi-media purposes. A RIFF files consists of a number of "chunks":
  7.  
  8.   ┌────────────────────────────────────────────────────────────────────────┐
  9.   │ Byte              Length                                               │
  10.   │ Offset   Name   (in bytes)    Description                              │
  11.   ├────────────────────────────────────────────────────────────────────────┤
  12.   │ 00h      rID        4h        Contains the characters "RIFF"           │
  13.   │ 04h      rLen       4h        The length of the data in the next chunk │
  14.   │ 08h      rData     rLen       The data chunk                           │
  15.   └────────────────────────────────────────────────────────────────────────┘
  16.  
  17.  
  18. ┌──────────────────────────┬─────────────────────────────────────────────────
  19. │ The WAVE Form Definition │
  20. └──────────────────────────┘
  21.  
  22. The rData chunk in a WAV file is split up into several further chunks:
  23.  
  24.  ┌─────────────────────────────────────────────────────────────────────────┐
  25.  │ rData                                                                   │
  26.  │ Byte              Length                                                │
  27.  │ Offset   Name   (in bytes)    Description                               │
  28.  ├─────────────────────────────────────────────────────────────────────────┤
  29.  │ 00h      wID        4h        Contains the characters "WAVE"            │
  30.  │ 04h      Format    14h        Contains data which specifies the format  │
  31.  │          Chunk                  of the Data in the Data Chunk           │
  32.  │ 18h      WAVE Data  ?         Contains the WAV audio data               │
  33.  │          Chunk                                                          │
  34.  └─────────────────────────────────────────────────────────────────────────┘
  35.  
  36.  
  37.  
  38. ┌──────────────────┬─────────────────────────────────────────────────────────
  39. │ The Format Chunk │
  40. └──────────────────┘
  41.  
  42. The Format Chunk is split up into these fields:
  43.  
  44. ┌─────────────────────────────────────────────────────────────────────────┐
  45. │ Format                                                                  │
  46. │ Chunk                  Length                                           │
  47. │ Offset  Name         (in bytes)   Description                           │
  48. ├─────────────────────────────────────────────────────────────────────────┤
  49. │ 00h     fId               4       Contains the characters "fmt"         │
  50. │ 04h     fLen              4       Length of data in the format chunk    │
  51. │ 08h     wFormatTag        2       *                                     │
  52. │ 0Ah     nChannels         2       Number of channels, 1=mono, 2=stereo  │
  53. │ 0Ch     nSamplesPerSec    2       Playback frequency                    │
  54. │ 0Eh     nAvgBytesPerSec   2       **                                    │
  55. │ 10h     nBlockAlign       2       ***                                   │
  56. │ 12h     FormatSpecific    2       Format specific data area             │
  57. └─────────────────────────────────────────────────────────────────────────┘
  58.  
  59. * The wFormatTag specifies the wave format, eg 1 = Pulse Code Modulation
  60.   (or in plain english, regular 8 bit sampled uncompressed sound)
  61.  
  62. ** Indicates the average number of bytes a second the data should be
  63.    transferred at = nChannels * nSamplesPerSec * (nBitsPerSample / 8)
  64.  
  65. *** Indicates the block alignment of the data in the data chunk. Software
  66.     needs to process a multiplt of nBlockAlign at a time.
  67.     nBlockAlign = nChannels * (nBitsPerSample / 8)
  68.  
  69.  
  70. ┌────────────────┬───────────────────────────────────────────────────────────
  71. │ The Data Chunk │
  72. └────────────────┘
  73.  
  74. The Data Chunk is split up into these fields:
  75.  
  76. ┌─────────────────────────────────────────────────────────────────────────┐
  77. │  Data                                                                   │
  78. │ Chunk                  Length                                           │
  79. │ Offset  Name         (in bytes)   Description                           │
  80. ├─────────────────────────────────────────────────────────────────────────┤
  81. │ 00h     dId              4        Contains the characters "data"        │
  82. │ 02h     dLen             4        Length of data in the dData field     │
  83. │ 00h     dData            dLen     The actual waveform data              │
  84. └─────────────────────────────────────────────────────────────────────────┘
  85.  
  86. In  mono  8-bit files each byte  represents  one sample. In stereo 8-bit
  87. files  two bytes are stored for each  sample, the first byte is the left
  88. channel value, the next is the right channel value.
  89.