OscillatorNode.frequency
OscillatorNode
的 frequency 属性的接口
是 a-rate AudioParam
,表示振荡的频率,单位HZ(hertz)
语法
var oscillator = audioCtx.createOscillator();
oscillator.frequency.value = 440; // value in hertz
Note: 虽然返回的 AudioParam
是只读的,但是它表示的值不是。
值
一个 a-rate AudioParam
的值
示例
下列示例使用 AudioContext
创建了一个 oscillator node. 这是一个用于展示的示例,查看 Violent Theremin demo (see app.js 是相关代码).
// create web audio api context
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// create Oscillator node
var oscillator = audioCtx.createOscillator();
oscillator.type = 'square';
oscillator.frequency.value = 440; // value in hertz
oscillator.start();
说明
Specification | Status | Comment |
---|---|---|
Web Audio API frequency |
Working Draft |
浏览器兼容性
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 14 webkit (en-US) | (Yes) | 23 | 未实现 | 15 webkit (en-US) 22 (unprefixed) |
6 webkit (en-US) |
Feature | Android | Chrome | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support | 未实现 | 28 webkit (en-US) | (Yes) | 25 | 1.2 | 未实现 | 未实现 | 6 webkit (en-US) |