Audio · function

smoothToward

Exponential approach, in time.

Explained in Your first game.

function smoothToward(current: number, target: number, rate: number, dtSec: number): number
import { smoothToward } from '@driftengine/audio';

Parameters

ParameterTypeDescription
currentnumber
targetnumber
ratenumber
dtSecnumber

In depth

rate is per second and means the same thing at 60 Hz, at 144 Hz and at whatever a background tab does. A per-step factor is the bug AGENTS.md records: the same constant meant 47 ms in one caller and 158 ms in another, and moved with the frame rate in the second.