UPBGE Feature suggestion: Add a Tempo option to the Sound Actuator

Currently, the only way to add a change in tempo, is to increase the sound pitch. But lets say we want to increase the tempo of the game music or sound effect? Well with the current implementation which is pitch based, the sound pitch will increase too as well as the tempo, which is not ideal for music in many cases, unless you want vinyl records.

My idea therefore is this:

  • A new feature called “Tempo” is added to the Sound Actuator. You can still add Pitch, but Pitch only adjusts the pitch of the sound, not the tempo. The Tempo will handle changing the speed of the sound, but leaving pitch unchanged.

So the Sound Actuator now has a Tempo value, which is set at 0 (default tempo). Raising the value causes the sound to play faster, lowering it causes the sound to play slower.

In Python, the Sound Actuator also gains a new Attribute known as Tempo. It would look like this in an example script:

import bge
cont = bge.logic.getCurrentController()
act = cont.actuators['Sound']
act.tempo = 1.0
cont.activate(act)

This will actually be useful for when you don’t want your sound being raised in pitch, like when creating scripts to loop music or for when you don’t want sound to increase in tempo when increasing pitch.

We could also add in the options found in Python into the Sound Actuator which are highpass and lowpass while we are at it too so we can adjust those values from the actuator, not just exclusively from Python.

You can still combine both Tempo and Pitch if you like.

What do you think? This was an idea I thought up.