MDN wants to learn about developers like you:


The setValueCurveAtTime() method of the AudioParam Interface schedules a transition between values defined by a Float32Array, which are scaled to fit into the given interval starting at startTime and having a specific duration. The transition between values was undefined in the original spec but has now been specified as linear. Chrome 46.0.2490 uses linear interpolation; earlier versions use nearest neighbor (no interpolation).


var AudioParam = AudioParam.setValueCurveAtTime(values, startTime, duration)


A Float32Array representing the value curve the AudioParam will change through along the duration. Every value in the array must be a finite number; if any value is NaN, Infinity, or -Infinity, a TypeError exception is thrown.
A double representing the time (in seconds) after the AudioContext was first created that the change in value will happen.
A double representing the time (in seconds) the values will be changed between. The values are spaced equally along this duration.

Return value

A reference to this AudioParam object. In some browsers older implementations of this interface return void.


One or more of the values in the values array is non-finite. Non-finite values are NaN, Infinity, and -Infinity.


In this example, we have a media source with a single button (see the audio-param repo for the source code, or view the example live.) When this button is pressed, setValueCurveAtTime() is used to change the gain value between the values contained in the waveArray array:

// create audio context
var AudioContext = window.AudioContext || window.webkitAudioContext;
var audioCtx = new AudioContext();

// set basic variables for example
var myAudio = document.querySelector('audio');
var pre = document.querySelector('pre');
var myScript = document.querySelector('script');

pre.innerHTML = myScript.innerHTML;

var valueCurve = document.querySelector('.value-curve');

// Create a MediaElementAudioSourceNode
// Feed the HTMLMediaElement into it
var source = audioCtx.createMediaElementSource(myAudio);

// Create a gain node and set it's gain value to 0.5
var gainNode = audioCtx.createGain();
gainNode.gain.value = 0.5;
var currGain = gainNode.gain.value;

// connect the AudioBufferSourceNode to the gainNode
// and the gainNode to the destination

// set button to do something onclick

var waveArray = new Float32Array(9);
waveArray[0] = 0.5;
waveArray[1] = 1;
waveArray[2] = 0.5;
waveArray[3] = 0;
waveArray[4] = 0.5;
waveArray[5] = 1;
waveArray[6] = 0.5;
waveArray[7] = 0;
waveArray[8] = 0.5;

valueCurve.onclick = function() {
  gainNode.gain.setValueCurveAtTime(waveArray, audioCtx.currentTime, 2);


Specification Status Comment
Web Audio API
The definition of 'setValueCurveAtTime' in that specification.
Working Draft  

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 14 webkit (Yes) 23 No support 15 webkit
22 (unprefixed)
6 webkit
Unprefixed (Yes) (Yes)        
Feature Android Webview Chrome for Android Edge Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support ? 28 webkit (Yes) 25 1.2 No support No support webkit
Unprefixed (Yes) (Yes) (Yes)          

See also

Document Tags and Contributors

 Contributors to this page: jpmedley, Sheppy, erikadoyle, fscholz, mattlima, chrisdavidmills
 Last updated by: jpmedley,