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
AudioContextrepresenting the audio context you want the node to be associated with. options- A
ConstantSourceOptionsdictionary object defining the properties you want theConstantSourceNodeto have:offset: A read-onlyAudioParamspecifying 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-Infinityto+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 });
Specifications
| Specification | Status | Comment |
|---|---|---|
| Web Audio API The definition of 'ConstantSourceNode' in that specification. |
Working Draft |
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Microsoft Edge | Opera | Safari (WebKit) |
|---|---|---|---|---|---|---|
| Basic support | (Yes) |
52 (52) | No support | ? |
(Yes) |
No support |
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
|---|---|---|---|---|---|---|
| Basic support | No support | 52.0 (52) | No support | No support | No support | (Yes) |