This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

type

Summary

The shape of the periodic waveform. It may directly be set to any of the type constant values except for CUSTOM. The setWaveTable() method can be used to set a custom waveform, which results in this attribute being set to CUSTOM.

Property of apis/webaudio/OscillatorNodeapis/webaudio/OscillatorNode

Syntax

var result = OscillatorNode.type;
OscillatorNode.type = value;

Return Value

Returns an object of type unsigned shortunsigned short

Uses one of the following constant values:

  • SINE (0);
  • SQUARE (1);
  • SAWTOOTH (2);
  • TRIANGLE (3);
  • CUSTOM (4).

Examples

var oscillator = audioCtx.createOscillator();
oscillator.type = 'square';

Related specifications

W3C Web Audio API
W3C Editor’s Draft