Skip to content

Instantly share code, notes, and snippets.

@pushkine
Created January 13, 2022 12:19
Show Gist options
  • Select an option

  • Save pushkine/eb475c349c99fe3c4c96bcd4ed1744f5 to your computer and use it in GitHub Desktop.

Select an option

Save pushkine/eb475c349c99fe3c4c96bcd4ed1744f5 to your computer and use it in GitHub Desktop.

Revisions

  1. pushkine created this gist Jan 13, 2022.
    16 changes: 16 additions & 0 deletions beep.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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);
    }