From MultimediaWiki
Jump to navigation Jump to search


The information on this page is based on a document found on and other sites on the internet, and originated on GAP's (Game Audio Player) website (now defunct). The information was originally by Valery V. Anisimovsky (no valid email address known)

CLU Resource Files

All numbers in all structures described are stored in files using little-endian (Intel) byte order.

Music/speech/sound files of Broken Sword 2 are stored in CLU resource files. Each music/speech/sound CLU file has the following header:

struct tagCLUHeader
 DWORD dwNumber;
 char	szID[4];
} CLUHeader;

szID -- string ID is always "\xFF\xF0\xFF\xF0".

dwNumber -- the number of files stored in CLU file.

After the header comes the array of (dwNumber) directory entries. Each directory entry contains the info on a file in CLU archive. Each such entry has the following format:

struct tagCLUDirEntry
 DWORD dwStart;
 DWORD dwSize;
} CLUDirEntry;

dwStart -- the starting position of the file relative to the beginning of the CLU archive.

dwSize -- the size of the file.

Note that there're some entries with zero (dwStart) or (dwSize) -- they correspond to the files absent in the given CLU archive (the files with the same numbers may be found in the corresponding CLU archive on the other game CD).

After the array of directory entries come the files contained in CLU archive.

NOTE: The CLU files containing other types of game data have different format. It's not described here.

CLUSFX Music/Speech/Sound Files

All of the music/speech/sfx files are of the same format which is referred to here as CLUSFX. A CLUSFX file has a simple format -- just a 16-bit initial predictor value followed by a compressed waveform stream. When decompressed, all music/speech/sfx files are 16-bit mono PCM samples replayed at 22050 Hz. (signed or unsigned? presumably signed --Multimedia Mike)

All CLUSFX files are compressed using CLU ADPCM compression algorithm.

CLU ADPCM Decompression Algorithm

A CLU file begins with a 16-bit initial predictor value that is not sent to the output. The compressed stream is comprised of a sequence of bytes. The 8 bits of each byte have the following meaning:

 bits 7-4    delta magnifier
 bit 3       sign bit
 bits 2-0    delta base

For each byte:

 delta = (delta base) << (delta magnifier)
 if the sign bit is cleared
   predictor += delta
   predictor -= delta
 send predictor to the output as the next audio sample

Presumably, the output sample should be saturated within an appropriate value range.

PC Games using CLU format