Hacker News new | ask | show | jobs
by omgmog 3564 days ago
I had a go at rewriting this to use requestAnimationFrame, and provide more instruments and some random/clear buttons: https://blog.omgmog.net/beatmaker/

Including whitespace it's 102 lines: https://github.com/omgmog/beatmaker/blob/master/js/index.js

An interesting thing, after a short while the browser unloads the page (Chrome on Mac OS) -- probably due to memory usage, which I think this is down to creating a new Audio element each time, rather than initialising them once and then triggering .play() when needed.

update:

Alright I'm using AudioContext now rather than `new Audio`, seems to be performing a lot better. This puts us at about 144 lines.

2 comments

Really like your changes! I've incorporated your use of requestAnimationFrame and AudioContext back into mine: https://github.com/siggy/beatboxer/commit/dccff243474b17ca34...
Well your version doesn't crash shortly after toying around in it unlike OP's so good job!.