Changing the gain of an audio signal is a fundamental operation in audio applications. The GainNode is one of the building blocks for creating mixers. This interface is an AudioNode with a single input and single output:
numberOfInputs : 1
numberOfOutputs : 1
which multiplies the input audio signal by the (possibly time-varying) gain attribute, copying the result to the output. By default, it will take the input and pass it through to the output unchanged, which represents a constant gain change of 1.
As with other AudioParams, the gain parameter represents a mapping from time (in the coordinate system of AudioContext.currentTime) to floating-point value. Every PCM audio sample in the input is multiplied by the gain parameter's value for the specific time corresponding to that audio sample. This multiplied value represents the PCM audio sample for the output.
The number of channels of the output will always equal the number of channels of the input, with each channel of the input being multiplied by the gain values and being copied into the corresponding channel of the output.
The implementation must make gain changes to the audio stream smoothly, without introducing noticeable clicks or glitches. This process is called "de-zippering".
The AudioContext which owns this AudioNode.
Represents the amount of gain to apply. Its default value is 1 (no gain change). The nominal minValue is 0, but may be set negative for phase inversion. The nominal maxValue is 1, but higher values are allowed (no exception thrown).This parameter is a-rate
The number of inputs feeding into the AudioNode. This will be 0 for an AudioSourceNode.
The number of outputs coming out of the AudioNode. This will be 0 for an AudioDestinationNode.
Connects the AudioNode to another AudioNode.
It is possible to connect an AudioNode output to more than one input with multiple calls to connect(). Thus, "fanout" is supported.
It is possible to connect an AudioNode to another AudioNode which creates a cycle. In other words, an AudioNode may connect to another AudioNode, which in turn connects back to the first AudioNode. This is allowed only if there is at least one DelayNode in the cycle or an exception will be thrown.
There can only be one connection between a given output of one specific node and a given input of another specific node. Multiple connections with the same termini are ignored. For example:
nodeA.connect(nodeB);
nodeA.connect(nodeB);
will have the same effect as
nodeA.connect(nodeB);
the AudioNode to connect to.
an index describing which output of the AudioNode from which to connect. An out-of-bound value throws an exception.
an index describing which input of the destination AudioNode to connect to. An out-of-bound value throws an exception.
Connects the AudioNode to an AudioParam, controlling the parameter value with an audio-rate signal.
It is possible to connect an AudioNode output to more than one AudioParam with multiple calls to connect(). Thus, "fanout" is supported.
It is possible to connect more than one AudioNode output to a single AudioParam with multiple calls to connect(). Thus, "fanin" is supported.
An AudioParam will take the rendered audio data from any AudioNode output connected to it and convert it to mono by down-mixing if it is not already mono, then mix it together with other such outputs and finally will mix with the intrinsic parameter value (the value the AudioParam would normally have without any audio connections), including any timeline changes scheduled for the parameter.
There can only be one connection between a given output of one specific node and a specific AudioParam. Multiple connections with the same termini are ignored. For example:
nodeA.connect(param);
nodeA.connect(param);
will have the same effect as
nodeA.connect(param);
the AudioParam to connect to.
an index describing which output of the AudioNode from which to connect. An out-of-bound value throws an exception.
Disconnects an AudioNode's output.
an index describing which output of the AudioNode to disconnect. An out-of-bound value throws an exception.