--- title: AudioParam slug: Web/API/AudioParam tags: - API - Audio - AudioParam - Interface - NeedsTranslation - Reference - TopicStub - Web Audio API translation_of: Web/API/AudioParam ---
{{APIRef("Web Audio API")}}
The AudioParam interface represents an audio-related parameter, usually a parameter of an {{domxref("AudioNode")}} (such as {{ domxref("GainNode.gain") }}). An AudioParam can be set to a specific value or a change in value, and can be scheduled to happen at a specific time and following a specific pattern.
There are two kinds of AudioParam, a-rate and k-rate parameters:
AudioParam takes the current audio parameter value for each sample frame of the audio signal.AudioParam uses the same initial audio parameter value for the whole block processed, that is 128 sample frames.Each {{domxref("AudioNode")}} defines which of its parameters are a-rate or k-rate in the spec.
Each AudioParam has a list of events, initially empty, that define when and how values change. When this list is not empty, changes using the AudioParam.value attributes are ignored. This list of events allows us to schedule changes that have to happen at very precise times, using arbitrary timelime-based automation curves. The time used is the one defined in {{domxref("AudioContext.currentTime")}}.
AudioParam Inherits properties from its parent, AudioNode.
AudioParam.AudioParam.defaultValue. Though it can be set, any modifications happening while there are automation events scheduled — that is events scheduled using the methods of the AudioParam — are ignored, without raising any exception.AudioParam Inherits methods from its parent, AudioNode.
AudioParam at a precise time, as measured against {{domxref("AudioContext.currentTime")}}. The new value is given in the value parameter.AudioParam. The change starts at the time specified for the previous event, follows a linear ramp to the new value given in the value parameter, and reaches the new value at the time given in the endTime parameter.AudioParam. The change starts at the time specified for the previous event, follows an exponential ramp to the new value given in the value parameter, and reaches the new value at the time given in the endTime parameter.AudioParam. The change starts at the time specified in startTime and exponentially moves towards the value given by the target parameter. The exponential decay rate is defined by the timeConstant parameter, which is a time measured in seconds.AudioParam to follow a set of values, defined by the values {{domxref("Float32Array")}} scaled to fit into the given interval, starting at startTime, and having a specific duration.AudioParam.AudioParam but holds its value at a given time until further changes are made using other methods. The new value is given in the value parameter.First, a basic example showing a {{domxref("GainNode")}} having its gain value set. gain is an example of an a-rate AudioParam, as the value can potentially be set differently for each sample frame of the audio.
var AudioContext = window.AudioContext || window.webkitAudioContext; var audioCtx = new AudioContext(); var gainNode = audioCtx.createGain(); gainNode.gain.value = 0;
Next, an example showing a {{ domxref("BiquadFilterNode") }} having some values set. These are examples of k-rate AudioParam's, as the values are set for the entire audio block at once.
var AudioContext = window.AudioContext || window.webkitAudioContext; var audioCtx = new AudioContext(); var biquadFilter = audioCtx.createBiquadFilter(); biquadFilter.type = "lowshelf"; biquadFilter.frequency.value = 1000; biquadFilter.gain.value = 25;
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('Web Audio API', '#the-audioparam-interface', 'AudioParam')}} | {{Spec2('Web Audio API')}} |
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|---|
| Basic support | {{CompatChrome(14)}} {{property_prefix("webkit")}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop(23)}} | {{CompatNo}} | 15 {{property_prefix("webkit")}} 22 (unprefixed) |
6 {{property_prefix("webkit")}} |
| Unprefixed | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatNo}} |
minValue and maxValue |
{{CompatChrome(52)}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatNo}} | 39 | {{CompatNo}} |
cancelAndHoldAtTime() |
{{CompatChrome(57)}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
| Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|
| Basic support | {{CompatVersionUnknown}} | {{CompatChrome(28)}} {{property_prefix("webkit")}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile(25)}} | {{CompatNo}} | {{CompatNo}} | 6 {{property_prefix("webkit")}} |
| Unprefixed | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatNo}} |
minValue and maxValue |
{{CompatChrome(52)}} | {{CompatChrome(52)}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatNo}} | 39 | {{CompatNo}} |
cancelAndHoldAtTime() |
{{CompatChrome(57)}} | {{CompatChrome(57)}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |