The slug can be turned into a network-attached audio player. Using integer codecs (due to lack of floating point unit) it's possible to decode a number of formats on the slug and output the audio via a cheap usb-audio adapter. One program, music player daemon (mpd), can be controlled via various clients from most operating systems. It's also capable of playing streamed music (internet radio, or stream the audio of the movie you're watching on your notebook). If you've got a lot of time at your disposal, you could even hack together an LCD plus some buttons to control it.. or use your mobile phone via bluetooth
Here are a number of products with similar capabilities (and less work):
This page tries to summarize what's needed to do that. Lots of this is quoted directly from mailing list posts by Glen Harris, Inge Bjørnvall Arnesen, tman and others.
The basic components needed are:
If you don't want to add sound hardware, you can still use the slug's internal speaker to play MIDI files.
Any Linux supported USB sound adapter should work (see http://www.qbik.ch/), but in practice some adapters work better than others.
Devices based on the C-Media USB Sound chips:
This chip is also in USB sound dongles that are sold on ebay. Mine is transparent green with the text "3D-sound" on it. Brands mentioned on the package are Comodow and LeadTide.
eFfeM once got audio playback and madplay running on openslug using a Philips PSC805 Aurilium card. However this was not reproducible. Others have seen similar behaviour with other devices (e.g. Griffin iMIC, Creative audio cards). As those cards work on PC linux systems it is expected that the problem is timing or byte ordering related.
I (karibou-hunter) found, and tried, successfull this one : http://www.dealextreme.com/details.dx/sku.5831 (this site is amazing :)
I (epninety) found that not all the USB sound dongles are equal. Mine looks like those described (translucent case, "3D-sound"), but only has one LED (some have two), and doesn't use the CM10x chip. It works straight out of the box, and plays my 320kbit MP3s with no glitches or gaps. Trouble is, the distortion is terrible! Even a simple sine wave has lots of distortion - (2nd harmonic of 10kHz tone only -20dB at full output, lots of other 'sprogs' visible too). Maybe I got a bad one? Chip bears the numbers "1621 C1-M6C P4A53-010C", not sure of the manufacturer. It looks like the second board in the pic at http://www.stockstore.com.br/BookPic/Som/somusbfo.jpg(approve sites) I wouldn't listen to this thing out of choice! I bought a Behringer UCA202 to replace it... Also works straight out of the box and sounds great!
(tbrier) Great success with the Turtle Beach Audio Advantage Micro (AKA Voyetra) http://www.amazon.com/Turtle-Beach-Micro-Voyetra-TBS-1120-01/dp/B0002ICGDY/ref=pd_bbs_sr_1?ie=UTF8&s=electronics&qid=1228548208&sr=8-1 Analog output is very high when the "Loudness" is enabled (default). Switch with alsamixer. There is some noise with the analog output, but it is very low compared to the signal level. This unit has an optical digital (SPDIF / TOSLINK) output that is coaxial with the 3.5mm analog output. The supplied adapter allows you to connect a fiber optic cable to the optical input of a receiver. This elimates ALL environmental noise. The fanless NSLU2 piped to the receiver optical input while running mpd, and qmpdclient on another computer in another room keeping the playslist stoked with favorites, is a most agreeable setup.
(Tom Harris) Another option is to use a pair of USB laptop speakers, which get both power and data through the slug's USB port and don't need a separate soundcard. They are also available in pretty small sizes, too, which fit with the slug's form factor. I needed a small set to fit inside an old wallbox that I'm converting into a slug-powered MP3? jukebox - a set of TEAC XS-2 speakers (http://www.amazon.co.uk/exec/obidos/ASIN/B000KHVGHO/) work fine with the slug and give reasonable sound (the bass is as good as can be expected from a pair of one-inch drivers ;-)
Testing the USB audio device for linux support:
You may want to start by testing your USB audio device to make sure you can actually get it to work on a standard desktop linux system. Typically you'll already have a non-USB sound interface (either a card, or one built into your motherboard), and even when you have a USB audio device plugged into a USB port, Linux will continue using the non-USB one by default unless you tell it otherwise. Here are some instructions for poking around in the GNOME GUI to make sure it works.
System > Preferences > Hardware Info brings up Device Manager, so you can make sure the device has been recognized.
To control the volume, double-click on the volume control icon in GNOME's top menu bar; this pops up an applet with the name of the sound card listed in its title bar. File > Change Device lets you select your USB device instead so you can set its volume.
To get some output, try Gnome > System > Preferences > Sound > Devices > Sound Events. Change it from autodetect to USB audio.
Software installation on SlugOS:
SlugOs users can install the "kernel-module-snd-usb-audio", "kernel-module-snd-mixer-oss" and "kernel-module-snd-pcm-oss" packages.
After that the following commands need to be given
C. Blue - Three of the above insmods might give an error message 'Unknown symbol in module'. If that happens, try creating the audio devices with these 'mknod' commands. Then retry insmodding and it should work:
If you still get the error message 'Unknown symbol in module' you can use 'modinfo' to see what dependencies the module in question has. Then check the dependencies are loaded using lsmod or insert them first. For instance if you check rawmidi using the line below, you'll probably see it depends on snd and snd-seq-device (true with SlugOS and kernel 220.127.116.11)
To control your card you need to install alsa using the command
Check (after plugging in your USB card and speakers) /proc/asound/cards to see if your card is actually present.
If so start alsamixer. Make sure the card is not muted and the sound volume ok. (mine is close to 100%).
As tests try:
Software installation on unslung:
Unslung uses the 2.4 linux kernel, which has less audio support than later versions. In particular, ALSA doesn't exist in the 2.4 kernel.
Bcrowell used the following procedure to get audio output working on unslung 6.8 with a C Media based usb audio dongle.
Put the insmods in a script in
#!/bin/sh insmod /lib/modules/2.4.22-xfs/kernel/drivers/sound/soundcore.o insmod /lib/modules/2.4.22-xfs/kernel/drivers/usb/audio.o depmod -a
and do a
[kismetcow] I followed (an earlier version of) the above instructions except I lamely didn't create S99mpd as a script (just as a plain-text file). I figured this out when I tried to add the line to the script to start mpd on bootup. Since I'd successfully gotten mpd to play without running those commands, I tracked down the insmods: they apparently were placed for me in
I then updated the daemon startup. I have this in
#!/bin/sh if [ -n "`pidof mpd`" ] ;then /bin/killall mpd 2>/dev/null fi sleep 2 /opt/bin/mpd
Following the advice at the MPD site, I'm running the service as a non-root user (I created a user called 'mpd'). I then discovered that the /dev/dsp device is not created with global permissions, so that needed to be chmod'd. There is no /dev/mixer, not sure why -- maybe usbaudio doesn't support it? Doesn't seem to matter: mpd runs without it, and mpd does not need ALSA. The client's volume control does cause MPD to scale playback.
fozzy had trouble getting madplay to work with the ALSA packages. In the end the problem was the OSS compatability packages need to be installed, i.e: kernel-module-snd-mixer-oss and kernel-module-snd-pcm-oss. A simple thing, but something that could catch others.
I (malfi) just bought a Creative Sound Blaster MP3+ USB. Sound quality is very good, it has gold plated RCA jacks and doesn't need an external power supply. I can recommend this little device by all means. It is supported by the 'audio' module in OpenSlug. But a small problem I stumbled across is the output sampling rate.
usbaudio: valid output sample rate 48000
mpd uses 41000 by default, so you have to add:
Furthermore the main mixer isn't called PCM, but 'Vol' at /dev/mixer. (Use aumix to figure it out.)
The mpd.conf should look like this:
# OSS Mixer mixer_type "oss" mixer_device "/dev/mixer" mixer_control "Vol"
This USB powered FM transmitter is an interesting option (not yet tried) http://www.myfmstation.com/html/linex_usb.html
I have audio working with an M-Audio Transit. It requires the firmware to be loaded onto the card with madfu http://usb-midi-fw.sourceforge.net/ but it should work. (Also beware of the order you modprobe the modules, this does matter.)
I tried the Linex FM transmitter and it works.
If you have choppy playback, try playing with the output rates and/or the audio buffers. I had choppy playback until I added the following lines to my mpd.conf:
audio_buffer_size "4096" buffer_before_play "10%"
Tips if your hardware is not working
Alsamixer (and amixer) may fail, complaining about a missing file. If this is the case it means that it can't find certain devices in /dev. To find this you must download the source for alsa and run ./snddevices (you may have to change the file to fix the owner-user format from root.root to root:root).
If things are not working perhaps try on a regular linux pc first. Also I got some good help on irc (freenode: #alsa)
Local and Network Storage
You can store your music locally on the NSLU2 or mount it over the network using NFS or Samba.
Internet Radio and Podcasts
You can specify the URL of an internet radio stream or a certain entry of a podcast directly. However if you want to listen always to the most recent podcast entry and/or your player is not able to interpret m3u/pls/asx playlists (like MPD), the following 'podcast-bounce' server can help: Hack:podcast-bounce.
The slug's CPU is fast enough to decode MP3 and Ogg Vorbis in real time, but the lack of floating point hardware means that not all players will give acceptable results.
mpg123 and XiMP3 can be built for the slug, but use floating point math, so are too slow for anything but low bitrates and/or mono output.
madplay and mpg321 use integer math to play MP3s and work well. At the moment only madplay - not mpg321 - is available as ipkg. mpg321 will be added in the next release (at least for SlugOS). However apparently madplay works better and uses less CPU cycles.
Music Browser is a web frontend for your music collection, which can do playback via madplay.
MPD is a "backend" player supporting many formats that is controlled by a TCP connection. It includes some playlist management features. Install the binary with "ipkg install mpd" (Now works with Unslung 6.8), alternatively see BuildMpd for details on getting it running from source.
Numerous MPD front-ends exist, and some should be easy to get running on the slug. The control connection can be protected with a password. One known working front end is wymypy which is a small, stand-alone python web server with a fairly usable AJAX web page interface. Zhyla spent a bit time getting this to work (summary: unpack the egg on a desktop machine, ipkg install the various python standard library modules needed).
[epninety]I wanted to be able to control the player from any (just about) web device on my network, so the frontend needed to be served from the slug. Using lighttpd and PHP5.2, I have two interfaces available, phpMp and Relaxx (both linked from the MPD wiki. phpMp works great on just about everything, Relaxx is more flashy but doesn't work on everything (like from pocket IE). Works great, very responsive, even with a 10,000 track library.
CPU usage on a TurboSlug peaks at less than 2% for MP3 files at all bitrates. Ogg Vorbis is similar except for q7 to q10, which briefly peak at 3.8%. Measurements were made with top, and the test samples were played in a loop so as not to measure the initial output buffer fill.
MPD maintains a database of the MP3 tracks, so for large collections (20,000+) the slug will need to have swap memory.
We want some way to control and see the status of the player.
Remote control from a PC
The easiest option is to SSH to the slug, and run a command-line player or something like mp3blaster, possibly inside screen, so it stays running when you disconnect.
With MPD, any of the available front-ends can be run on a remote PC.
Could be used with a serial or USB attached receiver.
Might be an option with something like this:
USB human interface devices
These are available as full keyboards, USB mice and (a possibly more suitable option) as calculator-style numeric keypads intended for use with laptop PC's. There are also adapters to connect PS/2 mice and keyboards to USB. These use a standard driver (kmod-usb-hid... in 2.6 kernels) and are readily available in computer and office-supply stores.
USB LCD display
This is a standard USB serial device and has a built in microcontroller to control the LCD. It has a sophisticated on-board firmware which can do scrolling, absolute positioned text and stand alone bar graphs(!). It is fully USB powered, unlike the serial version,and draws 200mA with the backlight on. With the backlight off, it draws roughly 80mA.
Another option is to use a cheap 128x64 graphical LCD screen to display infos (current song, songs library etc....). Sources and more infos at http://www.xwaves.net/?inc=projects
A good old time serial terminal is an easy option, but bulky.
In Norway you can get an Xbox compatible remote and receiver for €25, which is quite cheap (Linux drivers available for the remote as well as game pads). It is basically USB, but uses a different connector (adapters are available if you don't wanna solder). With the engineers best friend, the glue gun, some soldering, it might even reach "girlfriend approval standard". You may also look at the LCD solutions for Xbox. It is not that the Xbox equipment is that cool, but the volume is high, so the prices are low. Linux drivers are generally available too.
Sound Card Buttons
Some USB sound cards provide buttons for muting, adjusting the volume, etc. These buttons can be used to control the MPD (or any other application) in various ways. LIRC can read these key presses via the event device interface. A different little tool at http://www.devbase.at/nslu2/keyevent.php prints each key press to stdout and provides additional information like long/short/repeated/"double-click", eg. allowing for a script implementing PLAY, STOP, SKIP functionality with just a single button.
Power Supply concerns
Sound adapters (as opposed to speakers) should draw very little current, so powering the off the slug's USB bus is not a problem. Glen measured 12mA idle, 49mA attached to powered speakers, 80mA with non-powered 2W speakers.
A different issue is noise from the power supply affecting the audio output. This has been seen (heard, even) with a cheap "C-Media" adapter and hard disk attached to the slug. Adding a 47uF capacitor to the power lines of the audio adapter stopped the noise completely. Better quality adapters will likely filters on their power lines built in and not have this problem.
esalazar - I discovered with my TurtleBeach AudioAdvantage that I could not use the audio card plugged into my USB 2.0 hub. I had to plug it directly into the slug.
shm - I also found that the TurtleBeach AudioAdvantage would not work plugged into a hub, it was discovered when inserted, but would not output any audio, also noticed that madplay was ticking off too fast. I also discovered that the audio card was not recognized during initial boot, I have to unplug and plug the device back in to get it to work.
iano- Had the same problem when using the audio dongle with a hub. DMA time out errors in the log - it's a little bit odd. Anyway, I now have the external hdd & an 802.11 dongle on the hub in the "disk 1" slot and the audio dongle in slot 2. Everything up and working well. Next I want to add a bluetooth dongle and use my mobile phone as a remote control for mpd. Hopefully can avoid more DMA issues.
Lurch - I've got some cheap USB speakers which work when plugged directly into my slug, but not via a USB 2.0 hub. I experimented, and found they do work via a USB 1.0 hub. So I've got my flash root device and my speakers hanging off a USB 1.0 hub in port2, and a couple of NTFS disks hanging of a USB 2.0 hub in port1.
Apu - Solution for the problem with USB 2.0 hubs : Here.
bredde - I had a problem like the ones above with my audio dongle. The audio dongle is plugged into an USB(2)-Hub next to a bluetooth adapter and an external harddisk. Without the harddisk or the bluetooth adapter, my audio-stick worked fine, but when all three devices were pluged in, the dongle did not work. It was discovered correctly, but when I tried to play something with MPD, there were strange error-lines in /var/log/messages. The solution to the problem is as easy as incomprehensible: When the bluetooth adapter was not plugged in, I started to play music. While playing, I plugged the bluetooth adapter in and well... the adapter works fine. I also can stop the music and continue playing using my mobile-phone and bluetooth, no more problems since this procedure.
link to howto use the cheap "3D sound" usb card on the slug and debian: http://www.hermann-uwe.de/blog/playing-audio-on-the-nslu2
view · edit · print · history · Last edited by Tom Harris.
Based on work by JonBoy, tmbridgmailcom, Thomas Reitmayr, epninety, CBlue, Landon, janne5011, Mark Breddemann, karibou-hunter, Me, kismetcow, bcrowell, Zhyla, carlb, fcarolo, anonymous, gualteri, ssb22, HEINO, mathieu_xwave, oao, AlienZ, MPD, James Dear, eFfeM, die amme, Apu, Lurch, hifi-andrew, jpg, Iano, shm, fozzy, Brian Wood, Dietmar Zlabinger, esalazar, tman, neptune, DaveHooper, malfi, Malfi, alecv, Glen Harris, Michael-Luke Jones, and HannesReich.
Originally by HannesReich.
Page last modified on March 06, 2009, at 04:57 PM