Interplay ACMP
Interplay ACMP is an audio compression file format used in some games from Interplay. The name is shortened "AUDCOMP" and it employs DPCM with variable-length coding for compressing 8-bit PCM.
Interplay ACMP Format
Multi-byte numbers are stored in big endian format.
bytes 0-19 Signature string: 'Interplay ACMP Data\x1A' bytes 20-21 sample rate bytes 22-23 unknown, always seems to be 0 and might be part of sample rate byte 24 unknown, always seems to be 0x28 byte 25 unknown, always seems to be 0 bytes 26-29 possibly the size of decompressed audio bytes 30.. suspected to be the encoded audio data
Audio data coding
Audio seems to be coded in blocks of 256 samples (or less for the last block). Each block starts with 8-bit header:
- 1 bit - audio is transformed and only half of the samples are transmitted;
- 2 bits - quantisation step
- 5 bits - coding mode (0-6)
In general, block data is compressed by first taking differences (initial value is 0x80), quantising it by discarding low bits and coding in one of several ways. Some encoding modes use so-called tally code which is an unary code for min(value, 10)
and with optional 6-bit full value written afterwards (for values 10 and above). Also deltas are often coded as absolute values with a sign bit following.
Coding modes are:
- 0 - constant block, first sample is coded as is;
- 1 - deltas are coded as
tally(ilog2(|delta|)) |delta| sign
(ortally(1)
for zero delta); - 2 - deltas are coded as 4-bit fields, those that do not fit coded as 0 nibble plus
8 - quant_bits
bits for the actual delta value; - 3 - deltas are coded as
tally((|diff| >> 2) + 1) |diff|&3 sign
; - 4 - the same as previous but with 3 low bits coded raw;
- 5 - delta 0 is coded as
00
, delta 1 is coded as01
, other deltas are coded as10 tally(ilog2(|diff| - 1)) (|diff| - 1) sign
; - 6 - simply write raw quantised differences using
8 - quant_bits
bits for each.