Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Sounds a lot different in firefox and chrome. Not bad in either but don't know what the more accurate one is.


Author here. This is the major drawback of this approach. Since I'm tuning the sound tone by adjusting the playback rate, what algorithm the browser uses for up and down sampling is a major aspect of how playback sounds that I have no control over. I think one browser uses nearest neighbour and the other uses linear interpolation (I forget which uses which). Ironically, NN is more accurate in terms of sounding like an Amiga


Firefox has a lot of "clicking" sounds for me at the start of most samples. Like one instant square wave with no length.

Plays super laggy for me if it's an unfocused tab in firefox.


The lag happens because FF throttles the frame rate that's calling Jerrica when a tab isn't the center of attention. When used in a game, the developer could choose the lazy route I did in the demo or could stop calling Jerrica completely.

In terms of the clicks and pops, if it's not an imposition, could you let me know if you hear similar artefacts in the Newgrounds game listed in the FAQ? That MOD file was specifically modified to try and minimise that issue and I'd be interested in if it sounds better or worse on your setup.


About the clicks in firefox:

I've dealt with this problem in a MIDI webapp I've developed a couple of years ago (midiano.com). If I remember correctly, firefox had some issue when samples were scheduled to immediately start with a gain value above 0. I believe the solution was to schedule them slightly earlier with a gain value of 0 and using "gainNode.setValueAtTime" to make the sound appear at the desired time.

Not entirely sure if that was the exact solution but I do remember firefox causing some problems in that regard. I just recall it being a hacky solution and that I couldn't find a documented explanation of why it happened.


Usually I associate that sort of problem with *stopping* a sample (since the stop will almost never happen at a point where the wave is actually at zero). Interesting that FF might have problems at the beginning, since most samples do indeed start at zero. I'll explore around that. Cheers!

Edit: midiano.com is excellent! Super useful to be able to visualise MIDI's that way.


I just went back and actually found the corresponding issue on my repository. Turns out it was firefox having issues with the setTargetAtTime function. I replaced it with linearRampToValueAtTime to get rid of the clicking sounds. I think for that to work I had to shift each note a little forward and then do a very quick ramp in the beginning. It does alter the sound a little though.

Also: Thank you! The idea is definitely derived from Synthesia but that isn't free anymore and I wanted to make it work in a browser :)


Sorry for late reply. There's clicks in the Newgrounds game too.


No worries. I appreciate it. I'm going to see if I can reproduce the issue and try @Bewelge's solution.


On my machine at least, Firefox seems to clip short audio samples (in general—-not related to this project).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: