Web Audio API
The ConstantSourceNode() constructor creates a new
ConstantSourceNode object instance, representing an audio source which
constantly outputs samples whose values are always the same.
Syntax
new ConstantSourceNode(context)
new ConstantSourceNode(context, options)
Parameters
context- : An AudioContext representing the audio context you want the node to be associated with.
options- : A
ConstantSourceOptionsdictionary object defining the properties you want theConstantSourceNodeto have:offset- : A floating-point number specifying the initial value of the ConstantSourceNode.offset AudioParam, which determines the constant value generated by the source. The default is 1.0. The value must be finite.
- : A
Examples
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
ConstantSourceNodecreated by the constructor has achannelCountof 2.
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
