--- title: OscillatorNode.detune slug: Web/API/OscillatorNode/detune translation_of: Web/API/OscillatorNode/detune ---

{{ APIRef("Web Audio API") }}

{{ domxref("OscillatorNode") }} 的 detune 属性的接口是 a-rate {{domxref("AudioParam")}} ,代表振荡频率的失谐量(cents)。

语法

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

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

 值

一个 a-rate {{domxref("AudioParam")}} 的值

示例

下面的例子使用 {{ domxref("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.detune.value = 100; // value in cents
oscillator.start();

说明

Specification Status Comment
{{SpecName('Web Audio API', '#widl-OscillatorNode-detune', 'detune')}} {{Spec2('Web Audio API')}}  

浏览器兼容性

{{CompatibilityTable}}
Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 14 {{property_prefix("webkit")}} {{CompatVersionUnknown}} 23 {{CompatNo}} 15 {{property_prefix("webkit")}}
22 (unprefixed)
6 {{property_prefix("webkit")}}
Feature Android Chrome Edge Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support {{CompatNo}} 28 {{property_prefix("webkit")}} {{CompatVersionUnknown}} 25 1.2 {{CompatNo}} {{CompatNo}} 6 {{property_prefix("webkit")}}

See also