Soundcache

From Valve Developer Community
Revision as of 18:17, 5 December 2005 by Yahnbernier (talk | contribs)

Jump to: navigation, search

Outline

A Soundcache is a file with contains the first .125 seconds (125 milliseconds) of each sound required in a map. At level load, the Source engine loads certain sound .cache files instead of the full .wavs themselves in order to save memory and load time. During gameplay when a sound is requested, the sound begins to play immediately (consuming the 125 milliseconds of preload data in the .cache files) while the full sound is asynchronously loaded from the hard drive. In most cases, there is enough data loaded by the time the sound preload data such that the async i/o never needs to "block" to finish loading. If the async layer, however, does need to block, then a noticeable framerate hitch often occurs.

Each soundcache has an accompanying .manifest, which contains a list of files needed by the map.

Extraction

  • .cache files can be viewed with Game Extractor [1]
  • .manifest files can be viewed with any text editor

Caches

  • _sharedprecache.cache: contains data for sounds common to over 50% of maps.
  • _other.cache: contains the file header, but no data, for any sound files that were not encountered in any other precache lists. Sounds in this cache do not cause I/O-related hitches as they play back fully asynchronously, that is, only once the sound is completely loaded.
  • <mapname>.cache: Contains the remaining files that are precached but not already a part of _sharedprecache.cache.

Creation

Sound caches are created automatically if they do not already exist before a map is loaded. A manifest is first written listing every file used, then each cache is created using the rules above, with the first second of each file written to the relavant cache.

  • snd_writemanifest
Writes the .manifest file. Buggy.
  • snd_rebuildaudiocache
Writes the .cache file, containing soundfile snippets. Appears to have no effect.

Limitations & Bugs

There is no known way to manually select the contents of each cache.