PDA

View Full Version : [Workaround] Getting background sounds to loop [Obsolete]



AdamR
22-02-2009, 05:10 PM
I should have published this back in August 2008 when I first did this, but never mind...

As you all know ambient sounds that start on and loop don't play. However there is a trick to get them working which should suffice for you to test out how they would really sound so you can make adjustments, tweaks, etc.

This only effects ambient_generic's that you want to start switched on. Looping ambient_generic's work just fine if they are started later, so we can use this to get background sounds working.

I also assume you're using wav sound files. Apparently other sound formats behave differently.

IMPORTANT: Whichever workaround you decide to use, you must give every ambient_generic entity that you intend to have looping and starting on a targetname of sound_auto. Also ensure that the start silent flag is enabled. Do that now.


Workaround 1
Simple, but only works for quick joiners.


Wrap a trigger_once block around your info_player_deathmatch's
IMPORTANT: Set the delay of this trigger_once to 1 second, also ensure you set the target to sound_auto
Compile your map and start it on a listen server. There will be a tiny delay, but your ambient sound effects will work. It will also work if you're the first person to join the map on a dedicated server.

No other players that join will be able to hear them. They'd need to join before the sounds are triggered to start.

An example of this in action is my water works (http://scmapdb.wikidot.com/map:the-water-works) map. I've noticed that the sounds sort of change as time progresses though, as if there is slight echo or reverb being added, or something. However, I've never experienced a crash because of this - so it's fine for now I guess.

If you really want other players to hear them too you can either increase the delay of your trigger_once to say 3 to 5 seconds, to ensure they join before the delay finishes. However the first one in would notice silence, then sound all of a sudden.

Remember that a player will not hear the background sounds unless they are present in game at the moment they are switched on.


Workaround 2
More complicated, but works for all players including late joiners.

Set up a multi_manager and two trigger_relay's as follows:

Both trigger_relay's need to target sound_auto
Give one of them the name sound_auto_off, and set it's target state mode to off
Give the other one the name sound_auto_on, and set it's target state mode to on
Give your multi_manager the name sound_auto_reset
Set the multi_manager to target sound_auto_off in 1.00 second, and sound_auto_on in 1.05 seconds
Set all your info_player_deathmatch's to target sound_auto_reset

Bare in mind that using this approach would result in all ambient sound effects resetting every time someone spawns. There will also be a 0.05 second delay while the sounds are resetting. This is hardly noticeable unless you listen out for it specifically. You probably won't care if you do notice it anyway.

This example works perfectly in my fail mountain (http://scmapdb.wikidot.com/map:fail-mountain) map. Try it if you don't believe me.


Workaround 3 (for Sven Co-op 4.1 or later only)
This is similar to workaround 2, but much simpler as it uses a new multi_manager feature from Sven Co-op 4.1.

Set up a multi_manager called sound_auto_reset with the following trigger entries:

Key sound_auto with a value of 1#0
Key sound_auto#1 with a value of 1.05#1

Set all your info_player_deathmatch's to target sound_auto_reset.

Bare in mind that using this approach would result in all ambient sound effects resetting every time someone spawns. There will also be a 0.05 second delay while the sounds are resetting. This is hardly noticeable unless you listen out for it specifically. You probably won't care if you do notice it anyway.

This example works perfectly in my polar rescue (http://scmapdb.wikidot.com/map:polar-rescue) map. You can't try it yet though!


Got a better idea?

I'd love to hear it :)

Puchi
18-08-2009, 03:22 PM
The HL/OpFor SP Map uses a trigger_auto to start all sounds, and a multimanager named game_playerjoin, triggering the sounds at 0 and 0.1 seconds to disable and enable them for the new player.

AdamR
18-08-2009, 03:27 PM
The problem with using game_playerjoin is the reverb/distortion effect background sounds will be subject to as they play for longer and longer. You can avoid this by having your spawn points trigger a multi_manager instead.

In Sven Co-op 4.1 with the multi_manager explicit on/off feature, you will be able to do:

Set all ambient_generic's a name of sound_auto
Set all info_player_deathmatch's to target sound_auto_reset
Make a multi_manager called sound_auto_reset with these key pairs:

Key sound_auto, value 0.01#0 to switch all sounds off
Key sound_auto#1, value 0.02#1 to switch all sounds on


(added this as workaround 3)

Puchi
18-08-2009, 03:40 PM
The problem with using game_playerjoin is the reverb/distortion effect background sounds will be subject to as they play for longer and longer. You can avoid this by having your spawn points trigger a multi_manager instead.
i do not expect anyone to play the portal map for longer than 10-20 minutes anyway so its fine till the sound engine is done.

RNG
18-08-2009, 03:58 PM
mp3s tend to always loop

Puchi
18-08-2009, 04:04 PM
technically they're played once by the entity: you can trigger it any time and it starts. this is a not yet implemented feature.