Looping a sound: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (→‎GoldWave: I feel like this would count as pirating, which is something that probably shouldn't be on this wiki, due to legality and if for no other reason than not making Valve upset. Feel free to disagree and discuss though)
Line 23: Line 23:


=== GoldWave ===
=== GoldWave ===
{{tip|GoldWave has a limited number of saves in the unlicensed version. However this can be circumvented by searching for the pattern <code>83 FB 1E BF 05 00 00 00</code> in a hex editor and changing the 05 to 1E.}}


Open Goldwave and open the sound you want to loop. Click the '''cues''' icon. ([[File:Cues button.jpg]])
Open Goldwave and open the sound you want to loop. Click the '''cues''' icon. ([[File:Cues button.jpg]])

Revision as of 16:37, 10 March 2024

English (en)Русский (ru)Translate (Translate)

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.

GoldSrc GoldSrc and Source Source detect looped sounds ONLY through cue points embedded in the file. This is a WAV-only feature, so MP3s cannot be looped. Microsoft ADPCM compressed WAVs can be looped, but due to the way they are encoded, there may a pop when the sound restarts if the sound is shorter than a few seconds.

Note.pngNote:Source 2 Source 2 supports looping both WAV and MP3, but only S&box S&box's tools can set the looping flag in a VSND for MP3 files; first-party Valve tools still rely upon WAV cues points to determine when a VSND should loop.
Note.pngFix:With custom audio backends, it is theoretically possible to loop filetypes other than WAV. Compressed audio formats usually have a small decoding delay upon restarting a track, which can appear as a small pop or stutter, with MP3 being worse due to its fixed frame size and Ogg Vorbis being the cleanest. This can theoretically be avoided for any compressed format, including MP3.
Note.pngNote: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.pngWarning: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.

Programs

These free programs can add cue points to a WAV:

GoldWave

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

Wavosaur

Open Wavosaur and open the sound you want to loop. Go to Tools > Loop > Create loop points. It should create loop points. You can change their positions by dragging them.

After that, click "Save" or "Save As".

Warning.pngWarning:Wavosaur does not support ADPCM-compressed WAV files; attempting to open one will result in the application crashing!
Icon-Important.pngImportant:In GoldSrc GoldSrc, the sound may fail to loop if two cue points are set via the Create loop points function in Wavosaur. If this happens, try setting only the starting cue by using a marker instead (Tools > Loop > Create marker).

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.pngWarning:It seems that the end cue maybe doesn't have any effect at all. See the Discussion page for more details.
Warning.pngWarning:ADPCM-compressed WAV files may ignore the location of the start cue when looping, and loop the entire sound instead!

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

Looping an MP3

The name of the ambient_generic is "MP3".

In Source Source, MP3 files can't be looped with start/end queues like a WAV. A logic_timer can be a good workaround; have it start playing the sound again after it has fully played (or has played to the point desired).

This could also be done using User I/O from the ambient_generic to itself, and an input delay.

See also

External links