Top
If you look in the game assets of Delta Force: Black Hawk Down, you'll see some sbf files (
Header and index
Each SBF file starts with a header of this format:
Chunk format
Each segment has a list of chunks of this format:
Experimentation reveals the PCM data format is unsigned 8 bit, 2 channel, at 22050Hz sample rate. If you convert it to mp3 based on this spec, you get something like this:
It has the right rhythm but the amplitude is all over the place. It turns out the scale fields in the chunk header are modifiers that needs to be applied to the PCM data to get proper sounding audio. The digital signal needs to be divided by
Why did they encode it like this?
The decision to choose 8 bit PCM was clearly a space optimization. But the problem with 8 bit audio is precision. There are only 256 values that the amplitude can have. For parts of the track where the volume is relatively loud, this isn't that big of a problem, but it adds a lot of noise to the quieter parts of the track and sounds worse. (relative difference between 1 and 2 is much bigger than difference between 115 and 116). For example, this is a downscaled 8 bit version of the first track in the list. Notice the hissing and cracking in the first few seconds.
This is unacceptable because this game has a lot of ambient music (e.g.
Their solution was to divide the tracks into 4096 byte chunks, which stores around 100ms of sound, use full 256 level precision for quiet parts as well, and add metadata to the chunk describing how it must be scaled in a high precision space to get the final result.
Why didn't they just use mp3?
mp3 was under a patent until 2017. Maybe they didn't want to bother with the licensing. Ogg vorbis is a free alternative but it came out in 2000. Considering the game came out in 2003, they might have already implemented this solution by the time ogg became popular.