SFML community forums
Help => Audio => Topic started by: Walker on March 01, 2010, 09:21:33 am
-
Hey guys. I am working on a game right now with levels being generated infinitely.
Anyway, I wanted to have a simple looping melody for "music" and I was going to shift the tempo up each level. As far as I know, OpenAL and SFML can't do this - it is quite a difficult operation (if it can even be done realtime on my hardware, while there is other stuff using my CPU). So I am looking for a different audio library to use. Either one that can change tempo of an mp3/ogg/whatever without shifting the pitch too, or perhaps a library to play MIDI or popular tracker formats, or even a SID emulator or SPC700.
Has anyone here got any experience with anything like this or any suggestions?
By the way, I have thought about having a different loop for each level, but when 15+ levels is a reasonable amount to get through on your first play, this seems a little excessive.
Cheers guys.
PS Sorry for asking for <not SFML> in the SFML forum, Laurent. It handles everything else beautifully :)
-
Maybe fmod, don't know if it supports that.
-
Thanks, will try it out tonight. Has a pretty long feature list. I would prefer and open source library though.
-
What you are asking about is known as "time stretching" in the pro audio world, and is indeed a difficult task. Especially if you want it to sound good, too... I think you will be hard pressed to find an audio library for games that can do this in real time.
I think your best bet would be to apply such an operation to the sound, between levels, because of the complexity.
I have no idea where you could find such an algorithm, or how to apply it, though.
-
Thanks for the tip. I've decided to look into midi libraries for now.
-
I was just looking over SoundTouch myself...
http://www.surina.net/soundtouch/index.html
Could be good!