Playing a wav file at a random offset
Moderator: eKid
Playing a wav file at a random offset
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
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.
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.
-
- Site Admin
- Posts: 1986
- Joined: Tue Aug 09, 2005 3:21 am
- Location: UK
- Contact:
Re: Playing a wav file at a random offset
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
and maybe 2 or more variation samples
Who is online
Users browsing this forum: No registered users and 0 guests