The ConstantSourceNode()
constructor creates a new ConstantSourceNode
object instance, representing an audio source which constantly outputs samples whose values are always the same.
Syntax
var constantSourceNode = new ConstantSourceNode(context, options);
Parameters
context
- An
AudioContext
representing the audio context you want the node to be associated with. options
- A
ConstantSourceOptions
dictionary object defining the properties you want theConstantSourceNode
to have:offset
: A read-onlyAudioParam
specifying the constant value generated by the source. The default is 1.0. The normal range is -1.0 to 1.0, but the value can be anywhere in the range from-Infinity
to+Infinity
.
Example
In this example, an audio context is created, then a ConstantSourceNode
is established with its offset
initialized to 0.5.
let audioContext = new AudioContext(); let myConstantSource = new ConstantSourceNode(audioContext, { offset: 0.5 });
Note: The new ConstantSourceNode
created by the constructor has a channelCount
of 2.
Specifications
Specification | Status | Comment |
---|---|---|
Web Audio API The definition of 'ConstantSourceNode: ConstantSourceNode' in that specification. |
Working Draft |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
ConstantSourceNode() constructor | Chrome Full support 56 | Edge Full support ≤79 | Firefox Full support 52 | IE No support No | Opera Full support 43 | Safari No support No | WebView Android Full support 56 | Chrome Android Full support 56 | Firefox Android Full support 52 | Opera Android Full support 43 | Safari iOS No support No | Samsung Internet Android Full support 6.0 |
Legend
- Full support
- Full support
- No support
- No support