Live data from Hacker News

Show HN: Drum machine in 100 lines of HTML/JS

sig.gy

31–40 of 51 posts

Re: Show HN: Drum machine in 100 lines of HTML/JS

#32

Never use setInterval for audio based applications. It's just totally unreliable. WebAudio has nice built in features for high precision timing.

When the goal is showing off what you can do with 100 lines of code, what's wrong with it? I doubt high precision timing can be done with the same amount of code.

First, it's an enourmous waste of computing resources. Second, it doesn't even work, since the 'setinterval' is unusable for audio timing. Third, what's there to show off? So Javascript got a 'PlayWav' function that you call in not so regular intervals depending on buttonstate. Simple beatbox is simple. Could aswell be 30 lines.

Re: Show HN: Drum machine in 100 lines of HTML/JS

#33
I thought the drum sounds would be generated using JS, but they are just pre-recorded samples (bass_drum.wav, snare_drum.wav, low_tom.wav, mid_tom.wav, hi hat, cymbal, cowbell, hand clap, hi tom, conga, claves). I'm looking for drum-generated sounds using pure javascript, so I can make changes on them and create new kinds of sounds. I already created some pure JS sounds (e.g. laser sounds, bass effect, white noise, achords, bell sounds, water drop) but I'm still looking for equations to generate more realistic drum sounds: http://js.do/blog/sound-waves-with-javascript/

Re: Show HN: Drum machine in 100 lines of HTML/JS

#34
post #32

Earlier quoted context omitted.

When the goal is showing off what you can do with 100 lines of code, what's wrong with it? I doubt high precision timing can be done with the same amount of code.

First, it's an enourmous waste of computing resources. Second, it doesn't even work, since the 'setinterval' is unusable for audio timing. Third, what's there to show off? So Javascript got a 'PlayWav' function that you call in not so regular intervals depending on buttonstate. Simple beatbox is simple. Could aswell be 30 lines.

Not sure why this is down voted — the demo literally does not work in my browser (Safari 10) because of the (mis)use of setInterval.

Re: Show HN: Drum machine in 100 lines of HTML/JS

#35

Never use setInterval for audio based applications. It's just totally unreliable. WebAudio has nice built in features for high precision timing.

When the goal is showing off what you can do with 100 lines of code, what's wrong with it? I doubt high precision timing can be done with the same amount of code.

The problmem is that it's shaking like it has Parkinson's. It can be be coded with webaudio with the same effort.

I've researched this in the past and it's nowehere near significant more complexity. In fact, a primitive solution is about the same as a setInterval call.

Re: Show HN: Drum machine in 100 lines of HTML/JS

#36

Never use setInterval for audio based applications. It's just totally unreliable. WebAudio has nice built in features for high precision timing.

When the goal is showing off what you can do with 100 lines of code, what's wrong with it? I doubt high precision timing can be done with the same amount of code.

The premise of showing off anything with 100 lines of code seems backwards.

Re: Show HN: Drum machine in 100 lines of HTML/JS

#37

I thought the drum sounds would be generated using JS, but they are just pre-recorded samples (bass_drum.wav, snare_drum.wav, low_tom.wav, mid_tom.wav, hi hat, cymbal, cowbell, hand clap, hi tom, conga, claves). I'm looking for drum-generated sounds using pure javascript, so I can make changes on them and create new kinds of sounds. I already created some pure JS sounds (e.g. laser sounds, bass effect, white noise, a…

I can't give you 'realistic' drum sounds, but I was working on an approximate recreation of a Roland analog drum machine using only Javascript. I got the sound engine down more or less, but kind of fell off the rails when I moved away from my earlier, crappier sequencer and started using a framework.

The sounds should work across browsers when you're manually playing (use the bottom row of your keyboard) but when sequenced playback happens, things get weird. Chrome more accurately reproduces the sounds as I'm imagining them.

Grab the whole thing at https://github.com/leviathant/BossDR110/tree/feature/synthes... or just play around with it yourself at http://bitrotten.com/dr110/webaudio/

Post reply on HN