The start
method of the OscillatorNode
interface specifies the exact time to start playing the tone. Its parameter is optional and default to 0
.
oscillator.start(when); // start playing oscillator in when seconds
The following example shows basic usage of an AudioContext
to create an oscillator node. For an applied example, check out our Violent Theremin demo (see app.js for relevant code).
// create web audio api context var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); // create Oscillator node var oscillator = audioCtx.createOscillator(); oscillator.type = 'square'; oscillator.frequency.setValueAtTime(3000, audioCtx.currentTime); // value in hertz oscillator.start();
Specification | Status | Comment |
---|---|---|
Web Audio API The definition of 'start' in that specification. | Working Draft |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 14 | Yes | 251 | No | 15 | 6 |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | Yes | 14 | Yes | 261 | No | 15 | ? |
1. Before Firefox 30, the when
parameter was not optional.
© 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/OscillatorNode/start