Custom Sounds and Scenes
Just to briefly cover what I've done so far: I made a WAV, put it in portal 2/portal 2/sound, and ran snd_rebuildaudiocache from the console. I then made a simple VCD that uses the sound, saved it in portal 2/portal 2/scenes, and rebuilt scenes.image from Face Poser. I currently have a test map that runs the VCD and it works properly.
However, when I finish the map, how should I distribute it such that the custom content (sounds and VCDs) works properly? From what I've read, using a VPK file is the best option, but will someone who downloads my VPK need to rebuild their sound cache and scenes.image file in order for the custom content to work? Is this done automatically when the update_addon_paths command is run?
Also, regarding soundscripts, I gather I'm supposed to create a text file in portal 2/portal 2/scripts containing something like this:
intercom.hello
{
channel CHAN_VOICE
volume VOL_NORM
pitch PITCH_NORM
soundlevel SNDLVL_NORM
wave hello.wav
}
However, is it also necessary to modify game_sounds_manifest.txt? The VDC soundscript article seems to imply that this is required in order for new soundscripts to be loaded.
Any input regarding this would be appreciated!
A soundscript will be loaded properly if a precache command for it (e.g., "precache_file" "maps/nameoflevel_level_sounds.txt") is added to game_sounds_manifest.txt (located in portal 2/portal 2/scripts for those not familiar with it). Unfortunately, any file named game_sounds_manifest.txt in a VPK file placed in the addons directly (this directory needs to be manually created) overrides the original game_sounds_manifest.txt, so unless it contains all the entries for the original Portal 2 soundscripts in addition to those for custom soundscripts it will cause problems (i.e., Portal 2 will crash when loading a map). Accordingly, this method of using custom soundscripts isn't feasible since it's not extensible.
As of yet, I haven't been able to figure out any alternate, addon VPK-compatible way to load custom soundscripts. In a few places on the VDC wiki (notably here and here), it seems to indicate that soundscripts can also be loaded for a specific map by placing a soundscript txt file called <name of level>_level_sounds.txt in the portal 2/portal 2/maps folder. In particular, the second of the two pages linked above states:
As with any source game, a soundscript found as maps/<mapname>_level_sounds.txt can override official soundscript entries without affecting other campaigns.
However, from the testing I've done, simply placing soundscript entries for a level in a file called nameoflevel_level_sounds.txt does not cause the entries to be loaded (when the map is run or otherwise) unless a corresponding precache command is included in game_sounds_manifest.txt. (I should mention that the actual WAV files can be played in-game without any problems using the console command snd_playsounds, ambient_generic entities, or VCDs; it's just the soundscripts associated with the sounds that aren't being loaded.)
I've also been looking into the soundcache issue as well. Apparently L4D2 has a command called snd_buildsoundcachefordirectory specifically for making caches of only the sounds present in a given directory (see this page), which is useful for distributing caches of custom sounds alone. Unfortunately, Portal 2 doesn't have this function, which seems a bit odd.
I'm going to keep plugging away at this to see if I can find a solution; any suggestions would be appreciated.
As far as I can tell, every sound used in Portal 2 has an associated soundscript that uses it (some of these soundscripts won't play in Hammer because of format issues, but this doesn't affect their usage), so I think it's desirable to use soundscripts for custom sounds as well. It's just a matter of getting them to load from an addon VPK without overriding the precaching of the original soundscripts or other custom soundscripts (e.g., from someone else's addon VPK).
Omnicoder wrote:
The only way to use custom sounds is to embed the waves in the bsp. And there is simply no way to use custom VCDs.
I've actually got both custom sounds and VCDs to work when they're in a VPK in the addons folder (i.e., they can be used by ambient_generics and logic_choreographed_scene entities in a map). However, I rebuilt scenes.image in Face Poser before moving the VCD into the VPK (which is a potential problem for the distribution of custom VCDs), and unfortunately it's still necessary to rebuild the (entire) audio cache in order for custom sounds to work.
I'll try to put together a simple VPK to demonstrate what I've managed to get working; perhaps it might help illuminate the soundscripts/cache problems as well.
I'd prefer to use VCDs rather than raw WAVs, as I'm planning on some custom narration with triggers fired at particular times and, although a similar result could probably be accomplished solely within Hammer, using a VCD would be a lot less messy. I've also found that delays in the source engine can sometimes be less than precise (e.g., see here) and I plan to have triggers fired in sync with musical cues and dialogue so even slight variations in trigger timing could make the final result feel a bit off.
However, that said, I may have to forget about VCDs and go with the BSP-embedding method if VPKs require a) the soundcache to be rebuilt and b) scenes.image to be rebuilt (not to mention the issues with soundscripts). It's unfortunate that Portal 2 lacks some of the infrastructure that apparently exists in L4D2 to handle custom content in VPKs.
In COLOURS there is a .cache file the soundcache folder, are these necessary, and if so - how do you make them?
Kasc wrote:
In COLOURS there is a .cache file the soundcache folder, are these necessary, and if so - how do you make them?
Where is this soundcache folder? Is it inside the Colours BSP? I haven't tried anything relating to Pakrat or embedding resources in BSPs yet, so I don't know how to open these "special" BSPs (assuming it's possible to do so).
Regarding making individual soundcaches, I didn't think it was possible to do this in Portal 2 since it doesn't include the snd_buildsoundcachefordirectory console command (it only has snd_rebuildaudiocache, which rebuilds one sound cache for all the audio files, original and custom). Perhaps Pakrat is able to extract the part of the sound cache that's relevant for a given map.
Also, I've discovered that VCDs in VPKs only work if they're registered in the scenes.image file already, which basically rules out using VCDs in content you eventually want to distribute (since distributing a new copy of scenes.image isn't a realistic option). I suppose I'll focus on including sounds without the user needing to rebuild their sound cache to hear them; since the Colours maps do it, it must be possible.
sound -> all his custom sounds used.
materials -> all his custom materials used.
maps -> soundcache -> mp_coop_coulours.cache
At any rate, I did a quick test and embedded a WAV in a BSP using Pakrat, and it works fine (at least for me) without building/rebuilding any sound caches. If anyone wants to give it a quick test to check that it works for them, I'd appreciate it (I've attached it below).
It's unfortunate that VCDs only seem to work with a scenes.image file that's modified to include them, but I suppose I'll just have to work around that.
snd_updateaudiocache
You can update the cache instead of having to rebuild it entirely.
I've only tested it with raw files though.
If only it was easier to add new soundscripts to your addons and maps.
That snd_updateaudiocache command does sound like quite a time-saver when testing sounds in VPKs. I still find it strange, however, that there doesn't appear to be a way to generate a sound cache for only a subset of sounds in Portal 2 while such functionality (according to the VDC wiki) does exist in L4D2. Without this functionality, including sounds in a VPK requires the user to run either snd_rebuildaudiocache or (as AniCator points out) snd_updateaudiocache in order for the sounds to play, which is decidedly inferior to simply embedding them in the BSP, which requires no additional effort on the part of the user.
For now, I'm just going to go with embedding the sounds in the BSP and using triggers, but I hope that the use of soundscripts and VCDs is possible in the future (using VCDs would certainly beat using a trigger possessing a bunch of outputs with different delays that play various sounds).