此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

OscillatorNode.detune

基线 广泛可用

自 2015年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

OscillatorNodedetune 属性的接口a-rate AudioParam ,代表振荡频率的失谐量(cents)。

语法

js
var oscillator = audioCtx.createOscillator();
oscillator.detune.value = 100; // value in cents

备注:虽然返回的 AudioParam 是只读的,但是它表示的值不是。

一个 a-rate AudioParam 的值

示例

下面的例子使用 AudioContext 创建了一个 oscillator node。这是已经在运行的例子,查看 Violent Theremin demo (see app.js 是相关源码)。

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.detune.value = 100; // value in cents
oscillator.start();

规范

规范
Web Audio API
# dom-oscillatornode-detune

浏览器兼容性

See also