Live data from Hacker News

JavaScript mp3 decoder allows Firefox to play mp3 without flash

jsmad.org

11–20 of 99 posts

Re: JavaScript mp3 decoder allows Firefox to play mp3 without flash

#11
post #8

jsmad lead developer here, shoot if you have any questions!

Does anyone have a good handle on what the GPL means in the context of a javascript library invoked by an html page rendered by a browser? I certainly don't! nb, you say: "libmad has commercial license. As for jsmad, we're in a sort of grey legal area." I presume you mean that you would have problems with a commercial licence? Your work is clearly a derivative work of libmad, so it has to be GPLv2 licensed: any comme…

Yes, anything under the GPLv2 is obviously fine. But we cannot relicense it under a commercial/liberal license like libmad could (at least not without their permission).

Re: JavaScript mp3 decoder allows Firefox to play mp3 without flash

#13
post #8

jsmad lead developer here, shoot if you have any questions!

Does anyone have a good handle on what the GPL means in the context of a javascript library invoked by an html page rendered by a browser? I certainly don't! nb, you say: "libmad has commercial license. As for jsmad, we're in a sort of grey legal area." I presume you mean that you would have problems with a commercial licence? Your work is clearly a derivative work of libmad, so it has to be GPLv2 licensed: any comme…

Yes, we would love to discuss commercial license with the Underbit/libmad guys. So if you're here, hello! Let's talk :)

Re: JavaScript mp3 decoder allows Firefox to play mp3 without flash

#14

jsmad lead developer here, shoot if you have any questions!

o/

Hey dude :) Long time no see. As you can see, I've moved on t greener pastures ;)

(I also happen to be the author of http://ooc-lang.org/, and that's where I know gmaster1440 from)

Re: JavaScript mp3 decoder allows Firefox to play mp3 without flash

#15

As a wise Keanu Reeves once said, "Woah." Is there any upper limit you've found with bitrates, etc.? Also, what was the most difficult part in building this?

320kBit ones works fine (the max for MPEG1/2 streams.)

We did most of the work during and after Music Hackday Berlin (and it was continued at MHD Barcelona) and just staying awake was quite difficult, but porting much of the low-level bitfiddling and pointer-stuff to javascript was hard because of language differences, but also converting a fixed-point library to the floating-point that is available in javascript was a bit of trouble.

Re: JavaScript mp3 decoder allows Firefox to play mp3 without flash

#16
post #4

Earlier quoted context omitted.

It seems to stutter if you change tabs, is this due to restrictions in Firefox background tabs and timers? Edit: Awesome stuff, btw :D

The answer to this is complex, and I've spent the last night tuning the player so that it wouldn'd do that. There are several scenarios here: 1) Either the MP3 data buffer doesn't fill fast enough (slow network transfer), so when it runs out of buffer, all hell breaks loose. This is because player.js is really naive, so more a demo bug than a jsmad bug. 2) Or Firefox fails to call the scheduled tasks (via setTimeout)…

From the Firefox 5RC1 release notes:

> Background tabs have setTimeout and setInterval clamped to 1000ms to improve performance

As far as I'm aware, Chrome does this also but I'm not sure what version it was introduced in.

Re: JavaScript mp3 decoder allows Firefox to play mp3 without flash

#18
post #8

Earlier quoted context omitted.

Does anyone have a good handle on what the GPL means in the context of a javascript library invoked by an html page rendered by a browser? I certainly don't! nb, you say: "libmad has commercial license. As for jsmad, we're in a sort of grey legal area." I presume you mean that you would have problems with a commercial licence? Your work is clearly a derivative work of libmad, so it has to be GPLv2 licensed: any comme…

Yes, anything under the GPLv2 is obviously fine. But we cannot relicense it under a commercial/liberal license like libmad could (at least not without their permission).

That's my take too.

The remaining question then is just how far the reach of the GPL is in the context of a javascript library. Just the javascript that actually calls the code? Everything else called from the same html page? Everything else on the same site?

It's a shame the history of libmpg123 is so clouded: they've made a good effort to contact all the previous developers to get permission to LGPL the library, but they haven't been able to reach everyone so there are always going to be lingering doubts.

Re: JavaScript mp3 decoder allows Firefox to play mp3 without flash

#19

As a wise Keanu Reeves once said, "Woah." Is there any upper limit you've found with bitrates, etc.? Also, what was the most difficult part in building this?

Been playing 320kbps Stereo flawlessly afaik. The bitrate is really not much of an issue.

Browsers have a much harder time dealing with binary XHRs, huge typed arrays, huge strings, and a real fucking lot of arithmetic operations.

I think the most difficult part was the debugging. Jens Nockert, Matthias Georgi & I finally used node.js and carefully diff'd the output from minimad.c (the canonical libmad example) and jsmad.

However, it quickly became obvious that comparing exact values wasn't going to cut it. Listening was also almost useless (try to debug when all you have is SCRRRCHHHHHH vs CRRRRRRKKKKKK). So we plotted graphs. With gnuplot. It was a matrix-like experience but quickly allowed us to see what was wrong.

Profiling the code via Firebug made us realize that most of the time (~28%) was spent in the synthetizer (synth.js). The I/O code is particularly expensive too, it's a mix of Uint8Arrays and javascript Strings, depending on whether you're using the local file version (filestream.js) or the http streaming version (ajaxstream.js)

One of the funniest part was when I had to code 36-bit precision integer routines in Javascript such as shifting, OR-ing, AND-ing.. I had to separate the numbers in a low word and a high word and then work with floats (which have a 54-bit mantissa in JS).

Really quite an experience!

Re: JavaScript mp3 decoder allows Firefox to play mp3 without flash

#20
post #17

If the site isn't loading for you (I was getting nginx errors for a bit before it finally loaded for me), here's the github repo: https://github.com/nddrylliog/jsmad

Yes, we're running this on a node.js+nginx VPS and you guys are MURDERING it.

That's great news though! Bear with us as we try to handle the traffic :) And reload from time to time until it works.

Edit: all static assets are now served by nginx, and the default track is cached on our server instead of being proxied by node.js all the way. Wish we had CORS at official.fm!

Post reply on HN