Page 1 of 1

Playing a wav file at a random offset

Posted: Mon Dec 07, 2009 6:03 am
by headkaze
I have a "footsteps" sample that is played while the main player sprite is walking around. This is looped using the built in looping of the wav format. Is it possible to play the sample at a random offset so the footsteps are not so repetative?

Re: Playing a wav file at a random offset

Posted: Thu Dec 10, 2009 11:31 pm
by Discostew
If you have it played at a random offset, wouldn't that cut in to the actual audio, and therefore not play the entire data?

If you want it to not sound repetitive while keeping the audio intact, don't have it loop, but rather replay the audio after a random number of frames have passed, like so...

**footstep, wait 3 frames, footstep, wait 9 frames, footstep, wait 5 frames, etc.**

Since Maxmod doesn't currently have the ability to check if an audio sample had finished, you'd need to know the length of the audio, and just add that to some random number of frames to wait prior to playing it again.

Re: Playing a wav file at a random offset

Posted: Sat Dec 12, 2009 4:28 am
by WinterMute
Rather than looping make it one shot & triggered by some aspect of your animation code then vary the volume and playback rate a little with each step.

Re: Playing a wav file at a random offset

Posted: Sat Dec 12, 2009 4:49 am
by eKid
and maybe 2 or more variation samples :)