Pavel Marceluch

Unity - Change audio speed without changing the pitch

When you change the speed of an audio clip, you also change the pitch. If you have a 440Hz tone and speed it up, the frequency will rise. But what if you want to change just the speed and leave the pitch alone?

Read about time stretching on Wikipedia.


To replicate this effect in Unity, follow this guide:

  1. Create an Audio Mixer, an Audio Group and add the Pitch Shifter effect to the group. When playing audio, you need to pass the Audio Group you just created into the Source’s Output.
  2. Increase the FFT size and overlap to increase quality. I have not noticed a significant performance hit.
  3. Expose the Pitch parameter of the group and the Pitch parameter of the Pitch Shifter effect. Don’t forget to rename them.
  4. Run this code to change the speed without affecting the pitch:
AudioMixer audioMixer;

void SetSpeed(float speed)
{
	audioMixer.SetFloat("Pitch", speed);
	audioMixer.SetFloat("PitchShifterPitch", 1f / speed);
}

This is how the mixer and exposed parameters should look like:

And this is how the effect should be setup:

The only limitation with this approach I found is that this only works between the range of 50% and 200% speed. So just keep that in mind.


I use this effect in VRtuos to allow for slowing down a song and its accompanying custom audio track.

Tags: