Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
WAV
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==File specifications== ===RIFF=== A RIFF file is a tagged file format. It has a specific container format (a ''chunk'') with a header that includes a four-character tag ([[FourCC]]) and the size (number of bytes) of the chunk. The tag specifies how the data within the chunk should be interpreted, and there are several standard FourCC tags. Tags consisting of all capital letters are reserved tags. The outermost chunk of a RIFF file has a <code>RIFF</code> tag; the first four bytes of chunk data are an additional FourCC tag that specify the form type and are followed by a sequence of subchunks. In the case of a WAV file, the additional tag is <code>WAVE</code>. The remainder of the RIFF data is a sequence of chunks describing the audio information. The advantage of a tagged file format is that the format can be extended later while maintaining [[backward compatibility]].<ref>{{Harvnb|IBM|Microsoft|1991|p=1{{hyphen}}1}}<!--HYPEN PAGE - not a page range -->, "The main advantage of RIFF is its extensibility; file formats based on RIFF can be future-proofed, as format changes can be ignored by existing applications."</ref> The rule for a RIFF (or WAV) reader is that it should ignore any tagged chunk that it does not recognize.<ref>{{Harvnb|IBM|Microsoft|1991|loc=PDF p. 56}}, "Programs must expect (and ignore) any unknown chunks encountered, as with all RIFF forms."</ref> The reader will not be able to use the new information, but the reader should not be confused. The specification for RIFF files includes the definition of an <code>INFO</code> chunk. The chunk may include information such as the title of the work, the author, the creation date, and copyright information. Although the <code>INFO</code> chunk was defined for RIFF in version 1.0, the chunk was not referenced in the formal specification of a WAV file. Many readers had trouble processing this. Consequently, the safest thing to do from an interchange standpoint was to omit the <code>INFO</code> chunk and other extensions and send a lowest-common-denominator file. There are other [[Resource Interchange File Format#INFO chunk placement problems|INFO chunk placement problems]]. RIFF files were expected to be used in international environments, so there is <code>CSET</code> chunk to specify the country code, language, dialect, and [[code page]] for the strings in a RIFF file.<ref>{{Harvnb|IBM|Microsoft|1991|pp=2{{hyphen}}17 to 2{{hyphen}}18}}</ref> For example, specifying an appropriate <code>CSET</code> chunk should allow the strings in an <code>INFO</code> chunk (and other chunks throughout the RIFF file) to be interpreted as Cyrillic or Japanese characters. RIFF also defines a <code>JUNK</code> chunk whose contents are uninteresting.<ref>{{Harvnb|IBM|Microsoft|1991|p=2{{hyphen}}18}}</ref> The chunk allows a chunk to be deleted by just changing its FourCC. The chunk could also be used to reserve some space for future edits so the file could be modified without being resized. A later definition of RIFF introduced a similar <code>PAD</code> chunk.<ref>Microsoft Multimedia Standards Update, New Multimedia Data Types and Data Techniques, Revision 3.0, April 15, 1994, page 6.</ref> ===RIFF WAVE=== The top-level definition of a WAV file is:<ref>{{Harvnb|IBM|Microsoft|1991|loc=PDF p. 56}}</ref> <pre><WAVE-form> β RIFF('WAVE' <fmt-ck> // Format of the file [<fact-ck>] // Fact chunk [<cue-ck>] // Cue points [<playlist-ck>] // Playlist [<assoc-data-list>] // Associated data list <wave-data> ) // Wave data </pre> The top-level RIFF form uses a <code>WAVE</code> tag. It is followed by a mandatory <code><nowiki><fmt-ck></nowiki></code> chunk that describes the format of the sample data that follows. This chunk includes information such as the sample encoding, number of bits per channel, the number of channels, and the sample rate. The WAV specification includes some optional features. The optional <code><nowiki><fact-ck></nowiki></code> chunk reports the number of samples for some compressed coding schemes. The <code><nowiki><cue-ck></nowiki></code> chunk identifies some significant sample numbers in the wave file. The <code><nowiki><playlist-ck></nowiki></code> chunk allows the samples to be played out of order or repeated rather than just from beginning to end. The associated data list (<code><nowiki><assoc-data-list></nowiki></code>) allows labels and notes to be attached to cue points; text annotation may be given for a group of samples (e.g., caption information). Finally, the mandatory <code><nowiki><wave-data></nowiki></code> chunk contains the actual samples in the format previously specified. Note that the WAV file definition does not show where an <code>INFO</code> chunk should be placed. It is also silent about the placement of a <code>CSET</code> chunk (which specifies the character set used). The RIFF specification attempts to be a formal specification, but its formalism lacks the precision seen in other tagged formats. For example, the RIFF specification does not clearly distinguish between a set of subchunks and an ordered sequence of subchunks.<!-- Compare ASN SET-OF and SEQUENCE-OF --> The RIFF form chunk suggests it should be a sequence container. Sequencing information is specified in the RIFF form of a WAV file consistent with the formalism: "However, <code><nowiki><fmt-ck></nowiki></code> must always occur before <code><nowiki><wave-data></nowiki></code>, and both of these chunks are mandatory in a WAVE file."<ref>{{Harvnb|IBM|Microsoft|1991|loc=PDF p. 56}}</ref> The specification suggests a <code>LIST</code> chunk is also a sequence: "A LIST chunk contains a list, or ordered sequence, of subchunks."<ref>{{Harvnb|IBM|Microsoft|1991|loc=PDF p. 23}}</ref> However, the specification does not give a formal specification of the <code>INFO</code> chunk; an example <code>INFO</code> <code>LIST</code> chunk ignores the chunk sequence implied in the <code>INFO</code> description.<ref>{{Harvnb|IBM|Microsoft|1991|loc=PDF p. 21}}, <code>INAM</code> appears before <code>ICOP</code></ref> The <code>LIST</code> chunk definition for <code><nowiki><wave-data></nowiki></code> does use the <code>LIST</code> chunk as a sequence container with good formal semantics. The WAV specification supports, and most WAV files use, a single contiguous array of audio samples. The specification also supports discrete blocks of samples and silence that are played in order. The specification for the sample data contains apparent errors:<ref>Specification from {{Harvnb|IBM|Microsoft|1991}} which also describes how the production syntax is interpreted.</ref> <pre>The <wave-data> contains the waveform data. It is defined as follows: <wave-data> β { <data-ck> | <data-list> } <data-ck> β data( <wave-data> ) <wave-list> β LIST( 'wavl' { <data-ck> | // Wave samples <silence-ck> }... ) // Silence <silence-ck> β slnt( <dwSamples:DWORD> ) // Count of silent samples </pre> Apparently <code><nowiki><data-list></nowiki></code> (undefined) and <code><nowiki><wave-list></nowiki></code> (defined but not referenced) should be identical. Even with this resolved, the productions then allow a <code><nowiki><data-ck></nowiki></code> to contain a [[Recursion (computer science)|recursive]] <code><nowiki><wave-data></nowiki></code> (which implies data interpretation problems). To avoid the recursion, the specification can be interpreted as: <pre><wave-data> β { <data-ck> | <wave-list> } <data-ck> β data( <bSampleData:BYTE> ... ) <wave-list> β LIST( 'wavl' { <data-ck> | // Wave samples <silence-ck> }... ) // Silence <silence-ck> β slnt( <dwSamples:DWORD> ) // Count of silent samples </pre> WAV files can contain embedded IFF ''lists'', which can contain several ''sub-chunks''.<ref>{{cite web |date=1999-11-15 |title=WAVE File Format |url=https://www.borg.com/~jglatt/tech/wave.htm |url-status=dead |archive-url=https://web.archive.org/web/19991115123323/https://www.borg.com/~jglatt/tech/wave.htm |archive-date=1999-11-15 |access-date=2010-03-16}}</ref><ref>{{cite web |url=https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ |title=WAVE PCM soundfile format |date=2003-01-20 |access-date=2010-03-16 |archive-url=https://web.archive.org/web/20090827003349/https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ |archive-date=2009-08-27 |url-status=dead }}</ref><ref>{{cite web |url=https://www.lightlink.com/tjweber/StripWav/WAVE.html |title=The WAVE File Format |access-date=2010-03-16 |archive-url=https://web.archive.org/web/20110722003211/https://www.lightlink.com/tjweber/StripWav/WAVE.html |archive-date=2011-07-22 |url-status=dead}}</ref> === WAV file header === This is an example of a WAV file header (44 bytes). Data is stored in little-endian byte order. [Master RIFF chunk] FileTypeBlocID (4 bytes) : Identifier Β« RIFF Β» (0x52, 0x49, 0x46, 0x46) FileSize (4 bytes) : Overall file size minus 8 bytes FileFormatID (4 bytes) : Format = Β« WAVE Β» (0x57, 0x41, 0x56, 0x45) [Chunk describing the data format] FormatBlocID (4 bytes) : Identifier Β« fmtβ£ Β» (0x66, 0x6D, 0x74, 0x20) BlocSize (4 bytes) : Chunk size minus 8 bytes, which is 16 bytes here (0x10) AudioFormat (2 bytes) : Audio format (1: PCM integer, 3: IEEE 754 float) NbrChannels (2 bytes) : Number of channels Frequency (4 bytes) : Sample rate (in hertz) BytePerSec (4 bytes) : Number of bytes to read per second (Frequency * BytePerBloc). BytePerBloc (2 bytes) : Number of bytes per block (NbrChannels * BitsPerSample / 8). BitsPerSample (2 bytes) : Number of bits per sample [Chunk containing the sampled data] DataBlocID (4 bytes) : Identifier Β« data Β» (0x64, 0x61, 0x74, 0x61) DataSize (4 bytes) : SampledData size SampledData
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)