The cancelScheduledValues() method of the AudioParam Interface cancels all scheduled future changes to the AudioParam.
cancelScheduledValues(startTime)startTimeA double representing the time (in seconds) after the AudioContext was first created after which all scheduled changes will be cancelled.
A reference to this AudioParam object. In some older implementations this method returns undefined.
const gainNode = audioCtx.createGain();
gainNode.gain.setValueCurveAtTime(waveArray, audioCtx.currentTime, 2); // 'gain' is the AudioParam
gainNode.gain.cancelScheduledValues(audioCtx.currentTime);