Increase or Decrease Music Tempo without Pitch Change

Hello:

Is there anyway to increase or decrease the tempo of the music in an audio track without changing its pitch in the process?

Thanks.

You can counter the pitch change by using the FMOD Pitch Shifter DSP.

Awesome! Thank you so much!

I was having trouble getting the pitch of the Pitch shifter DSP plugin to shift accurately. I found an old thread that used a formula to calculate how much you need to shift for a specific keychange. Instead of providing the formula, i thought id just share my results from a google sheets doc. hope this helps some future person.

It would be awesome if the Pitch shifter plugin could just use a semitone or cents shifter rather than an arbitrary 0 to 2 number thing…

For now heres the numbers.
Imgur

1 Like

Very helpful, thank you for that!

Just dropping this info for anyone still reading. If you’re using C#/Unity, you can use the following functions to transform the values just as shown in the Pitch Shifter formula:

    private static float SpeedMultiplierToPitchSemitones(float speed)
    {
        return 12f * Mathf.Log(speed, 2f);
    }

    private static float PitchSemitonesToSpeedMultiplier(float pitch)
    {
        return Mathf.Pow(2f, pitch / 12f);
    }

The actual code I use is this:

    private void SetSpeed(float speed)
    {
        float pitch = SpeedMultiplierToPitchSemitones(speed);
        float pitchShift = 1f / speed;
        Debug.Log($"speed: {speed}, pitch: {pitch}, pitchShift: {pitchShift}");
        // change the tempo
        m_MusicInstance.setParameterByName("Pitch", pitch);
        // compensate for pitch change
        m_MusicInstance.setParameterByName("PitchShift", pitchShift);
    }

NOTE: This requires having parameters set up so that “Pitch” and “PitchShift” apply the same values to the respective controls.

1 Like

I’ve improved my code a bit. Here’s a glimpse:

    private void SetSpeed(float speedMultiplier)
    {
        float pitchSemitones = SpeedMultiplierToPitchSemitones(speedMultiplier);
        float pitchShift = 1f / speedMultiplier;
        Debug.Log($"speedMultiplier: {speedMultiplier}, pitchSemitones: {pitchSemitones}, pitchShift: {pitchShift}");
        // change the tempo
        m_MusicInstance.setPitch(speedMultiplier);
        // compensate for pitch change
        m_MusicInstance.setParameterByName("PitchShift", pitchShift);
    }

You can also rename speedMultiplier to pitch, which I have done in my actual code.

1 Like

This is very cool! Thank you so much for your help!