Created
January 15, 2015 05:06
-
-
Save adamf/e30ece52f2c065fd90f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<script> | |
// use the HTML5 audio API to make a beep. | |
var context = new webkitAudioContext(); | |
var volume = context.createGain(); | |
volume.gain.value = 0.5; | |
volume.connect(context.destination); | |
var synth = context.createOscillator(); | |
synth.connect(volume); | |
// 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. | |
synth.noteOn(0); | |
// In 2 seconds, stop playing the note. | |
setTimeout(synth.noteOff, 2000); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment