Created
September 4, 2019 18:55
-
-
Save thales17/7759bffb9874fb4b7f1222cbd1474921 to your computer and use it in GitHub Desktop.
WebAudio Oscillator Example
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> | |
<head> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
console.log("Hello, world"); | |
// create web audio api context | |
var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); | |
// create Oscillator node | |
var oscillator = audioCtx.createOscillator(); | |
oscillator.type = 'sine'; | |
oscillator.frequency.setValueAtTime(288, audioCtx.currentTime); // value in hertz | |
oscillator.connect(audioCtx.destination); | |
oscillator.start(); | |
setTimeout(()=> { | |
oscillator.stop() | |
}, 5000); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment