Show HN: Drum machine in 100 lines of HTML/JS
21–30 of 51 posts
Re: Show HN: Drum machine in 100 lines of HTML/JS
#22http://imgur.com/a/O1dy8
Re: Show HN: Drum machine in 100 lines of HTML/JS
#23Here's mine: http://wa-101.net/. I used setInterval too, because I found the web audio api docs for the timing functions rather confusing, and I'd set myself a time-limit on getting something "attractive" working.
Re: Show HN: Drum machine in 100 lines of HTML/JS
#24Re: Show HN: Drum machine in 100 lines of HTML/JS
#25Never use setInterval for audio based applications. It's just totally unreliable. WebAudio has nice built in features for high precision timing.
I doubt high precision timing can be done with the same amount of code.
Re: Show HN: Drum machine in 100 lines of HTML/JS
#26it behaves weirdly when you change the tabs, must be because of setInterval?
Re: Show HN: Drum machine in 100 lines of HTML/JS
#27http://imgur.com/a/O1dy8
Re: Show HN: Drum machine in 100 lines of HTML/JS
#28Re: Show HN: Drum machine in 100 lines of HTML/JS
#29http://imgur.com/a/O1dy8
http://imgur.com/a/zEj4w
Re: Show HN: Drum machine in 100 lines of HTML/JS
#30Including 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.