Coding Ducks

Friday, September 16, 2005

Enjoy the music with your router

Some months ago we found an USB-audio adaptor in a computer shop. This adaptor is very inexpensive, just costs us about US$10 in Hong Kong. Plug this in our PC (running Fedora core 3), we can see the infomation about this gadget:

T: Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 4 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=0d8c ProdID=000c Rev= 1.00
S: Product=C-Media USB Headphone Set
C:* #Ifs= 4 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=00 Driver=snd-usb-audio
I: If#= 1 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
I: If#= 1 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
E: Ad=01(O) Atr=09(Isoc) MxPS= 200 Ivl=1ms
I: If#= 2 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
I: If#= 2 Alt= 1 #EPs= 1 Cls=01(audio) Sub=02 Prot=00 Driver=snd-usb-audio
E: Ad=82(I) Atr=05(Isoc) MxPS= 100 Ivl=1ms
I: If#= 3 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=hid
E: Ad=83(I) Atr=03(Int.) MxPS= 4 Ivl=32ms
We have USB 2.0 host in some models of the MANGA series, like MANGA Plus. So what we want to do is making a MP3 jukebox, with a MANGA and a USB-audio adaptor. This jukebox will able to play the MP3 music automatically when you plug in a USB storage device (USB key, USB harddisk, or even a ipod shuffle) with MP3 files to it. It will search all the MP3 files in the USB storage and generate a playlist, we also want to have a very simple web UI to access this playlist via the network. Finally we call this little jukebox "MANGA tunes".

Actually we found this is not a pretty hard job to make the router sing! The USB audio adaptor is compatible with the USB audio class, and the kernel 2.4.24 running in the MANGA has USB audio class support. So we go to enable the USB audio class support option, and the related sound options, then recompile the kernel. After loaded the new kernel on the board, the USB audio adaptor can be recognized.

With the help of the Linux hotplug scripts, we can recognize and mount the USB storage as soon as we plug it in. We do some survery for our MP3 player. The Madplay in MAD project is our choice as its small size and pure integer computation. The later one is important since we do not need to use the floating point emulation for our ARM9 CPU.

The web UI is written in a very simple bash script CGI. We can start, stop, or select which song we want to play. The CGI is slow and not very responsive, but I think it is ok for us. :-P

So this takes us about one day to put them all together, and we can have some background music in our working space. It is also fun to get the others' USB keys, plug in the MANGA tunes, to share the music we like. Right now, the Cantonese-pop and J-pop are our engineers' favorites.

Some photosnaps of MANGA tunes are in the last post :


  • I should post this more eailer, and I did. But I click 'back' in the publish page by mistake, oops....

    By Blogger Jason Miu, at 8:12 AM  

Post a Comment

<< Home