Introduction
VOC is the sound file of Creative Labs’ Sound Blaster cards, from the MS-DOS era. Many DOS games stored their speech and sound effects as VOC files, and the tools that came with the card recorded and played them. The audio is usually 8-bit unsigned PCM, and the file can also hold silence, markers, text and repeat loops.
Structure
The file starts with the text Creative Voice File and the byte
1A, 20 bytes in all. Three little-endian 16-bit values follow: the offset
of the first block (usually 26), the version (such as 0x010A or
0x0114) and a check value equal to the complement of the version plus
0x1234.
The rest is a list of blocks. Each block starts with a type byte and a 24-bit length. Type 1 holds sound data, starting with a time constant byte (the sample rate is 1000000 / (256 − time constant)) and a codec byte. Type 2 continues the previous sound data. Other types give silence (3), a marker (4), text (5), the start and end of a repeat (6 and 7), extended settings for stereo and high rates (8), and sound data with an explicit sample rate, bit depth and channel count (9). A block of type 0 ends the file. See Blocks and Codecs and sample rates.
0Signature Creative Voice File, 1A20 bytes20Header data offset, version, check value6 bytes26Blocks type, 24-bit length, datarepeated…Terminator block type 01 byte
Not described
These pages follow Creative’s own description (appendix B of the Sound Blaster Series Hardware Programming
Guide), VOC.TXT and its fax addendum, the MultimediaWiki, ModdingWiki, and the readers in SoX,
FFmpeg and DOSBox. The explorer reads the header and blocks 0 to 9
field by field, shows any other block type as an “unknown block”, and plays 8-bit unsigned and 16-bit signed PCM,
A-law, µ-law and the Creative ADPCM codecs 1, 2, 3 and 0x0200, following continued sound, silence (counted in the
sound’s rate), extended blocks and repeats (a repeat for ever is played once). Tested on 45 real .voc files, the
three real Creative ADPCM files of FFmpeg’s samples, and built cases (codec 0x0200 sample for sample against FFmpeg).
FFmpeg’s own VOC writer (8-bit, 16-bit, A-law and µ-law, mono and stereo, several rates) and files with every
time constant, block 8, block 9, continued sound and missing terminators decode sample for sample the same in
FFmpeg and in the explorer. The Creative ADPCM codecs 1 to 3 are the exception: FFmpeg’s decoder uses another rule
(see below), so they are checked against the real recordings and DOSBox’s tables instead.
Known, not yet covered
- Viewer: the waveform of Creative ADPCM 1 to 3 (a reference byte shifts the byte-to-sample mapping), and of sounds made of several blocks, repeats or silence, is not linked to bytes. A sound that is one run of PCM, or of codec 0x0200, is. Each run of one format is one sound with one waveform, exact peak and RMS levels and Play over the whole of it, however long: there is no cap on the number of samples. PCM, A-law and µ-law are read anywhere in the sound; Creative ADPCM runs in order and keeps decoder checkpoints, so a jump far into a long sound starts at the nearest one. Every sound is in the Sounds table when there are more than 16.
- Reference and viewer: the ADPCM of stereo sound (several channels): not described by Creative, taken as one reference byte a channel with alternating codes (as in FFmpeg).
- Viewer: the playback has no limit on the plain pass through the file: every block and run is reachable (a built 318,766,800-frame 8-bit file, a file of 4,100,001 sound blocks, and sounds of 8.6 and 10 million frames are tested). Repeats are nodes, not copies, so a frame deep inside nested loops is found by arithmetic, and the levels and overview of a repeated PCM sound are worked out from one pass of the repeat, exact. Three limits are left and stated by the viewer: a sound is clamped at 2^52 frames (four nested repeats of tens of thousands of passes go past it); a repeat that holds blocks of several formats lists its passes one by one, as far as 2 million blocks; and a repeated Creative ADPCM sound, whose every pass continues the decoder state of the one before, is read from the start through every pass, so its waveform, levels and Play cover its first 2^30 frames. An endless repeat (0xFFFF) is played once. A fourth limit is for damaged or made-up files only: repeats nested more than 200 deep are not followed past the 200th (their sections play once, and the viewer says so); real files nest one or two deep.
Unknown
- Reference and viewer: the data layout of the multi-DAC pack values (4 to 10, “3 plus channels”)
of blocks 1 and 8, named in
VOC.TXTand quoted from an edition of the “Sound Blaster: The Official Book” on the MultimediaWiki’s talk page. Creative’s guide and the book’s second edition (read in full, appendix A and chapter 12) list only 0 to 3, and no source describes the layout. The viewer names the value and does not decode it. - Reference: the repeat count of block 6: the Sound Blaster Official Book (second edition: “repeated
by the driver for Count + 1 times”, count 1 to 0xFFFE), the wikis and the viewer read the section as played count + 1
times;
VOC.TXTsays the count is the repetitions + 1 (played count times), and Creative’s guide says only “the number of times to repeat”. The word “repeated” can be read either way; DISCO.VOC’s counts of 7, 3, 3, 7 point to count + 1 passes. Creative’s CT-VOICE documentation (the Norton Guide text of the 1992 alt.sb.programmer posting) says the blocks between are “repeated by the CT-VOICE driver for (COUNT+1) times”, count 1 to FFFE, the same words as the Official Book (both cited on the blocks page). See the blocks page. - Reference: the exact rule of the Sound Blaster’s ADPCM: Creative’s guide gives none. 4-bit and 2-bit follow SoX and DOSBox and agree on the real BBC files; the 2.6-bit rule used here (last row 16, the last code a 2-bit code) differs from SoX and DOSBox, and Creative documents none. The MultimediaWiki’s “Creative 8 bits ADPCM” page, which FFmpeg’s decoders follow, calls its own rule guesswork, and says VOCEDIT 2 (VEDIT2.EXE, from the Sound Blaster Pro; the Official Book says the same, and that each data block is compressed on its own, with a reference byte) can compress PCM into all three codecs, so a real encoder exists to settle the rules by encoding known sound; its file (VOICE.LZH on “Sound Blaster Pro Disk #2”) was not found as a download, and nothing has been run. Whether the codec 0x0200 state restarts at each new block 9 is not stated anywhere.
Links
Software
Developers
- libsndfile – library that reads and writes VOC (C)
Reference
- Creative Voice – the MultimediaWiki’s description of the blocks and codecs
- VOC Format – the Game Modding wiki’s description, with notes on old and new blocks
- Raw audio sources – VOC sound data as headerless PCM, and ADPCM