Layered music
Quote from elt on June 6, 2011, 10:21 pmIn Portal 2, many levels have ambient music playing, and when certain test elements are being used (speed gel, sometimes faith plates) additional layers are added to the music. In the chamber where Wheatley brags about reading books, for example, being catapulted by the faith plates adds a cool harpsichord-like layer to the music, complimenting it. Another example would be in one of the first speed gel rooms where a nifty synth layer is added on top of the ambient music.
So... how do I do that? The wiki doesn't even mention this aspect of the game at all. Are the layers seperate sound files that have to be synchronized somehow? browsing sound files in Hammer is something of an incomplete mess (most of them won't even play?). Is it super-complicated and something I shouldn't even attempt until I have a dozen finished maps under my belt? Or is it something I can set up easily?
In Portal 2, many levels have ambient music playing, and when certain test elements are being used (speed gel, sometimes faith plates) additional layers are added to the music. In the chamber where Wheatley brags about reading books, for example, being catapulted by the faith plates adds a cool harpsichord-like layer to the music, complimenting it. Another example would be in one of the first speed gel rooms where a nifty synth layer is added on top of the ambient music.
So... how do I do that? The wiki doesn't even mention this aspect of the game at all. Are the layers seperate sound files that have to be synchronized somehow? browsing sound files in Hammer is something of an incomplete mess (most of them won't even play?). Is it super-complicated and something I shouldn't even attempt until I have a dozen finished maps under my belt? Or is it something I can set up easily?
Quote from raulness on June 7, 2011, 5:14 amI think I've read that these are coded into the game. It's nothing that can be done with a simple entity or anything. You could try a really ghetto version by making ambient generics that are triggered on certain surfaces based on the player's speed/height. If you look in sound bank you'll see certain files under 'music' are named very similarly and even sound very similar. These are the cues used to create a sense of music being added on. If you were to play them all together it would just sound like a full song.
Although they may not be perfectly synched together, using triggers and ambient generics could get close enough as the songs would be in the same key and tempo. I know it's not exactly what you want to do but it's about as much help as I can offer. I'll ask some friends who are much better versed in Hammer how Valve does it exactly and get back to you.
I think I've read that these are coded into the game. It's nothing that can be done with a simple entity or anything. You could try a really ghetto version by making ambient generics that are triggered on certain surfaces based on the player's speed/height. If you look in sound bank you'll see certain files under 'music' are named very similarly and even sound very similar. These are the cues used to create a sense of music being added on. If you were to play them all together it would just sound like a full song.
Although they may not be perfectly synched together, using triggers and ambient generics could get close enough as the songs would be in the same key and tempo. I know it's not exactly what you want to do but it's about as much help as I can offer. I'll ask some friends who are much better versed in Hammer how Valve does it exactly and get back to you.

Quote from ChickenMobile on June 7, 2011, 5:19 amHave you decompiled the maps that they have examples of this? All I can think of is that they have an 'actor' (or in this case Wheatley) that triggers sounds based on a script, a few ambient generic's that are looping sounds (which you can hear when you fly by a certain spot, maybe even triggered when you get launched by a catapult.) and maybe a couple of soundscapes (or ambient sounds).
How they made the music add different layers is probably by triggering a different sound altogether (stopping the other one that was playing), or its even part of the sound. The FadeIn and FadeOut values in an Ambient generic would be a great way to blend music together but I highly doubt they did that.
Have you decompiled the maps that they have examples of this? All I can think of is that they have an 'actor' (or in this case Wheatley) that triggers sounds based on a script, a few ambient generic's that are looping sounds (which you can hear when you fly by a certain spot, maybe even triggered when you get launched by a catapult.) and maybe a couple of soundscapes (or ambient sounds).
How they made the music add different layers is probably by triggering a different sound altogether (stopping the other one that was playing), or its even part of the sound. The FadeIn and FadeOut values in an Ambient generic would be a great way to blend music together but I highly doubt they did that.
Quote from The Irate Pirate on June 7, 2011, 5:28 amIt's easy to set up... if you just steal the entities from the Valve VMFs. To make it yourself seems to require quite a bit of scripting.
It's easy to set up... if you just steal the entities from the Valve VMFs. To make it yourself seems to require quite a bit of scripting.
Quote from VitaminZed on June 7, 2011, 3:05 pmchickenmobile wrote:How they made the music add different layers is probably by triggering a different sound altogether (stopping the other one that was playing), or its even part of the sound. The FadeIn and FadeOut values in an Ambient generic would be a great way to blend music together but I highly doubt they did that.Yeah, I took this approach on my map since I had a bit of a crunch to get it polished up for the contest and didn't have time to sort out how Valve did it officially.
There are four looped ambient_generics in the map each set to a different sound file under /music/. They each have different values for the "Fade In" and "Fade Out" keys.
I'll save you a bit of head-scratching that I went through: although you are able to set 'FadeIn' and 'FadeOut' as inputs via I/O to an ambient_generic, they are non-functional!
The first ambient is triggered by a logic_auto with OnMapSpawn -> PlaySound
The remaining three each have a corresponding logic_relay with two outputs:
OnTrigger -> [new ambient_generic targetname] -> PlaySound
OnTrigger -> [old ambient_generic targetname] -> StopSoundWith the appropriate keyvalues in "Fade In" and "Fade Out" the new sound comes in gradually and the old fades out to 'blend' them a bit. Each of the logic_relays are fired off as the player progresses or test elements are completed.
Seemed to work here, but I'd like to look into the 'official' method for my next map. I was also somewhat surprised that Portal2 does not have the ambient_music entity that's apparently available in L4D. Odd, I'd think this is exactly what you'd want to use but oh well.
Another caveat: I haven't tested it myself, but offhand I don't think that this method with ambient_generics set with a /music/ file actually plays through the Music channel (where you can increase/decrease Music Volume separately from Game Volume in the options).
Yeah, I took this approach on my map since I had a bit of a crunch to get it polished up for the contest and didn't have time to sort out how Valve did it officially.
There are four looped ambient_generics in the map each set to a different sound file under /music/. They each have different values for the "Fade In" and "Fade Out" keys.
I'll save you a bit of head-scratching that I went through: although you are able to set 'FadeIn' and 'FadeOut' as inputs via I/O to an ambient_generic, they are non-functional!
The first ambient is triggered by a logic_auto with OnMapSpawn -> PlaySound
The remaining three each have a corresponding logic_relay with two outputs:
OnTrigger -> [new ambient_generic targetname] -> PlaySound
OnTrigger -> [old ambient_generic targetname] -> StopSound
With the appropriate keyvalues in "Fade In" and "Fade Out" the new sound comes in gradually and the old fades out to 'blend' them a bit. Each of the logic_relays are fired off as the player progresses or test elements are completed.
Seemed to work here, but I'd like to look into the 'official' method for my next map. I was also somewhat surprised that Portal2 does not have the ambient_music entity that's apparently available in L4D. Odd, I'd think this is exactly what you'd want to use but oh well.
Another caveat: I haven't tested it myself, but offhand I don't think that this method with ambient_generics set with a /music/ file actually plays through the Music channel (where you can increase/decrease Music Volume separately from Game Volume in the options).