Custom Sounds and Scenes
Quote from PrejudicedNanobot on June 17, 2011, 9:15 pmI've been looking into using custom sounds and scenes in a Portal 2 map I'm working on. I've got them to work at a basic level, but I'm wondering how I should include them when I (eventually) distribute the map. I'm also rather unclear on how/where to add new soundscripts.
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:
- Code: Select all
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!
I've been looking into using custom sounds and scenes in a Portal 2 map I'm working on. I've got them to work at a basic level, but I'm wondering how I should include them when I (eventually) distribute the map. I'm also rather unclear on how/where to add new soundscripts.
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:
- Code: Select all
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!
Quote from PrejudicedNanobot on June 18, 2011, 8:23 pmSorry about the double post, but I've been doing some further testing and the results are fairly informative (if not particularly helpful at this stage).
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.
Sorry about the double post, but I've been doing some further testing and the results are fairly informative (if not particularly helpful at this stage).
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.
Quote from Kasc on June 18, 2011, 9:33 pmI am also planning to include custom sounds in the future, why is it better to control sounds without a soundscript? I've noticed all NPC sounds seem to be run via scripts and won't play within hammer.
I am also planning to include custom sounds in the future, why is it better to control sounds without a soundscript? I've noticed all NPC sounds seem to be run via scripts and won't play within hammer.
Quote from PrejudicedNanobot on June 18, 2011, 10:48 pmWell, I wouldn't say it's better to use sounds without an accompanying soundscript, but it's certainly possible. I'm trying to get soundscripts to work because of their associated benefits (volume control, specifying the origin of a sound, etc.), but currently it seems there's no way to load them without overriding the original copy of game_sounds_manifest.txt (which isn't a good idea since if multiple custom VPKs include copies of game_sounds_manifest.txt only one of them will be used and custom soundscripts for the other VPKs won't load).
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).
Well, I wouldn't say it's better to use sounds without an accompanying soundscript, but it's certainly possible. I'm trying to get soundscripts to work because of their associated benefits (volume control, specifying the origin of a sound, etc.), but currently it seems there's no way to load them without overriding the original copy of game_sounds_manifest.txt (which isn't a good idea since if multiple custom VPKs include copies of game_sounds_manifest.txt only one of them will be used and custom soundscripts for the other VPKs won't load).
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).
Quote from Omnicoder on June 18, 2011, 11:10 pmThe only way to use custom sounds is to embed the waves in the bsp. And there is simply no way to use custom VCDs.
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.
Quote from PrejudicedNanobot on June 19, 2011, 9:17 amOmnicoder 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'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.
Quote from Kasc on June 19, 2011, 10:54 amPerhaps what you need to do isn't hard, or perhaps you DON'T need to rebuild to sound cache, but the COLOURS map has a lot of custom sounds.
Perhaps what you need to do isn't hard, or perhaps you DON'T need to rebuild to sound cache, but the COLOURS map has a lot of custom sounds.
Quote from PrejudicedNanobot on June 19, 2011, 11:16 amI actually downloaded two of the Colours maps yesterday, but I haven't had a chance to take a look them in-game. They appear to use the method Omnicoder mentioned where WAVs are embedded in the BSP itself, which (I assume) does not require the sound cache to be rebuilt. (I should probably test that assumption!)
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.
I actually downloaded two of the Colours maps yesterday, but I haven't had a chance to take a look them in-game. They appear to use the method Omnicoder mentioned where WAVs are embedded in the BSP itself, which (I assume) does not require the sound cache to be rebuilt. (I should probably test that assumption!)
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.
Quote from Kasc on June 19, 2011, 11:21 amCan you still not use scripts to control the sound even if it's embedded into the .bsp? Or am I totally misunderstanding what you're trying to achieve :p
Can you still not use scripts to control the sound even if it's embedded into the .bsp? Or am I totally misunderstanding what you're trying to achieve :p
Quote from Kasc on June 19, 2011, 12:11 pmDo you have to rebuild the sound cache if you include the sounds in the .bsp, all of the guides/tutorials I've looked at give mismatched info, i.e. some say you need to rebuild the sound cache and some just don't even mention that.
In COLOURS there is a .cache file the soundcache folder, are these necessary, and if so - how do you make them?
Do you have to rebuild the sound cache if you include the sounds in the .bsp, all of the guides/tutorials I've looked at give mismatched info, i.e. some say you need to rebuild the sound cache and some just don't even mention that.
In COLOURS there is a .cache file the soundcache folder, are these necessary, and if so - how do you make them?