W3cubDocs

/DOM

AudioBufferSourceNode.detune

The detune property of the AudioBufferSourceNode interface is an k-rate AudioParam representing detuning of oscillation in cents.

For example, values of +100 and -100 detune the source up or down by one semitone, while +1200 and -1200 detune it up or down by one octave.

Syntax

var source = audioCtx.createBufferSource();
source.detune.value = 100; // value in cents

Note: Though the AudioParam returned is read-only, the value it represents is not.

Value

A k-rate AudioParam.

Example

const audioCtx = new AudioContext();

const channelCount = 2;
const frameCount = audioCtx.sampleRate * 2.0; // 2 seconds

const myArrayBuffer = audioCtx.createBuffer(channelCount, frameCount, audioCtx.sampleRate);

for (let channel = 0; channel < channelCount; channel++) {
  const nowBuffering = myArrayBuffer.getChannelData(channel);
  for (let i = 0; i < frameCount; i++) {
    nowBuffering[i] = Math.random() * 2 - 1;
  }
}

const source = audioCtx.createBufferSource();
source.buffer = myArrayBuffer;
source.connect(audioCtx.destination);
source.detune.value = 100; // value in cents
source.start();

Specifications

Specification Status Comment
Web Audio API
The definition of 'detune' in that specification.
Working Draft

Browser compatibility

Feature Chrome Edge Firefox Internet Explorer Opera Safari
Basic support Yes Yes 40 No 44 No
Feature Android webview Chrome for Android Edge mobile Firefox for Android IE mobile Opera Android iOS Safari
Basic support Yes Yes Yes 40 No Yes ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/detune