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
by taoist
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 = 3;
oscillator.frequency.value = 500;
oscillator.connect(context.destination);
oscillator.noteOn(0);