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

(NraButtons) #1

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;
      oldPitch = oldPitch + 0.02 * dt;

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?

(Geoff Carlton) #2

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;
    pitch = pitch + 0.01f;

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).

(NraButtons) #3

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

(Geoff Carlton) #4

Yes, that code is for FMOD Studio.