This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-04-28 08:44:48

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

JavaScript Mp3 decoder / encoder

Aim :
To write a pure javascript based mp3 decoder which supports
MPEG 1 , 2 and Layer 1,2,3
with Id3v2 tags.

Why :
Well This question is huge ! and here is the reason,

1. Since webAudio / mozAudio api's , and the fileReader API  the internet browser is becoming an intresting platform for development of really powerful apps
and actually i like where is it going but webAudio and mozAudio both lack the functionality of saving the song as a compressed dataformat , what they deal with is PCM raw, which surely cannot be saved to file and not at all transferred on wire [keep the file size in mind ]

Jussi Kalliokoski's audiolib.js has a proof of concept of saving files
// he converts them to wav and can be saved later.

I wanted to go one step even further and convert them to .mp3 ( because its more widespread & lightweight & supported by all )

secondly mozAudio doesnt even supports the de-coding of mp3 song .

jsMad was a proof of concept ( though very limited ) , which actually de-codes mp3 audio inside a web-browser.

but jsmad is limited to client side and is a pure port of libMAD and lacks qualities  sad  with speed :-( no joy!.

2. Server side javascript I dont know if you guys have heard about this but server side javascript is extremely powerful , and by benchmarks node.js 's v8 vm engine actually beats JAVA at speed.
See ( keep in mind the node version there is extremely outdated and node.js has been optimized further )

So i thought it can actually act as a great platform for building web-apps etc. and like php and C++ has got there mp3 conversion libraries , i thought it will be nice to write one for node.js aswell .

3. For the sake of learning .. most of us have used mp3 but do we actually understand what does an mp3 consists of ???

The sad answer for most is no and it was the same for me too before a week , i still have loads to learn though but reading source docs and source codes of Mp3 and libMad has given me a lot of knowledge about mp3 .

Also a libary like this being open will help a lot of developers like me [ i actually wanted to use this for something i am working on already but found no joy ].


3.Road Map
DECODER
1. To read id3v2 - Done
2. To read mp3Frame Header - Done
3. To fetch body / frame - Done
4. To prepare a huffman table [ color= red] Not _ done [/color]
5. To prepare a de-compressor using huffman and convert the audio in huffman form to PCM.
6. VBR [ not necessary but will be cool as awesome ]

ENCODER
----HALTED::Work will begin once decoder is done ----
1. To write id3v2 tags - Done
2. To write mp3FrameHeader Done
3. Strip of unhearable parts using psychoacoustic model
4. Convert to hoffman
5. Write a full frame

Source code ??
Post below if you are intrested i will send you it .

Required Skills

1. Advanced javascript knowledge.
2. knowledge of C++.
3. Eagerness to learn.
4. Will to code more talk less [ hehe trust me this is kinda important as the huffman tables only consist about 80kb ].


So wanna join ? (by the way if somebody is wondering about why i asked here , then um well i know there are loads of curious scratchers out there who have been coding a lot lately in langauges away from scratch aswell ;D , some might get involved in this )

btw the id3v2 reader :: http://gist.github.com/2481696

// Seriously it look quite naive so far

Last edited by fanofcena (2012-04-28 08:50:42)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#2 2012-04-28 08:53:03

ZeroLuck
Scratcher
Registered: 2010-02-23
Posts: 500+

Re: JavaScript Mp3 decoder / encoder

I don't think you are allowed to write an MP3-Encoder/Decoder.
Because of license problems. But what about Ogg-vorbis? Ogg vorbis is open source and better than MP3!


http://3.bp.blogspot.com/-oL2Atzp0Byw/T465vIQ36dI/AAAAAAAAADo/1vqL4PvhkM0/s1600/scratchdachwiki.png

Offline

 

#3 2012-04-28 08:55:01

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: JavaScript Mp3 decoder / encoder

ZeroLuck wrote:

I don't think you are allowed to write an MP3-Encoder/Decoder.
Because of license problems. But what about Ogg-vorbis? Ogg vorbis is open source and better than MP3!

+1


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

#4 2012-04-28 09:00:43

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: JavaScript Mp3 decoder / encoder

ZeroLuck wrote:

I don't think you are allowed to write an MP3-Encoder/Decoder.
Because of license problems. But what about Ogg-vorbis? Ogg vorbis is open source and better than MP3!

How on earth does lame exists ? // you just need to pay a license fees in some countries.


why not ogg-vorbis ,

not widespread  tongue  , // i am talking about common man.

and

with ogg-vorbis we have .flac a much better audio compression  tongue

Last edited by fanofcena (2012-04-28 09:01:50)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#5 2012-04-28 09:18:06

ZeroLuck
Scratcher
Registered: 2010-02-23
Posts: 500+

Re: JavaScript Mp3 decoder / encoder

fanofcena wrote:

you just need to pay a license fees in some countries.

That is what I mean.
If you want to pay much money you can do that.

But this is not the only problem:
MP3 is very very complicated! You need very good math skills and
you have to understand much about audio!
I bet you won't finish this project...
But you can try of course.

Last edited by ZeroLuck (2012-04-28 09:19:21)


http://3.bp.blogspot.com/-oL2Atzp0Byw/T465vIQ36dI/AAAAAAAAADo/1vqL4PvhkM0/s1600/scratchdachwiki.png

Offline

 

#6 2012-04-28 09:48:14

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: JavaScript Mp3 decoder / encoder

ZeroLuck wrote:

fanofcena wrote:

you just need to pay a license fees in some countries.

That is what I mean.
If you want to pay much money you can do that.

But this is not the only problem:
MP3 is very very complicated! You need very good math skills and
you have to understand much about audio!
I bet you won't finish this project...
But you can try of course.

Wanna bet $500 on that ?

// Don't count my scratch projects when u are calibarating me  tongue  I deleted most of my projects a long while back .  tongue

Last edited by fanofcena (2012-04-28 09:53:16)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#7 2012-04-28 10:52:53

ZeroLuck
Scratcher
Registered: 2010-02-23
Posts: 500+

Re: JavaScript Mp3 decoder / encoder

I didn't look at your scratch projects.
But you won't finish this project without copying the code from others and don't using finished MP3 librarys...


http://3.bp.blogspot.com/-oL2Atzp0Byw/T465vIQ36dI/AAAAAAAAADo/1vqL4PvhkM0/s1600/scratchdachwiki.png

Offline

 

#8 2012-04-28 12:29:00

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: JavaScript Mp3 decoder / encoder

ZeroLuck wrote:

I didn't look at your scratch projects.
But you won't finish this project without copying the code from others and don't using finished MP3 librarys...

How can you be so sure about that ?



But yes there is one place where i will have to use other libraries code

the huffman tables :-| for mp3 they are 80kbs alone and i am NOT going to write them by hand.. [removed] NO!

[moderator note - please use appropriate language when using the Scratch Forums

Last edited by Lucario621 (2012-04-28 14:56:57)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

Board footer