New WAVE RIFF Chunks

 


Added: 05/01/92
Author: Microsoft, IBM

Most of the information in this section comes directly from the IBM/Microsoft RIFF standard document.

The WAVE form is defined as follows. Programs must expect (and ignore) any unknown chunks encountered, as with all RIFF forms. However, <'fmt'-ck> must always occur before , and both of these chunks are mandatory in a WAVE file.

®
RIFF( 'WAVE'
<'fmt'-ck> // Format
[] // Fact chunk
[] // Cue points
[] // Playlist
[] // Associated data list
) // Wave data

The WAVE chunks are described in the following sections.

Fact Chunk

The stores file dependent information about the contents of the WAVE file. This chunk is defined as follows:

® fact( )

 

<dwSampleLength> represents the length of the data in samples. The <nSamplesPerSec> field from the wave format header is used in conjunction with the <dwSampleLength> field to determine the length of the data in seconds.

The fact chunk is required for all new WAVE formats. The chunk is not required for the standard WAVE_FORMAT_PCM files.

The fact chunk will be expanded to include any other information required by future WAVE formats. Added fields will appear following the field. Applications can use the chunk size field to determine which fields are present.

Cue Points Chunk

The <cue-ck> cue-points chunk identifies a series of positions in the waveform data stream. The is defined as follows:

® cue( // Count of cue points
... ) // Cue-point table

® struct {
DWORD dwName;
DWORD dwPosition;
FOURCC fccChunk;
DWORD dwChunkStart;
DWORD dwBlockStart;
DWORD dwSampleOffset;
}

The <cue-point> fields are as follows:

Field Description
dwName Specifies the cue point name. Each record must have a unique dwName field.
dwPosition Specifies the sample position of the cue point. This is the sequential sample number within the play order. See "Playlist Chunk," later in this document, for a discussion of the play order.
fccChunk Specifies the name or chunk ID of the chunk containing the cue point.
dwChunkStart Specifies the position of the start of the data chunk containing the cue point. This should be zero if there is only one chunk containing data (as is currently always the case).
dwBlockStart Specifies the position of the start of the block containing the position. This is the byte offset from the start of the data section of the chunk, not the chunk's FOURCC.
dwSampleOffset Specifies the sample offset of the cue point relative to the start of the block.

Examples of File Position Values

The following table describes the field values for a WAVE file containing a single 'data' chunk:

Cue Point Location Field Value
Within PCM data fccChunk FOURCC value 'data'.
  dwChunkStart Zero value.
  dwBlockStart File position of the sample (nBlockAlign aligned bytes) relative to the start of the data section of the 'data' chunk (not the FOURCC).
  dwSampleOffset Sample position of the cue point relative to the start of the 'data' chunk.
In all other 'data' chunks fccChunk FOURCC value 'data'.
  dwChunkStart Zero value.
  dwBlockStart File position of the enclosing block relative to the start of the data section of the 'data' chunk (not the FOURCC). The software can begin the decompression at this point.
  dwSampleOffset Sample position of the cue point relative to the start of the block.

Playlist Chunk

The playlist chunk specifies a play order for a series of cue points. The is defined as follows:

® plst(
// Count of play segments
... ) // Play-segment table

® struct {
DWORD dwName;
DWORD dwLength;
DWORD dwLoops;
}

The <play-segment> fields are as follows:

Field Description
dwName Specifies the cue point name. This value must match one of the names listed in the cue-point table.
dwLength Specifies the length of the section in samples.
dwLoops Specifies the number of times to play the section.

Associated Data Chunk

The associated data list provides the ability to attach information like labels to sections of the waveform data stream. The is defined as follows:

® LIST( 'adtl'

// Label

// Note

} // Text with data length

 

® labl(

)

 

® note(

)

 

® ltxt(

... )

 

Label and Note Information

The 'labl' and 'note' chunks have similar fields. The 'labl' chunk contains a label, or title, to associate with a cue point. The 'note' chunk contains comment text for a cue point. The fields are as follows:

Field Description
dwName Specifies the cue point name. This value must match one of the names listed in the cue-point table.
data Specifies a NULL-terminated string containing a text label (for the 'labl' chunk) or comment text (for the 'note' chunk).

Text with Data Length Information

The "ltxt" chunk contains text that is associated with a data segment of specific length. The chunk fields are as follows:

Field Description
dwName Specifies the cue point name. This value must match one of the names listed in the cue-point table.
dwSampleLength Specifies the number of samples in the segment of waveform data.
dwPurpose Specifies the type or purpose of the text. For example, can specify a FOURCC code like 'scrp' for script text or 'capt' for close-caption text.
wCountry Specifies the country code for the text. See "Country Codes" for a current list of country codes.
wLanguage,
wDialect
Specify the language and dialect codes for the text. See "Language and Dialect Codes" for a current list of language and dialect codes.
wCodePage Specifies the code page for the text.

 

inst (Instrument) Chunk

Added: 12/29/92
Author: IBM
Defined for: WAVE form

The WAVE form is NEARLY the perfect file format for storing a sampled sound synthesizer's samples. Bits per sample, sample rate, number of channels, and complex looping can be specified with current WAVE subchunks, but a sample's pitch and its desired volume relative to other samples cannot. The optional instrument subchunk defined below fills in these needed parameters:

|| ® inst(

)

bUnshiftedNote the MIDI note number that corresponds to the unshifted pitch of the sample. Valid values range from 0 to 127.
chFineTune the pitch shift adjustment in cents (or 100ths of a semitone) needed to hit bUnshiftedNote value exactly. chFineTune can be used to compensate for tuning errors in the sampling process. Valid values range from -50 to 50.
chGain the suggested volume setting for the sample in decibels. A value of zero decibels suggests no change in the volume. A value of -6 decibels suggests reducing the amplitude of the sample by two.
bLowNote and bHigh Note the suggested usable MIDI note number range of the sample. Valid values range from 0 to 127.
bLowVelocity and bHighVelocity the suggested usable MIDI velocity range of the sample. Valid values range from 0 to 127.

smpl (Sample) Chunk

Added: 11/09/93
Author: Digidesign, Sonic Foundary, Turtle Beach
Defined for: WAVE form

The sampled instrument chunk describes the minimum necessary information needed to allow a sampling keyboard to use a WAVE file as an instrument. Samplers which require more information can save their extended information in the sampler specific data section. The is defined as follows:

|| ® smpl(

)

 

struct

{

DWORD dwIdentifier;

DWORD dwType;

DWORD dwStart;

DWORD dwEnd;

DWORD dwFraction;

DWORD dwPlayCount;

}

 

The chunk:

dwManufacturer Specifies the MMA Manufacturer code for the intended target device. The high byte indicates the number of low order bytes (1 or 3) that are valid for the manufacturer code. For example, this value will be 0x01000013 for Digidesign (the MMA Manufacturer code is one byte, 0x13); whereas 0x03000041 identifies Microsoft (the MMA Manufacturer code is three bytes, 0x00 0x00 0x41). If the sample is not intended for a specific manufacturer, then this field should be set to zero.
dwProduct Specifies the Product code of the intended target device for the dwManufacturer. If the sample is not intended for a specific manufacturer's product, then this field should be set to zero.
dwSamplePeriod Specifies the period of one sample in nanoseconds (normally 1/nSamplesPerSec from the WAVEFORMAT structure for the RIFF WAVE file--however, this field allows fine tuning). For example, 44.1 kHz would be specified as 22675 (0x00005893).
dwMIDIUnityNote Specifies the MIDI note which will replay the sample at original pitch. This value ranges from 0 to 127 (a value of 60 represents Middle C as defined by the MMA).
dwMIDIPitchFraction Specifies the fraction of a semitone up from the specified dwMIDIUnityNote. A value of 0x80000000 is 1/2 semitone (50 cents); a value of 0x00000000 represents no fine tuning between semitones.
dwSMPTEFormat Specifies the SMPTE time format used in the dwSMPTEOffset field. Possible values are (unrecognized formats should be ignored):
0 - specifies no SMPTE offset (dwSMPTEOffset should also be zero)
24 - specifies 24 frames per second
25 - specifies 25 frames per second
29 - specifies 30 frames per second with frame dropping ('30 drop')
30 - specifies 30 frames per second
dwSMPTEOffset Specifies a time offset for the sample if it is to be syncronized or calibrated according to a start time other than 0. The format of this value is 0xhhmmssff. hh is a signed Hours value [-23..23]. mm is an unsigned Minutes value [0..59]. ss is unsigned Seconds value [0..59]. ff is an unsigned value [0..( - 1)].
cSampleLoops Specifies the number (count) of records that are contained in the chunk. The records are stored immediately following the cbSamplerData field.
cbSamplerData Specifies the size in bytes of the optional . Sampler specific data is stored imediately following the records. The cbSamplerData field will be zero if no extended sampler specific information is stored in the chunk.

The structure:

dwIdentifier Identifies the unique 'name' of the loop. This field may correspond with a name stored in the chunk. The name data is stored in the chunk.
dwType Specifies the loop type:
0 - Loop forward (normal)
1 - Alternating loop (forward/backward)
2 - Loop backward
3-31 - reserved for future standard types
32-? - sampler specific types (manufacturer defined)
dwStart Specifies the startpoint of the loop in samples.
dwEnd Specifies the endpoint of the loop in samples (this sample will also be played).
dwFraction Allows fine-tuning for loop fractional areas between samples. Values range from 0x00000000 to 0xFFFFFFFF. A value of 0x80000000 represents 1/2 of a sample length.
dwPlayCount Specifies the number of times to play the loop. A value of 0 specifies an infinite sustain loop.