e01.org

OscillatorNode: detune property

Web Audio API

Web Audio API

The `detune` property of the OscillatorNode interface is an [a-rate](/docs/Web/API/AudioParam#a-rate) AudioParam representing detuning of oscillation in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29).

> [!NOTE]
> Though the `AudioParam` returned is read-only, the value it represents is not.

## Value

An [a-rate](/docs/Web/API/AudioParam#a-rate) AudioParam.

## Examples

The following example shows basic usage of an AudioContext to create an oscillator node. For applied examples/information, check out our [Violent Theremin demo](https://mdn.github.io/webaudio-examples/violent-theremin/) ([see app.js](https://github.com/mdn/webaudio-examples/blob/main/violent-theremin/scripts/app.js) for relevant code).

```js
// create web audio api context
const audioCtx = new AudioContext();

// create Oscillator node
const oscillator = audioCtx.createOscillator();

oscillator.type = "square";
oscillator.frequency.setValueAtTime(440, audioCtx.currentTime); // value in hertz
oscillator.detune.setValueAtTime(100, audioCtx.currentTime); // value in cents
oscillator.start();
```

## Specifications

## Browser compatibility

## See also

- [Using the Web Audio API](/docs/Web/API/Web_Audio_API/Using_Web_Audio_API)

source: MDN Web Docs mirror · page

Cite this

"OscillatorNode: detune property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode/detune

JSON record · API collection · citation policy