Troubles with dynamic music
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.
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.
Idolon 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.
EDIT: Wow, they can. Is the best way to add a new soundscript to pack a modified _manifest.txt into your BSP?
I would like to see if anyone can get this working because Portal 2 has some awesome addon to soundscripts..
FelixGriffin 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.
It is all relative to the scripts/ directory.
ChickenMobile wrote:
...soundscapes...
Using 2 timers (one that adds 1 and one that subtracts 1 every fire)
a math_counter (that fires it's value output to a logic_case input)
and a logic_case (with values corresponding to volumes)
Will make your music able to fade say only halfway in and then fade back out from that point. Just enable the up timer and disable the down to turn up and the opposite to turn down (disable down timer on min value and up timer on max value). This way if your relay to fade in and relay to fade out are triggered closely together the effect is correct and wont end up all mixed up.