Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// use the HTML5 audio API to make a beep.
var context = new webkitAudioContext();
var volume = context.createGain();
volume.gain.value = 0.5;
var synth = context.createOscillator();
// I think 0 is the default type? Let’s see what we get.
synth.type = 0;
// Play an ‘A’ at 440Hz, the typical tone used to tune an instrument.
synth.frequency_value = 440;
// Actually play a note.
// In 2 seconds, stop playing the note.
setTimeout(synth.noteOff, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment