This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The GainNode interface represents a change in volume. It is an AudioNode audio-processing module that causes a given gain to be applied to the input data before its propagation to the output. A GainNode always has exactly one input and one output, both with the same number of channels.
The gain is a unitless value, changing with time, that is multiplied to each corresponding sample of all input channels. If modified, the new gain is instantly applied, causing unaesthetic 'clicks' in the resulting audio. To prevent this from happening, never change the value directly but use the exponential interpolation methods on the AudioParam interface.
| Number of inputs | 1 |
|---|---|
| Number of outputs | 1 |
| Channel count mode | "max" |
| Channel count |
2 (not used in the default count mode) |
| Channel interpretation | "speakers" |
GainNode()Creates and returns a new GainNode object. As an alternative, you can use the BaseAudioContext.createGain() factory method; see Creating an AudioNode.
Inherits properties from its parent, AudioNode.
GainNode.gain Read only
An a-rate AudioParam representing the amount of gain to apply. You have to set AudioParam.value or use the methods of AudioParam to change the effect of gain.
No specific method; inherits methods from its parent, AudioNode.
See BaseAudioContext.createGain() for example code showing how to use an AudioContext to create a GainNode.
| Specification |
|---|
| Web Audio API> # GainNode> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
GainNode |
55 | 79 | 53 | 42 | 14.1 | 55 | 53 | 42 | 14.5 | 6.0 | 55 | 14.5 |
GainNode |
24 | 12 | 25 | 15 | 7 | 25 | 25 | 14 | 7 | 1.5 | 4.4 | 7 |
gain |
24 | 12 | 25 | 15 | 7 | 25 | 25 | 14 | 7 | 1.5 | 4.4 | 7 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/GainNode