>== Play music on Plug via USB2AUDIO Dongle ==
Making you plug into a Jukebox is easy, all you need is a usb2audio dongle and a set of speakers.
The following description assumes you are using Ubuntu/Debian based distribution.
Kernel config
Start by adding kernel sound support:
CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_TIMER=y CONFIG_SND_PCM=y CONFIG_SND_HWDEP=y CONFIG_SND_RAWMIDI=y CONFIG_SND_SEQUENCER=y CONFIG_SND_HRTIMER=y CONFIG_SND_SEQ_HRTIMER_DEFAULT=y CONFIG_SND_SUPPORT_OLD_API=y CONFIG_SND_VERBOSE_PROCFS=y CONFIG_SND_DRIVERS=y CONFIG_SND_ARM=y CONFIG_SND_SPI=y CONFIG_SND_USB=y CONFIG_SND_USB_AUDIO=y CONFIG_SND_USB_CAIAQ=y
USB sound support:
CONFIG_SND_USB=y CONFIG_SND_USB_AUDIO=y CONFIG_SND_USB_CAIAQ=y
Applications installation
Next step we need to install some packages, for Apache based web server:
sudo aptitude install apache2.2-common apache2-mpm-framework php-common libapache2-mod-php5
If you prefer lighttpd web server, then install:
sudo aptitude install lighttpd php5-cgi
And install Samba and MPD too:
sudo aptitude install mpd mpc samba samba-common swat
So now you should have:
1) PHP and Apache2/lighttpd web server installed for the Music Player web interface
2) MPD - Music Player Daemon http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki
3) Samba and swat (Samba web based configuration util) to get the audio files onto your plug USB/SD storage
Download the relaxx MPC (Music Player Client), we will use it as the MPD front-end.
wget http://relaxxplayer.googlecode.com/files/relaxx-067.tar.gz
And unpack it to your /var/www directory.
If you want to use the web server for relaxx only, you can move all /relaxx/* content to /var/www (which is usually the web server root directory) to refrian from http://device-ip/relaxx notation.
Make sure the files extracted from the tarball are owned by www-data
sudo chown -R www-data.www-data /var/www/
Application Configuration
1) Create a samba share using swat http://device-ip:901
2) Edit the /etc/mpd.conf to use media from the new share you added (assuming the share is a mount point to some USB/SD storage)
3) Create a link from the /var/lib/mpd/music/<link_name> to you mounted media device
for example: sudo ln -s /mnt/usb /var/lib/mpd/music/my-usb
4) Replace the /var/www/music soft link (which is a part of relaxx) with a link that points to your music (for example: /mnt/usb)
5) Place any play list file in the /var/lib/mpd/playlists directory.
6) Insert your USB audio dongle to the Plug USB and use dmesg to see that kernel noticed it. Here is the print I got using AK4571 Demo Board:
usb 1-1.4: USB disconnect, address 5 usb 1-1.4: new full speed USB device using orion-ehci and address 6 usb 1-1.4: configuration #1 chosen from 1 choice input: AKM AK5371 EEPROM mode as /devices/platform/orion-ehci.0/usb1/1-1/1-1.4/1-1.4:1.3/input/input1 generic-usb 0003:0556:0002.0002: input: USB HID v1.10 Device [AKM AK5371 EEPROM mode] on usb-orion-ehci.0-1.4/input3
You can use the cat /proc/asound/devices to see the device number we will use to configure MPD.
Edit the /etc/mpd.conf and add an entry for your audio USB dongle
audio_output {
type "alsa"
name "My ALSA Device"
device "hw:0,0" # optional, device number from the /proc/asound/devices list
format "44100:16:2" # optional
}
7) If you chose lighttpd, make sure you enabled mod_fastcgi in modules section and add the following to your /etc/lighttpd/lightppd.conf
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 2,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "16",
"PHP_FCGI_MAX_REQUESTS" => "10000"
),
"bin-copy-environment" => (
"PATH", "SHELL", "USER"
),
"broken-scriptfilename" => "enable"
)))
Restart the MPD service
sudo /etc/init.d/mpd restart
MPD Alternatives
I, User:rektide, have used MPD far more than what I'm proposing, but I do want to mention some alternative:
- The MPRIS protocol is a FD.o D-Bus spec for interacting with media players; any media player with MPRIS control can be interacted with remotely.
- UPnP defines MediaServer / MediaRender devices capable of forming a networked media ecosystem. One of the advantages of UPnP is that it may be easier to adhoc add/remove accessible media than NFS/SMB file sharing.
The advantage here is that while MPD is one daemon that has a large number of clients, these specs define a more general interface with both multiple clients—as mpd—and multiple servers, be they headless or more conventional. This is handy for two reasons:
- MPD in particular is a fairly static piece of software: adding and removing media on the fly isn't easy, each system needs its own MPD configuration... its good fixed infrastructure, but systems like UPnP are much better at allowing you to access whatever media is on hand at the time.
- If you use a program like VLC, you could use the same client to control VLC as you use to control MPD. Sure, if you're sitting at your desk watching VLC the pause button is right there on VLC, but if you ever want to control VLC remotely, as you're controlling your music remotely, this may be a boon.
UPnP is really the premo solution here, as you can avoid all the fixed infrastructure of samba mounting and you get a truly generic media playing framework, but linux tooling for mediaplayer/mediarenderer's is still not uber-advanced, and typically not geared towards headless implementation. Xvfb will frequently suffice.
Servers: Headless
- Have you considered using MPRIS to control MPD via mpDris?
- XMMS2 is at its core a headless music playing daemon. has many clients, and a crude mpris bridge.
- Coherence as a UPnP MediaRenderer
Conventional players
Note that in some cases it may be feasible to run a virtual frame buffer—Xvfb—to run these programs without a display. Particularly for UPnP media renderers, this may be interesting.
- vlc via mpris
- bmpx via mpris
Clients
- potentially lots via MPRIS
Playing Music from Dongle
Now you can copy your music to the Samba share you created and create MPD DB by running the following commands:
sudo /etc/init.d/mpd stop sudo /etc/init.d/mpd start-create-db
Now open the web browser on http://device-ip/, you should see the folders and add to your playlist, you can also add some playlist (m3u,asx,mp3,ogg,url:port) URL to the list and listen to Internet radio.
For more Relaxx options goto: http://relaxx.dirk-hoeschen.de/
Tested with
HW:
Siig SoundWave 7.1 USB Sound Card AK4571 Demo Board
Linux Version:
sheeva-2.6.30-rc5,6, 2.6.30.2
Enjoy your new Jukebox :)
