Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@xem xem commented Jun 7, 2014

Here's the demo !

@p01

This comment has been minimized.

Copy link

@p01 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

This comment has been minimized.

Copy link
Owner Author

@xem 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