Making waves using the Web Audio API

How to make sine, square, sawtooth and triangle waves using the Web Audio API (Chrome only). More info - http://stuartmemo.com

HTML

<html>
<h1>Making waves</h1>
    <p><a href="http://stuartmemo.com/making-sine-square-sawtooth-and-triangle-waves/" target="_blank">Related blogpost</a></p>
<p>Oscillator type values:</p>
<ul>
    <li>Sine wave = 0
    <li>Square wave = 1
    <li>Sawtooth wave = 2
    <li>Triangle wave = 3
</ul>
</html>

JavaScript

var context = new webkitAudioContext(),
    oscillator = context.createOscillator();

oscillator.type = 2;
oscillator.frequency.value = 800;
oscillator.connect(context.destination);
oscillator.start(0);