Looping a Sound

From Valve Developer Community
Revision as of 01:55, 5 October 2018 by Gordon Walkedby (talk | contribs)
Jump to: navigation, search

A looped sound will repeat endlessly without any gap between its end and start. It is up to the sound artist to ensure that the end and start of the file match up however, or there will be a "pop" as the waveform jumps from one shape to another.

Source detects looped sounds ONLY through cue points embedded in the file. This is a WAV-only feature, so MP3s cannot be looped. MS-ADPCM compressed WAVs can be looped, but due to the compression there will be a pop when the sound restarts. (But that can theoretically be avoided for any compressed format, including MP3.)

Note.png Note: There is no need to mark a sound as looping when playing it, but if using ambient_generic you will find that the "Is NOT Looped" flag must be set correctly if you want to stop the sound after it starts!
Warning.png Warning: Left 4 Dead 2 During development: editing the contents of an existing sound file stored in your campaign's sound.cache will not show any change until the sound cache is rebuilt! See Creating a sound.cache file or L4D2 Custom Sound and Music Tutorial for further instructions.


These free programs can add cue points to a WAV:


Open Goldwave and open the sound you want to loop. Click the cues icon. (Cues button.jpg) Then in the new window click on the New button and add a cue point At Start. Then click New for another cue point and add a point At End. So it looks similar to this:

Cue dialog.jpg

Cue location

Your cues do not have to be at the start and end of the file. If you place them in the middle Source will start playing the sound normally, then when it reaches the end cue will loop back to the start cue. From then on only what's between the cues will play.

Warning.png Warning: It seems that the end cue maybe doesn't have any effect at all. See the Discussion page for more details.

This can be used to give a sound a "winding up" effect that only plays once (e.g. a motor starting).

Looping a MP3

MP3 sound file can't be looped in normal way.

I have found a strange way to loop it.

We will need a logic_timer to stop the sound and replay the sound.

here is a example. I used an ambient_generic named "MP3".


Use the logic_timer to stop the sound when the sound is over and then start playing it again.

See Also

External Links