Live data from Hacker News

JavaScript mp3 decoder allows Firefox to play mp3 without flash

jsmad.org

31–40 of 99 posts

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

#31
If imitation is the sincerest form of flattery, feature requests must be the next-sincerest. With that out of the way, I'd love to see:

* Standard playback widgets: volume, position slider, etc.

* A way to link songs, e.g. http://jsmad.org/play/114578

Fantastic work!

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

#32
I'm curious whether you came up with the logo after the fact, or whether you named it after the mag?

I've been surprised at how blatantly some recent open source projects reference pop culture in ways that are just begging for a takedown order - cool.io is another. I suppose it may be worth it if you're primarily focused on getting noticed in the short term (perhaps to get investment or a good job offer), but long term it seems to guarantee that the project will need to go through a rename with all the confusion that entails.

Edit: Forgot to say the technology really is amazing.

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

#33

It'd be neat to have a overview of the different 'modules' in play and what they do (either in the README or a separate wiki page). Great stuff!

We would've loved to have that too when porting the mad code.

Here's a quick overview:

bytestream is our general I/O abstract class - there's much room for improvement because it works with Strings. substream allows to have a 'view' of a slice of a bytestream.

filestream and ajaxstream are two implementations of bytestream, doing local File I/O (with the upcoming W3C File API) and XMLHttpRequest streaming. On Firefox 4.0+, ajaxstream takes advantage of mozBinaryResponse and uses Uint8Array(s) to 1) compute the amount of data read, and 2) implement getU8 (which is used a lot).

bit.js is a straight port of libmad's bit manipulation routines. Bit-level I/O is a must-have in an MP3 decoder because you have numbers stored on 7 bytes, 19 bytes, and other weird stuff like this (especially in the huffman decoding part).

huffman.js, imdct_s.js, rq_table.js are all tables used somewhere else in the process.

layer3.js is really the central part. it implements huffman decoding, the various IMDCT transforms, reordering, requantizing... all sorts of magic tricks I didn't fully grasp even while porting. Comparing the output was really our best weapon. The libmad guys are really the reference guys for this kind of question. We had to strip out all their fixed-point stuff because it's really of no use in Javascript, since JS only has floating point numbers - even if we can make them behave almost as integers, it's still as costly as FP arithmetic so we just went floating point all the way - hence, jsmad doesn't have 24-bit output like libmad has. libmad is wayyyy better at everything :)

synth.js is the second central part - it synthesizes the sound waves from the decoded MPEG Layer-III data. It's the most expensive part of the project, since it's just thousand meaningless arithmetic operations, something JavaScript doesn't excel at.

mad.js contains mostly constants (errors), a few utility functions

decoder.js isn't used anywhere, it's my attempt to port decoder.c from libmad, but it's unfinished.

player.js is our ill-fated attempt to play the decoded MP3 correctly - it's really naive (no seeking, stutter in some cases, no buffering of decoded frames, etc.)

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

#34
post #32

I'm curious whether you came up with the logo after the fact, or whether you named it after the mag? I've been surprised at how blatantly some recent open source projects reference pop culture in ways that are just begging for a takedown order - cool.io is another. I suppose it may be worth it if you're primarily focused on getting noticed in the short term (perhaps to get investment or a good job offer), but long te…

The library is named after libmad, which when ported to js became jsmad.

The page linked is just a demo for Music Hackday Barcelona, was not intended to get _this_ much publicity.

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

#37
post #32

I'm curious whether you came up with the logo after the fact, or whether you named it after the mag? I've been surprised at how blatantly some recent open source projects reference pop culture in ways that are just begging for a takedown order - cool.io is another. I suppose it may be worth it if you're primarily focused on getting noticed in the short term (perhaps to get investment or a good job offer), but long te…

The library is named after libmad, which when ported to js became jsmad. The page linked is just a demo for Music Hackday Barcelona, was not intended to get _this_ much publicity.

Ah, makes perfect sense. Thanks and good luck with the project!

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

#38
post #36

Thanks to all contributed to this clever hack. MP3 on all browsers, without flash, is a really worthy goal. But I'm hearing sputtering, myself. Are you guys going to carry this to a production-capable system?

Yes, it is stuttering right now. Especially when it is in the background. We think this is a buffering issue, but yes. We hope this will be able to go into production soon(tm).

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

#39

Doesnt work for me (no audio): Chrome 12 on Ubuntu 10.10 64-bit Youtube is playing fine. Here's the Chrome debugger log: http://pastebin.com/MwqfD1K5

No, it does not work in Chrome yet, only Firefox 4+ (or Aurora etc). But it is on the roadmap.

Works fine for me on Chrome 13, OS X 10.6.7, however I do have Web Audio enabled in about:flags. Whether or not the Web Audio API's by-passing jsmad, I don't know.

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

#40
post #36

Thanks to all contributed to this clever hack. MP3 on all browsers, without flash, is a really worthy goal. But I'm hearing sputtering, myself. Are you guys going to carry this to a production-capable system?

Yes, it is stuttering right now. Especially when it is in the background. We think this is a buffering issue, but yes. We hope this will be able to go into production soon(tm).

FWIW, I'd love to see support for icecast or shoutcast streams.
Post reply on HN