VOC Format

From ModdingWiki
Jump to navigation Jump to search

The Creative Voice File (.voc) consists of a main header, followed by one or more data blocks. The file is in little endian format.

Main header

Data type Name Description
char[19] signature "Creative Voice File"
UINT8 signature2 0x1A
UINT16LE size Size of the main header. Usually 0x001A
UINT16LE version Version number. Usually 0x010A (0x0A 0x01) for the old format, or 0x0114 for the new format
UINT16LE checksum This should equal ~version + 0x1234

Data blocks

All data blocks have a common header:

Data type Name Description
UINT8 type Block type
UINT24LE len Block size, excluding this four-byte header

There are 10 different block types:

0: Terminator

This special block does not contain a size in the header. It is used to indicate the end of the file, though the file can end without it.

1: Sound data with type

This block is generally only used in older files, and has been superceded by block #9.

Data type Name Description
UINT8 freq Frequency divisor
UINT8 codec Codec #, see below
BYTE[...] data Audio data

The sample rate of the file can be determined by:

Sample rate = 1000000 / (256 - frequency divisor)

The codec can be one of the following:

Codec # Name
0x00 8 bits unsigned PCM
0x01 4 bits to 8 bits Creative ADPCM
0x02 3 bits to 8 bits Creative ADPCM (AKA 2.6 bits)
0x03 2 bits to 8 bits Creative ADPCM
0x04 16 bits signed PCM
0x06 alaw
0x07 ulaw
0x0200 4 bits to 16 bits Creative ADPCM. Only valid in block type 9

2: Sound data without type

This block is generally only used in older files, and has been superceded by block #9.

Data type Name Description
BYTE[...] data Audio data

This block uses the same codec as last set by block type 1.

3: Silence

Data type Name Description
UINT16LE len Length of silence - 1, in samples
UINT8 freq Frequency divisor (see block type 1)

4: Marker

Data type Name Description
UINT16LE value Mark value

This marker can be picked up by the playback application to synchronize the sound file with an external animation, or to otherwise perform some action when the marker point has been reached.

5: Text

Data type Name Description
char[...] text Text string, null-terminated

6: Repeat start

This block signals the start of a repeated section. Blocks after this one, up until the next Repeat end block, will be repeated the number of times indicated.

Data type Name Description
UINT16LE count Number of times to repeat minus one (i.e. 0=repeat once, 1=repeat twice, etc.) 0xFFFF means repeat forever.

7: Repeat end

Like the terminator block, this block contains no data. It signals the end of the loop point, and if a loop is in progress, playback jumps back to the block following the most recent Repeat start block.

8: Extra information

This block is generally only used in older files, and has been superceded by block #9.

This block overrides the properties set by earlier blocks. Unlike block #1, this block allows the number of channels to be set, allowing stereo playback. It also increases the frequency divisor from a 8-bit value to 16-bits, allowing finer control of the final sampling rate.

Data type Name Description
UINT16LE freq Frequency divisor
UINT8 codec Codec #, see below
UINT8 numChannels Channel count minus one (0=mono, 1=stereo)

Unlike block #1, there is no audio within this block, so block #2 must be used to play audio with the options set here.

The sample rate of the file can be determined by:

Sample rate = 256000000 / ((numChannels + 1) * (65536 - frequency divisor))

9: Sound data (New format)

This block is (probably) only valid in files with a version >= 1.20 (0x114).

Data type Name Description
UINT32LE rate Sample rate
UINT8 bits Bits per sample (e.g. 8 or 16)
UINT8 numChannels Channel count (1 is mono, 2 is stereo)
UINT16LE codec Codec #
UINT32LE reserved Set to 0
BYTE[...] data Audio data

Source

This page was adapted from MultimediaWiki