Skip to content

Instantly share code, notes, and snippets.

@xem
Last active January 19, 2023 22:43
Show Gist options
  • Save xem/670dec8e70815842eb95 to your computer and use it in GitHub Desktop.
Save xem/670dec8e70815842eb95 to your computer and use it in GitHub Desktop.
beep boop
<!-- solution 1, 117b, inspired by http://www.p01.org/releases/140bytes_music_softSynth/ -->
<button onclick="new Audio('data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU'+Array(1e3).join(123)).play()">Beep</button>
<!-- Solution 2, 107b, inspired by http://xem.github.io/chip8/c8.html -->
<button onclick="o=(A=new AudioContext()).createOscillator();o.connect(A.destination);o.start(0);setTimeout('o.stop(0)',500)">Boop</button>
@xem
Copy link
Author

xem commented Jun 7, 2014

Here's the demo !

@p01
Copy link

p01 commented Jun 7, 2014

If you want short and don't care so much about the sound, we can save 5 bytes on the Audio version:

<button onclick="new Audio(Array(40).join('data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU')).play()">Beep</button>

@xem
Copy link
Author

xem commented Jun 7, 2014

great (and weird), but sadly, only works on Opera 12. =(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment