Created
January 3, 2017 12:54
-
-
Save tassoevan/f5a11e42595f5609f57d1132bf49a0cf to your computer and use it in GitHub Desktop.
Sinusoidal beep in JavaScript ES5
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
var audioCtx = new(window.AudioContext || window.webkitAudioContext)(); | |
var oscillator = audioCtx.createOscillator(); | |
var gainNode = audioCtx.createGain(); | |
oscillator.connect(gainNode); | |
gainNode.connect(audioCtx.destination); | |
gainNode.gain.value = 1; | |
oscillator.frequency.value = 440; | |
oscillator.type = 'sine'; | |
oscillator.start(); | |
setTimeout(function() { oscillator.stop(); }, 500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment