ConstantSourceNode() 构造函数创建新 ConstantSourceNode object instance, representing an audio source which constantly outputs samples whose values are always the same.

句法

var constantSourceNode = new ConstantSourceNode(context, options);
					

参数

context
AudioContext representing the audio context you want the node to be associated with.
选项
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.

let audioContext = new AudioContext();
let myConstantSource = new ConstantSourceNode(audioContext, { offset: 0.5 });
					

注意 : The new ConstantSourceNode created by the constructor has a channelCount of 2.

规范

规范 状态 注释
Web 音频 API
The definition of 'ConstantSourceNode: ConstantSourceNode' in that specification.
工作草案

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
ConstantSourceNode() 构造函数 Chrome 56 Edge ≤79 Firefox 52 IE No Opera 43 Safari No WebView Android 56 Chrome Android 56 Firefox Android 52 Opera Android 43 Safari iOS No Samsung Internet Android 6.0

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: