[SOLVED] Increasing the speed an audio file is played

Peaz

25-04-2008 12:59:32

Hey guys, sorry for the long post but I'll need to explain what I'm doing before people can understand what I'm asking :)

I currently have a .wav file which is a second long and plays a single heart beat. The ogre application I have at the moment currently just loops the sound over and over when the scene is created to give the impression you can hear a regular heart beat going at 60 bps.

The idea of the application is that when the player sees/does something scary their heart rate will increase and I need the sound being played to increase as well to match the faster heart rate.

What I was wondering is is it possible to get OgreAL to change the speed at which a sound is played, e.g. play the sound twice as fast so you hear two beats a second and get a bps of 120? I'm just wondering because the only other way I can think of to get this working is to edit the .wav file and save different versions of it, i.e. have an audio file which plays a beat every second, every 0.8 seconds, every 0.6 seconds etc. and play the appropriate file at the correct time during the game. I'd really appreciate any help on how to do this if this is possible at all or any advice on maybe another better/more efficient way of doing this.

Thanks in advance,

Peaz

stickymango

25-04-2008 14:41:54

Not used it myself but I think you use setPitch() passing a value which acts as a multiplier, so setPitch(2.f) should double the speed...

Peaz

26-04-2008 18:50:01

Brilliant, I didn't know that was there I'll give that a try now, cheers :)

Peaz

Peaz

27-04-2008 01:30:30

Thank you that works perfectly, now I'm able to get the beats per second to be any speed I want :D cheers again.

Peaz

stickymango

28-04-2008 14:45:42

Now I know! :D