![]() |
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. Sound HardwareAny 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: http://www.qualitycables.com/Category.cfm?catid=121&AZX=usb-digital http://www.amazon.co.uk/TRUST-SC-5500P-EXTERNAL-SURROUND-SOUND/dp/B0002Z2QQY 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 :) 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 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.
/opt/etc/init.d/S90audio (OR DON'T: see note following), like this:#!/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 /etc/rc.d/rc.locmods which is part of the bootup. (This with Unslung 6.8beta, and Logitech V10 USB speakers.)
I then updated the daemon startup. I have this in /opt/etc/init.d/S90mpd:
#!/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.
Card-specific issuesfozzy 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. dmesg output: usbaudio: valid output sample rate 48000 mpd uses 41000 by default, so you have to add: audio_output_format "48000:16:2" to /etc/mpd.conf. 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 workingAlsamixer (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) Music StorageYou can store your music locally on the NSLU2 or mount it over the network using NFS or Samba. Player SoftwarePerformanceThe 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. Playersmpg123 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. MPDMPD 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). 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. User InterfaceWe want some way to control and see the status of the player. Remote control from a PCThe 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. Hardware interfacesInfrared RemotesCould be used with a serial or USB attached receiver. USB JoysticksMight be an option with something like this:
http://mercury.chem.pitt.edu/~shank/mpcstick-0.10.2.tar.gz USB human interface devicesThese 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 displayhttp://www.cwlinux.com/eng/products/products_cw12232.php 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 Serial terminalA good old time serial terminal is an easy option, but bulky. Xbox accessoriesIn 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 ButtonsSome 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 concernsSound 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 Landon.
Based on work by Thomas Reitmayr, 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 May 19, 2008, at 02:05 AM
|