Can Mathf.Lerp smoothly change float values at a rate faster than Update?

Hi there, I’m hoping someone can answer my question or point me in the right direction.

Can Mathf.Lerp smoothly change float values at a rate faster than Update? Or is there another technique that would work for faster than Update control of values?

I’m stuck figuring out how to smoothly increase and decrease audio pitch with more precision that one change per Update. I’m adjusting pitch based on mouse pointer position on screen to simulate DJ scratching, and currently I’m getting too much zippering of the audioclip as it changes pitch.

Thanks.

I don’t have a clear answer for you.

But l, regarding this part … I’m adjusting pitch based on mouse pointer position.

Location of mouse pointer is registered every update. Even if you could change the pitch several times between updates, it would be based on the same mouse position. So you’ll still be ‘predicting’ what the pich of the next frame could be.

I would try something the mathematical way to ‘smoothen’ the flow numbers.

Maybe you could restrict max. deviation from last ‘pitch’ by using Mathf.Clamp?

Say, the new pitch, must be between 85-115% of the pitch set in the last frame?

Maybe adding another modifier to the percentages comparing the average of the last 4 frames with the average of the last 2 frames. To see if pitch is increasing or decreasing and how fast.

Thanks for your reply Ben, those ideas are really useful. I’ve been so fixated on smoothing the pitch value I hadn’t even considered the mouse values sending only on Update! Mathf.Clamp could certainly be useful for restricting pitch deviation.

In my project I am currently detecting forwards and back movement, and that percentage value is altering the pitch in Unity - it sounds almost perfect for non-tonal samples, but tonal sounds (e.g. a 1kHz sine wave) have the ‘zippering’ audio quality that gives away the pitch is only changing each frame.

Based on this, I’ll take the mouse out of the equation for the time being and focus on getting the pitch to smoothly ramp up using a tonal sound that currently suffers from zippering.

It looks like the options are Mathf.Lerp, Mathf.SmoothStep and Mathf.SmoothDamp - I’ll come back with another post once I’ve tested these.

Thanks!