Building your own music player and... moreThis project is about using an usb-aware wifi router to play music. For this integration, I used the Asus WL500g Premium router and this because I needed 2 USB 2.0 ports (see schema).
Note that other broadcom-based routers should also do the job. For example, I tested the same setup on a WRTSL54GS (1 USB 2.0 port) router with an external hub to connect both the disk and the audio converter.
Why a router with 2 USB ports?
At least 2 usb connections are needed for this setup (either directly on the device or using a hub).
- The first port is used to connect the external disk. The disk acts both as the music library and as a shared drive for transfers and backups (using Samba).
- The second port is used to connect an audio converter. Even if the audio modules were made for the usb 1.1 controllers (either on ohci or uhci boards), they will cohabit seamlessly with the usb 2.0 controller (used by the disk). So that there is no real issue here; even regarding throughput since it's only audio.
You may wonder which audio converter to buy? Well, nowadays, any new one will work.
So basically the solution has two components:
- The router:
1) optionally booting from the external drive.
2) mounting a partition of the external drive where the music is stored.
3) exporting (with Samba) the music directory for external access & management.
4) but most of it, playing music...
- The client (PC or Mac) used:
1) to control the music player daemon installed on the server.
2) to rip the music and then upload/copy (using Samba) it onto the network drive mounted by the router.
The price (as of sept. '07)
- Asus WL500g Premium : 100 $.
- USB audio converter: 10 $ over ebay including shipping.
- An external USB 2.0 drive. I used the Seagate 360 GB/7200rpm/8mb for 130$. I bought this one a year ago for backups.
- A subwoofer. I used the Logitech X-530, currently 60 $ + taxes. I already had this piece in place for my Home Theatre.
TOTAL is 300$ + taxes. For that you will have a SAN (or as least a backup device) as well as an audio library player controlled by either a web or your PC application ( I still prefer this solution). Note that this price tag will drop under the 200 $ with newer routers like the WL-700gE...
The client interface
At first installing a web interface to remotely control the music player may seem a good idea. But truly, it adds too mush burden on the router (you will need a web server like lighttpd, some server-side technology like php and a site like phpMp2) for really small benefits. In fact except a ubiquitous access through firewall, I don't really see a benefit.... And even so.
Bottom line: You are way better with a fat PC/Mac/Linux client on your home computers to control your media player ;-).
1) Install openwrt whiterussian RC6. I choose RC6 for both its bcrm wifi support and x-wrt support... but I'd rather use the latest openwrt release (kamikaze) for its 2.6 kernel.
2) Install nas to enable wifi encryption.
% ipkg install nas
3) If needed, enable ssh (TCP port 22) for the wan interface in /etc/firewall.user and run this script. In case something goes wrong you will still have ssh access.
4) Install x-wrt (a more complete web interface to router management).
% ipkg install http://ftp.berlios.de/pub/xwrt/webif_latest_stable.ipk
then, from the x-wrt web interface (http://your_router), configure the router as a AP, client or bridge depending on your network deployment.
5) Install the usb support and (if you wish) make the router usb-bootable (see USBStorageHowTo).
You will have to install both usb 2.0 drivers (for the disk) and usb 1.1 drivers (for audio support). From the usb 1.1 install you will be able to see if your route is UHCI or OHCI compliant (WL500gP is UHCI & WRTSL54GS is OHCI).
6) Create some swap either on a partition or, as in the example, on a file.
% ipkg install swap-utils
# use the losetup package to create a loop device on a swap file
% ipkg install losetup
# create the swap file: 80Mg seems enough for a 32Mg router.
% dd if=/dev/zero of=/swapfile-80 bs=81920 count=1024
# install the script /etc/init.d/S95swap to make swap available at boot time & reboot.
4) Install and configure Samba (see SambaHowto)
% ipkg install samba-server
Then configure /etc/smb.conf to something similar to the example. In order to secure the samba and ease integration with Windows and Mac OS X, create a user account using passwd and then smbpasswd.
Note: Samba uses UDP:137-138 and TCP:139 & 445. You may want to open those port numbers to enable sharing on alll router inetrfaces.
5) Install the audio support as described in openwrt forum (recopied here for the sake of consistency):
src backports http://downloads.openwrt.org/backports/rc5
src sebek http://sokrates.mimuw.edu.pl/~sebek/openwrt/packages
# then install:
% ipkg install alsa-utils
% ipkg install libpthread
# extract the audio kernel modules from sebek's link above:
% wget -P /tmp http://sokrates.mimuw.edu.pl/~sebek/openwrt/packages/kernel-modules-sound-usb-2.4.30.tgz
% cd /lib/modules/2.4.30
% tar -zxvf /tmp/kernel-modules-sound-usb-2.4.30.tgz
# create a new file /etc/modules.d/70-snd-usb-audio containing the following entries
# then after reboot, new entries should be available in /dev/sound
6) Install mpd, the music player daemon.
% ipkg install mpd
# configure /etc/mpd.conf to something similar to the example
# create the music database
% mpd --create-db
# if needed, open mpd port (usually 6600) on the firewall
Note: I recommend to lower the audio volume at the mpd level and instead use the subwoofer to control the volume since I noticed that otherwise the audio converter was rapidly getting hot.
7) Install a mpd client on your PC or Mac. Then connect it to the router (usually over TCP port 6600) and play some music now :0