The ConstantSourceNode interface—part of the Web Audio API—represents an audio source (based upon AudioScheduledSourceNode) whose output is single unchanging value. This makes it useful for cases in which you need a constant value coming in from an audio source. In addition, it can be used like a constructible AudioParam by automating the value of its offset or by connecting another node to it; see Controlling multiple parameters with ConstantSourceNode.
A ConstantSourceNode has no inputs and exactly one monaural (one-channel) output. The output's value is always the same as the value of the offset parameter.
Creates and returns a new ConstantSourceNode instance, optionally specifying an object which establishes initial values for the object's properties. As an alternative, you can use the BaseAudioContext.createConstantSource() factory method; see Creating an AudioNode.
Instance properties
Inherits properties from its parent interface, AudioScheduledSourceNode, and adds the following properties:
This code starts by creating the gain nodes and setting them and the volume control that will adjust their value all to 0.5. Then the ConstantSourceNode is created by calling AudioContext.createConstantSource(), and the gain parameters of each of the two gain nodes are connected to the ConstantSourceNode. After starting the constant source by calling its start() method. Finally, the two gain nodes are connected to the audio destination (typically speakers or headphones).
Now, whenever the value of constantNode.offset changes, the gain on both gainNode2 and gainNode3 will change to have that same value.