# Changing wav speed in real-time

**URL:** <https://qa.fmod.com/t/changing-wav-speed-in-real-time/13443>\
**Category:** FMOD Engine\
**Created:** [September 16, 2017, 9:40am UTC](https://qa.fmod.com/t/changing-wav-speed-in-real-time/13443 "2017-09-16T09:40:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark81](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Mark81](https://qa.fmod.com/u/Mark81)\
**Post date:** [September 16, 2017, 9:40am UTC](https://qa.fmod.com/t/changing-wav-speed-in-real-time/13443/1 "2017-09-16T09:40:19Z")

</div>

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#](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?

---

<div class="post-metadata">

**Author:** ![grixm](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@grixm](https://qa.fmod.com/u/grixm)\
**Post date:** [September 18, 2017, 10:07pm UTC](https://qa.fmod.com/t/changing-wav-speed-in-real-time/13443/2 "2017-09-18T22:07:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Mark81](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Mark81](https://qa.fmod.com/u/Mark81)\
**Post date:** [September 19, 2017, 11:11am UTC](https://qa.fmod.com/t/changing-wav-speed-in-real-time/13443/3 "2017-09-19T11:11:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![grixm](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@grixm](https://qa.fmod.com/u/grixm)\
**Post date:** [September 19, 2017, 11:36am UTC](https://qa.fmod.com/t/changing-wav-speed-in-real-time/13443/4 "2017-09-19T11:36:47Z")

</div>

> [@](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Mark81](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Mark81](https://qa.fmod.com/u/Mark81)\
**Post date:** [September 19, 2017, 12:39pm UTC](https://qa.fmod.com/t/changing-wav-speed-in-real-time/13443/5 "2017-09-19T12:39:11Z")

</div>

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