Troubles with dynamic music
Quote from Idolon on April 26, 2013, 6:03 pmI've been trying to implement custom layered music, similar to the music in the singleplayer campaign, except it will all be controlled via I/O (since music will turn on/off by completing parts of the puzzle, rather than flying through the air etc). This will eventually be packaged as an instance for easy use in maps. However, I've been running into an issue in correctly implementing this and keeping all the tracks in sync.
My first attempt simply used the FadeIn and FadeOut commands, but it seems FadeOut will stop the sound, meaning tracks will desynchronize when I fade them out. quickly.
My second attempt went a bit better; each ambient_generic starts playing at 0 volume, and a logic_relay will increment the volume up to 10 over time, simulating a fade. A secondary relay does the same in reverse to fade the music back out. The tracks stay in sync as I fade them in. However, they still desynchronize when I turn them back down. Oddly though, the tracks of the music don't start from the beginning when they fade back in - it seems that setting the volume to 0 pauses the sound!
If someone knows of a way to get dynamic music like this to work, it'd be greatly appreciated.
I've been trying to implement custom layered music, similar to the music in the singleplayer campaign, except it will all be controlled via I/O (since music will turn on/off by completing parts of the puzzle, rather than flying through the air etc). This will eventually be packaged as an instance for easy use in maps. However, I've been running into an issue in correctly implementing this and keeping all the tracks in sync.
My first attempt simply used the FadeIn and FadeOut commands, but it seems FadeOut will stop the sound, meaning tracks will desynchronize when I fade them out. quickly.
My second attempt went a bit better; each ambient_generic starts playing at 0 volume, and a logic_relay will increment the volume up to 10 over time, simulating a fade. A secondary relay does the same in reverse to fade the music back out. The tracks stay in sync as I fade them in. However, they still desynchronize when I turn them back down. Oddly though, the tracks of the music don't start from the beginning when they fade back in - it seems that setting the volume to 0 pauses the sound!
If someone knows of a way to get dynamic music like this to work, it'd be greatly appreciated.
Quote from FelixGriffin on April 26, 2013, 6:10 pmI noticed the same things while working on the third Shadows of Time map's dynamic music system. For that I just stepped the music from 1 to 10 instead of 0, but a better option I've found since then is this:
Place an info_target for each piece of music. Set the sound to emit from it. Then when you want it to start, SetParent !player SetParentAttachment eyes. When you want it to stop, place some other model with an attachment (such as a pivot cube) in a nodraw-box and SetParent SetParentAttachment to it.
Since the sound will essentially emit from the player, you can set its radius to something very low. Then it doesn't need to teleport very far to become inaudible.
I noticed the same things while working on the third Shadows of Time map's dynamic music system. For that I just stepped the music from 1 to 10 instead of 0, but a better option I've found since then is this:
Place an info_target for each piece of music. Set the sound to emit from it. Then when you want it to start, SetParent !player SetParentAttachment eyes. When you want it to stop, place some other model with an attachment (such as a pivot cube) in a nodraw-box and SetParent SetParentAttachment to it.
Since the sound will essentially emit from the player, you can set its radius to something very low. Then it doesn't need to teleport very far to become inaudible.
Quote from Idolon on April 26, 2013, 9:21 pmThanks for the advice! I tried getting the parenting to work, but some really goofy stuff (like tracks being desynchronized on the map startup) was happening, so I just went with setting the volume to 1. However, if you have an example .vmf with the parenting method, I'd like to see it.
Thanks for the advice! I tried getting the parenting to work, but some really goofy stuff (like tracks being desynchronized on the map startup) was happening, so I just went with setting the volume to 1. However, if you have an example .vmf with the parenting method, I'd like to see it.
Quote from portal2tenacious on April 27, 2013, 8:43 amYou'll also want to change the player model to Chell. I remember Sicklebrick having the problem in Telekinesis because Bendy has no attachment points.
You'll also want to change the player model to Chell. I remember Sicklebrick having the problem in Telekinesis because Bendy has no attachment points.
Quote from FelixGriffin on April 27, 2013, 4:25 pmIdolon wrote:Thanks for the advice! I tried getting the parenting to work, but some really goofy stuff (like tracks being desynchronized on the map startup) was happening, so I just went with setting the volume to 1. However, if you have an example .vmf with the parenting method, I'd like to see it.I never got it to work well enough for a release map, but I found that making them all Start Silent and then using OnMapSpawn/OnMapLoad PlaySound on all of them helped fix that.
I never got it to work well enough for a release map, but I found that making them all Start Silent and then using OnMapSpawn/OnMapLoad PlaySound on all of them helped fix that.
Quote from vanSulli on April 27, 2013, 4:55 pmAs per my last experiments, soundscripts can be used per-map. Simply copying off of one of Valve's scripts for music should be enough to get two tracks to synchronize (create a script for one track and another for the track that syncs with it; then place two ambient_generics that use the corresponding sounds and trigger them as usual).
As per my last experiments, soundscripts can be used per-map. Simply copying off of one of Valve's scripts for music should be enough to get two tracks to synchronize (create a script for one track and another for the track that syncs with it; then place two ambient_generics that use the corresponding sounds and trigger them as usual).
Quote from FelixGriffin on April 28, 2013, 9:40 amWait, how can soundscripts be used to sync music tracks? That would be so useful!
EDIT: Wow, they can. Is the best way to add a new soundscript to pack a modified _manifest.txt into your BSP?
Wait, how can soundscripts be used to sync music tracks? That would be so useful!
EDIT: Wow, they can. Is the best way to add a new soundscript to pack a modified _manifest.txt into your BSP?

Quote from ChickenMobile on April 28, 2013, 8:50 pmSoundscripts (as far as I know) can only be loaded when packed from specific locations & a specific named file just like soundscapes (e.g. scripts/soundscapes_mapname.txt) See VDC soundscripts for these locations.
I would like to see if anyone can get this working because Portal 2 has some awesome addon to soundscripts..
Soundscripts (as far as I know) can only be loaded when packed from specific locations & a specific named file just like soundscapes (e.g. scripts/soundscapes_mapname.txt) See VDC soundscripts for these locations.
I would like to see if anyone can get this working because Portal 2 has some awesome addon to soundscripts..
Quote from FelixGriffin on April 28, 2013, 11:17 pmBut will that work on the Workshop? The map name changes when it's downloaded.
But will that work on the Workshop? The map name changes when it's downloaded.
Quote from Ultiman9711 on April 29, 2013, 12:57 amFelixGriffin wrote:But will that work on the Workshop? The map name changes when it's downloaded.The map name stays the same. What changes is the location. For example, if you had test.bsp, you usually have it in:
portal2/maps/test.bsp
However, once it's on the workshop, it's something like:
portal2/maps/workshop/[weird number]/test.bsp
I don't know if the soundscripts go based on name or path, though, so the best thing is to take a look at the Valve ones.
The map name stays the same. What changes is the location. For example, if you had test.bsp, you usually have it in:
portal2/maps/test.bsp
However, once it's on the workshop, it's something like:
portal2/maps/workshop/[weird number]/test.bsp
I don't know if the soundscripts go based on name or path, though, so the best thing is to take a look at the Valve ones.