Hacker News new | ask | show | jobs
by kowdermeister 3572 days ago
Never use setInterval for audio based applications. It's just totally unreliable. WebAudio has nice built in features for high precision timing.
1 comments

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.
>Safari

Try a better browser first. You might as well be using IE 8. I could write a book about the things that don't work in Safari.

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.