Playing a wav file at a random offset

support for the gba/nds sound library from www.maxmod.org

Moderator: eKid

Post Reply
headkaze
Posts: 13
Joined: Wed Oct 21, 2009 5:57 pm

Playing a wav file at a random offset

Post by headkaze » Mon Dec 07, 2009 6:03 am

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?

Discostew
Posts: 103
Joined: Sun Mar 08, 2009 7:24 pm

Re: Playing a wav file at a random offset

Post by Discostew » Thu Dec 10, 2009 11:31 pm

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.

WinterMute
Site Admin
Posts: 1997
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Playing a wav file at a random offset

Post by WinterMute » Sat Dec 12, 2009 4:28 am

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

eKid
Posts: 65
Joined: Sat Dec 06, 2008 6:07 pm
Contact:

Re: Playing a wav file at a random offset

Post by eKid » Sat Dec 12, 2009 4:49 am

and maybe 2 or more variation samples :)

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests