OscillatorNode.detune

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.

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();

规范

Specification
Web Audio API
# dom-oscillatornode-detune

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
detune

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also