The ConstantSourceNode()
constructor creates a new ConstantSourceNode
object instance, representing an audio source which constantly outputs samples whose values are always the same.
The ConstantSourceNode()
constructor creates a new ConstantSourceNode
object instance, representing an audio source which constantly outputs samples whose values are always the same.
js
new ConstantSourceNode(context, options)
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 the ConstantSourceNode
to have:
offset
A read-only AudioParam
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
.
In this example, an audio context is created, then a ConstantSourceNode
is established with its offset
initialized to 0.5.
js
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.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
ConstantSourceNode |
56 | 79 | 52 | No | 43 | 14.1 | 56 | 56 | 52 | 43 | 14.5 | 6.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ConstantSourceNode/ConstantSourceNode