Skip to content

Instantly share code, notes, and snippets.

@pushkine
Created January 13, 2022 12:19
Show Gist options
  • Save pushkine/eb475c349c99fe3c4c96bcd4ed1744f5 to your computer and use it in GitHub Desktop.
Save pushkine/eb475c349c99fe3c4c96bcd4ed1744f5 to your computer and use it in GitHub Desktop.
Beep javascript
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