CKTIS / JavaScript
OscillatorNode — periodic waveform generator
OscillatorNode generates a mono periodic waveform. Configure its shape and frequency, connect its output, and schedule its start and stop.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
new OscillatorNode(context, { type: "sine", frequency: 440, detune: 0 }); oscillator.connect(destination); oscillator.start(when); oscillator.stop(when);OscillatorNode is a Web Audio API source: it has no inputs and a mono output. It is not part of ECMAScript.
type selects sine, square, sawtooth, or triangle. setPeriodicWave() sets a custom waveform and custom. frequency (default 440 Hz) and detune (0 cents) are AudioParam objects; change their .value or schedule automation. The formula frequency * 2 ** (detune / 1200) gives the detuned frequency before clamping. The oscillator clamps that value to the range from negative to positive Nyquist frequency.
start(when) and stop(when) use seconds on the context timeline. A node cannot restart—create another. The example renders offline without sound; check API availability in the target browser.
Examples
(async () => {
const context = new OfflineAudioContext(1, 4800, 48000);
const oscillator = new OscillatorNode(context, {
type: "sine",
frequency: 440
});
oscillator.connect(context.destination);
oscillator.start(0);
oscillator.stop(0.1);
const buffer = await context.startRendering();
console.log(buffer.numberOfChannels, buffer.length);
})();Result
1 4800
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.