这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。
OscillatorNode() 构造器创建了一个新的 OscillatorNode 对象,也是 AudioNode 类型,表示一个周期的波形,例如正弦波,用来在不同的对象中定义其可选属性的值
如果属性的默认值可接受,也可以选择使用 AudioContext.createOscillator() 工厂方法构造 OscillatorNode 对象。
语法
var oscillatorNode = new OscillatorNode(context, options)
参数
context- 指向
AudioContext的引用。 options可选- 一个用来给 oscillator node 的属性指定值得对象,该对象中省略的属性都将采用默认值
type- oscillator node 产生的波形的形状。可用的值有 '
sine', 'square', 'sawtooth', 'triangle' 和 'custom',默认值是'sine'。 detune- 音高微调值(cents)可以对给定的频率值进行偏移。 默认值是0.
frequency- 周期性波形的频率 (in hertz)。 默认值是440.
periodicWave- 任意的周期性波形,通过一个
PeriodicWave对象描述。
说明
| Specification | Status | Comment |
|---|---|---|
| Web Audio API OscillatorNode() |
Working Draft | Initial definition. |
浏览器兼容性
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Basic support | 55[1] | 25 (25) | ? | 42 | ? |
| Feature | Android Webview | Chrome for Android | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|
| Basic support | 55[1] | 55[1] | 25.0 (25) | ? | ? | 42 | ? |
[1] Chrome 59 之前,不支持默认属性。