Is it possible to do this with Audio Source?

Hello guys, On my main menu, I have a heartbeat sound, and when I lower the pitch, the heartbeat goes slower, but over time, I want to heartbeat pitch to increase which makes it faster and adds a nice atmousphere. Lowest value is 0.6 and Highest is 0.9.

All I know for this is “audio.pitch”

Help thanks.

So you want to adjust the pitch between the values of 0.6 and 0.9?

Audio Pitch is just like any other component var, you can cap it’s min and max with something like this (eg)

if(audio.pitch>=0.9) { audio.pitch = 0.9; }

You could also use mathf.clamp to cap a min and max value. Also I have used gui sliders in the past to set a min and max.

To add to the var just use some simple operators (ie) audio.pitch += 1.0 * Time.deltaTime * 2;