PDA

View Full Version : Looping A WAV File



BOOWY
7 Oct 2009, 08:15am
This really should be simple but everything I've tried just isn't working. I've got a WAV file encoded with Microsoft ADPCM(I don't know if that helps) that I want to loop over and over again. This music file is silent at first and only starts playing when I hit a func_button triggering it. The problem is that even with my ambient_generic 'Is NOT Looped' flag unchecked, the music plays once and stops.

It's important to have the music play immediately upon ending with no breaks because the WAV file loops seamlessly. Any solutions? I've tried a logic_timer and either I'm not doing it right or it doesn't work, and logic_auto doesn't apply here because that's only good for playing something right when the round starts and that's not what I want.

Bob Loblaw
7 Oct 2009, 08:30am
I don't know what to tell you if you've already tried the standard options that make it loop.
You could always time the length of the file and have a logic timer get enabled when the button is pushed and every x seconds (how long your wav file is) it refires its outputs (aka refiring the ambient generic sound).

BOOWY
7 Oct 2009, 01:41pm
I've played around some more with properties, flags and outputs and finally got it to work. In case someone else runs into this problem I'll list what I did.

First, a func_button. Nothing special here. On the Output: OnPressed -> Target Entity name(will be a logic_timer object) -> FireTimer.

Then the logic_timer that takes the input of your button. Start Disabled must be set to "No". Refire interval is the length of your WAV file in seconds(if you want seamless loops you have to find out exactly how long your WAV file is, down to the millisecond). If I've got a WAV file that's 1:33.310 long, then I'm setting it to 93.310 in the refire interval box. Most music players won't tell you exactly how long your file is, I used Goldwave to see exactly how long the file is. For the flags, I'm not sure what Oscillator does, but I've got it unchecked. For the Output: OnTimer -> Target Entity name(will be an ambient_generic object) -> PlaySound.

Lastly, the ambient_generic object. The properties are pretty self explanatory, nothing special going on. For flags, you want Start Silent to be checked and Is NOT Looped to be checked.

That's it for looping audio that's triggered if your ambient_generic object refuses to loop the audio on it's own. I can finally get to doing 6 more seamless WAV files.

Bob Loblaw
7 Oct 2009, 10:56pm
I'm glad it worked. P.S. Oscillator alternates between the high and low time.