Article View: comp.windows.ms.programmer
Article #259Re: MS WAVE file format
From: stephen
Date: Thu, 09 Apr 1992 16:43
Date: Thu, 09 Apr 1992 16:43
63 lines
3156 bytes
3156 bytes
In article <1992Apr8.185930.12694@berlioz.nsc.com> you write:
>The book says (on Pg. 8-40)
><WAVE-form> -> RIFF( 'WAVE' //Form type
> <fmt-ck> // Waveform format
> <data-ck> ) // Waveform data
>
><fmt-ck> -> fmt( <wave-format> // WaveFormat Structure
> <format-specific> // Dependent on format category
>
><wave-format> -> struct {WORD formatTag; // Format Category
> WORD nChannels; // No. channels
> DWORD nSamplesPerSec; // Sampling Rate
> DWORD nAvgBytesPerSec; // For buffering
> WORD nBlockAlign;} // Block alignments
>
><PCM-format-specific> -> struct {WORD nBitsPerSample;} //Sample Size
>
><data-ck> -> data( <wave-data> )
>As you can see, I found where the text is that says RIFF, WAVE, fmt, etc...
>But I am a bit confused because I can't find the parantheses, etc...
<smirk> Okay. In the RIFF specification documents, they say that the
notation XXXX( <term> ...) means the following occurs in memory:
XXXX = 4 characters
<size> = 4 byte length of chunk in bytes
<term> = whatever data should follow
>I would really appreciate it if anyone could explain this differences to me
>or send me any current and more detailed information on the WAVE file format.
>Since I rarely, if ever, read news, please send email to me personally...
>ding
>52 49 46 46 RIFF <- Right
>46 2D 0 0 <- Length of rest of file
>57 41 56 45 WAVE <- Right
>66 6D 74 fmt <- Close it's "fmt "(note the space)
>20 10 0 0 0 1 0 1 0 22 56 0 <- fmt chunk size (4 bytes)
>0 22 56 0 0 1 0 8 0 fmt type (2 bytes)
num channels (2 bytes)
samples_per_sec (4 bytes)
ave_bytes_per_sec (4 bytes)
block_size (2 bytes)
bits_per_sample (2 bytes)
>64 61 74 61 data <- Right
>22 2D 0 0 <- Length of this chunk
>80 80 80 80 80 80 80 80 80.... <- The Data
Hope that clears things up some. If you are really curious, I wrote a program
from the specification to parse WAVE files and convert them to SND files.
Also, be aware that even though people usually format the file the way you have
it above that the RIFF spec does not state that the <fmt> chunk must precede
the <data> chunk. Oddly enough, they can be reversed! The size information
is provided so that people reading the file can know how much memory to
allocate to read in the chunk, and for people who are scanning the file to
skip past a chunk they are not interested in. It is legal to put bitmaps
(and other stuff) in a RIFF Wave file!
Good luck,
Stephen.
Technical Details
Message-ID:
<1992Apr9.164358.28424@ibmpa.awdpa.ibm.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!panews!russian.awdpa.ibm.com!stephenReferences:
<1992Apr8.185658.12584@berlioz.nsc.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.ms.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!panews!russian.awdpa.ibm.com!stephen From: stephen@ibmpa.awdpa.ibm.com Subject: Re: MS WAVE file format Message-ID: <1992Apr9.164358.28424@ibmpa.awdpa.ibm.com> Keywords: multimedia, WAVE, MS Windows Sender: news@ibmpa.awdpa.ibm.com (News Master) Organization: IBM PS Programming, Palo Alto References: <1992Apr8.185658.12584@berlioz.nsc.com> Date: Thu, 9 Apr 92 16:43:58 GMT