Created
June 15, 2018 04:09
-
-
Save odino/017d6e21a8d7ce35c3aa8a4a4798e2be to your computer and use it in GitHub Desktop.
This file contains 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
a=new AudioContext() // browsers limit the number of concurrent audio contexts, so you better re-use'em | |
function beep(vol, freq, duration){ | |
v=a.createOscillator() | |
u=a.createGain() | |
v.connect(u) | |
v.frequency.value=freq | |
v.type="square" | |
u.connect(a.destination) | |
u.gain.value=vol*0.01 | |
v.start(a.currentTime) | |
v.stop(a.currentTime+duration*0.001) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment