Created
January 13, 2022 12:19
-
-
Save pushkine/eb475c349c99fe3c4c96bcd4ed1744f5 to your computer and use it in GitHub Desktop.
Beep javascript
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
function beep() { | |
const ctx = new AudioContext(); | |
const oscillator = ctx.createOscillator(); | |
const gainNode = ctx.createGain(); | |
oscillator.connect(gainNode); | |
gainNode.connect(ctx.destination); | |
gainNode.gain.value = 0.25; | |
oscillator.frequency.value = 350; | |
oscillator.type = "triangle"; | |
oscillator.start(); | |
setTimeout(() => oscillator.stop(), 90); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment