Changing wav speed in real-time

Hi! I’m working on a toy for my daughter… it’s a “carousel” that she can spin manually.
I’d like to add a common carousel music but changing its speed in function of rotating speed.
No problem at all to have this information, indeed I already have.

But I have difficulties to find a player (or a library) that allows to change the speed fo a wave file in real-time flawlessly (i.e. without gaps or stuttering). The whole things is Raspberry Pi powered, hence I think there are no problems to run FMOD.

Reading through the documentation I found this function:

https://www.fmod.com/resources/documentation-api?page=content/generated/FMOD_Sound_SetMusicSpeed.html#

that seems to do exactly what I’m looking for BUT it says: “Sets the relative speed of MOD/S3M/XM/IT/MIDI music”. No wav/mp3 then?

Is there another way to achieve this?

It’s only for those formats because they are note based, not sample based, changing the speed of sample based audio is very different.

But you can do it, using Channel::setPitch. That will increase the speed but also make it high pitched as a result. If that it undesirable, you can in addition add the DSP type FMOD_DSP_TYPE_PITCHSHIFT and make it shift the tone back down so it sounds normal but still fast.

1 Like

The changing in pitch is desirable! It’s the effect I want to achieve: higher (or lower) tempo and pitch according.

By the way, what is the difference between Channel::setPitch and Channel::setFrequency?

I don’t think there is a big difference. Changing the pitch is practically the same as changing the frequency, it’s just a different way of looking at it.

Ops… sorry for my reply as an answer. I didn’t realize this forum is set up like SO.