# How can I change an Event's pitch as that Event is playing?

**URL:** <https://qa.fmod.com/t/how-can-i-change-an-events-pitch-as-that-event-is-playing/11818>\
**Category:** FMOD Engine\
**Created:** [February 3, 2015, 4:10am UTC](https://qa.fmod.com/t/how-can-i-change-an-events-pitch-as-that-event-is-playing/11818 "2015-02-03T04:10:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nrabreu](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@nrabreu](https://qa.fmod.com/u/nrabreu)\
**Post date:** [February 3, 2015, 4:10am UTC](https://qa.fmod.com/t/how-can-i-change-an-events-pitch-as-that-event-is-playing/11818/1 "2015-02-03T04:10:48Z")

</div>

At the moment, this is the code I’m using:

```
inst = AUDIO_SYSTEM->PlaySound("event:/ow", 0.5f); //0.5f being the volume

    if (inst)
    {
      float oldPitch;
      inst->getPitch(&oldPitch);
      oldPitch = oldPitch + 0.02 * dt;
      inst->setPitch(oldPitch);
    }

```

I’m not sure why the code doesn’t work. When this sound is triggered, it plays the sound unpitched, rather than the pitch increasing over time. Is there a way to change the pitch of the individual sound event on-the-fly, without going through a DSP?

---

<div class="post-metadata">

**Author:** ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://qa.fmod.com/u/geoff)\
**Post date:** [February 9, 2015, 4:32am UTC](https://qa.fmod.com/t/how-can-i-change-an-events-pitch-as-that-event-is-playing/11818/2 "2015-02-09T04:32:07Z")

</div>

Hi,  
That code should work fine. In fact I can do the same change with the 3d.cpp example that comes with the programmers API, in the main loop:

```
    float pitch;
    ERRCHECK(eventInstance->getPitch(&pitch));
    pitch = pitch + 0.01f;
    ERRCHECK(eventInstance->setPitch(pitch));

```

By adding that code, the engine pitch increases over time.

You could log the values of pitch that you are setting and check that it is increasing as you expect. Also if you check the return code out of getPitch and setPitch you can make sure there isn’t any problem (such as the event instance handle not being valid).

---

<div class="post-metadata">

**Author:** ![nrabreu](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@nrabreu](https://qa.fmod.com/u/nrabreu)\
**Post date:** [February 10, 2015, 6:15am UTC](https://qa.fmod.com/t/how-can-i-change-an-events-pitch-as-that-event-is-playing/11818/3 "2015-02-10T06:15:01Z")

</div>

> [@](#):
>
> Hi,  
> That code should work fine. In fact I can do the same change with the 3d.cpp example that comes with the programmers API, in the main loop:
> 
> ```
> float pitch;
> ERRCHECK(eventInstance->getPitch(&pitch));
> pitch = pitch + 0.01f;
> ERRCHECK(eventInstance->setPitch(pitch));
> 
> ```
> 
> By adding that code, the engine pitch increases over time.
> 
> You could log the values of pitch that you are setting and check that it is increasing as you expect. Also if you check the return code out of getPitch and setPitch you can make sure there isn’t any problem (such as the event instance handle not being valid).

I haven’t had the chance to check yet, but does this work the same when using FMOD Studio?

---

<div class="post-metadata">

**Author:** ![geoff](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoff](https://qa.fmod.com/u/geoff)\
**Post date:** [February 26, 2015, 11:18pm UTC](https://qa.fmod.com/t/how-can-i-change-an-events-pitch-as-that-event-is-playing/11818/4 "2015-02-26T23:18:10Z")

</div>

Yes, that code is for FMOD Studio.
