Add a USB sound card
From NAS-Central Buffalo - The Linkstation Wiki
Last edited by Jamie Wither.
Originally by akeyyeka.
Linkstation USB Sound Guide
The purpose to add a usb sound card should be different from people to people. We have many ‘remote’ sound solutions for example, slimserver, network streaming etc. So why we are in persuit of a ‘local’ sound solution?
a) Cost effective
The cheapest usb sound stick can be purchased only about 50 RMB (Roughly 7 US dollars) in any computer accessory store on Shanghai street, with acceptable quality (no worse than many on board AC97 sound system), while most network media players cost several hundred USD. It is worth investing some work to save some money!
Even if you are in persuit of high quality sound you can usually find a better usb sound card with good sound quality at a reasonably low price. If you consider the cost of building another computer system for audio play, or a network media player with HI-FI sound quality this solution can save you money.
Once you turn your Linkstation into an audio box, you can control it to do a lot of things by programming. For example, you can turn it into an alarm clock; you can make it read book or web page for you; you can let it report its download status without turn on another computer and log on; and you can let it play music for you.
Of course, not all the functions are readily available, the point is, it has the potential to turn into something which can use the usb sound hardware, and would add a lot of fun to your playing with your LS.
c) For fun
I believe thats one of the purpose for many people, when he/she flash the openlink firmware and ‘open’ the box. I get a lot of fun for make things work.
Pros & Cons
LS is power saving and quiet if you just put it far away in a corner, but if you use it as a juke box, you will find it is more noisy than you think.
There could be several ways to reduce the noise:
- reduce the fan speed
- reduce the HD sound by hdparm command
- hardware adjustment
- put the LS faraway or in a box and use a usb and/or sound extension cable
b) Computing power
Sound play will not use much CPU power, the CPU consumption should vary from 1% to 30% from my observation. If due to some reason your box are very busy, sound play may not be possible.
c) Audio format support
Some audio format may be kept as a secret, so there might be only binary for X86 machine avaible, that we can not find the decoder source code; some audio format may be patent protected, so only source code could be distributed, we need to compile it ourselves. If an audio format are not supported by your player application, you will need to wait until it is supported, so code your own. Either way means a long time wait.
Now you know the purpose and you may start to consider build your own usb sound system. The first thing needs to be decided is hardware selection.
a) Which Linkstation?
Divided from instruction set, there are two kinds of LS, LS I and LS HG uses PowerPC instruction set, which supports hardware floating point operation; LS II uses MIPSel instruction set, which does not have hardware floating point support.
FP program might be executed correctly on LSII, however, each FP instruction will cause a trap, and kernel will emulate it. The performance is simply slow with a program doing FP operation repeatly.
Lack of hardware FP instruction does not matter for most services, but for audio decoder, it is another story. Many audio decoder use FP operation to do their work. So if you use LSII, you will experience performance issue with many decoder. This could be resolved by choosing an integer decoder, however, choose a PPC based system will give you a wider range of solution selection and save you a lot of trouble.
I personally use an LSII, so there will be solutions to decoding on LSII, hope this will save your money if you happened to have an LSII and started to consider swap with an HG because of sound play is slow.
b) Which USB sound card?
It depends on which kernel do you use and which sound system do you use. The open link kernel is version 2.4 and uses the OSS sound system. I didn’t installed a debian on my box but I know that debian user could upgrade to kernel 2.6 and ALSA is the recommended sound system on kernel 2.6. You can go to the following two site and check the compatibility list, then decide the sound card/kernel combination of your own.
In practical, I uses a cheapest usb sound card with C-Media chip (C-Media USB Headphone Set) and it works fine. You can lookup the devices section of the wiki to see if a specific type is known to work.
I uses a USB2.0 card but in theory USB1.1 card should work, even if the higest dvd audio stereo sample rate (96Khz) with 24 bit sample precision yields the bandwidth of 2.3*2=4.6Mbit/s, still far lower than the 12Mbit/s limit of usb1.1; typical CD stereo sample rate (44.1Khz) with 16 bit precision only consumes 0.7*2=1.4Mbit/s bandwidth.
Openlink and Debian
Again, it will save you a lot of trouble if you use Debian, a lot of people uses Debian here and there are very big Debian community outside. On the other hand, openlink are not originally designed for multipurpose use so you may need to do some work manually to get the sound system work. Personally I work with openlink so the guide here will based on OSS and openlink, Debian users might add Debian topic here, and kernel 2.6 users might add Kernel 2.6 topics here, I’ll put place holder for things I didn’t cover.
Install the kernel module
The openlink 0.52 firmware does not contain kernel modules with usb sound support. The first thing you need to do is compiler your own kernel usb sound modules, or download pre-compiled kernel module from the download section of the wiki (I do the latter). REMEMBER, install pre-compiled module ONLY IF it is for BOTH your BOX type (I, II, HG) and kernel version. Type “uname -a” from a telnet/SSH connection to check for the kernel version.
You don’t need to install all the modules, for usb sound support on OSS you only needs the following thing:
Copy these two modules to the place indicated by the path above, you may want to change the path a little if you are using a different hardware or version of kernel. Issue a ‘depmod -a’ to rebuild kernel module dependence.
Then you need to load these modules, however, ‘modprobe audio’ may not always work. If you also have usbcore.o module compiled and installed, this module will also be loaded as a dependence of module audio, then I encounter problem such as “can not find proper devices”.
Instead of using modprobe to resolve all the dependence for you, use insmod to load module manually:
#insmod soundcore Using /lib/modules/2.4.20_mipsel_linkstation/kernel/drivers/sound/soundcore.o #insmod audio Using /lib/modules/2.4.20_mipsel_linkstation/kernel/drivers/usb/audio.o You are expected to see the following: #lsmod Module Size Used by Tainted: P audio 46352 0 (unused) soundcore 4544 3 [audio] If you see lsmod output like this, your sound card might not work: Module Size Used by Tainted: P audio 46368 0 (unused) usbcore 72192 0 [audio] soundcore 4544 0 [audio]
Note usbcore itself could be seperatly loaded, and maybe needed by other usb devices, just don’t make audio.o depend on it with modprobe. I didn’t make module loading automatically on my system yet, so there is no detailed guide here yet. But I think it should be easy by add a new script in the /etc/rc.d/rc2.d directory.
For ALSA specific issues
Insert the usb sound card
Once the usb sound card get its presence in the Linkstation system, kernel should get aware of the existence of the USB device. If a device deriver had already loaded for the USB sound card, the following line for similar should be printed when you issue a “dmesg” command:
usb.c: registered new driver audio usbaudio: device 2 audiocontrol interface 0 has 1 input and 1 output AudioStreaming interfaces usbaudio: valid input sample rate 48000 usbaudio: valid input sample rate 44100 usbaudio: device 2 interface 2 altsetting 1: format 0×00000010 sratelo 44100 sratehi 48000 attributes 0×01 usbaudio: device 2 interface 1 altsetting 0 does not have an endpoint usbaudio: valid output sample rate 48000 usbaudio: valid output sample rate 44100 usbaudio: device 2 interface 1 altsetting 1: format 0×80000010 sratelo 44100 sratehi 48000 attributes 0×01 usbaudio: registered dsp 14,3 usbaudio: constructing mixer for Terminal 6 type 0×0301 usbaudio: warning: found 1 of 2 logical channels. usbaudio: assuming that a stereo channel connected directly to a mixer is missing in search (got Labtec headset?). Should be fine. usbaudio: registered mixer 14,0 usbaudio: constructing mixer for Terminal 7 type 0×0101 usbaudio: registered mixer 14,16 usb_audio_parsecontrol: usb_audio_state at 83bb7c60 audio.c: v1.0.0:USB Audio Class driver
If no device had recognized your device, you will see the following in dmesg output:
usb.c: USB device 2 (vend/prod 0xd8c/0xc) is not claimed by any active driver.
If you see the latter, check if your usb sound card is supported by the sound system you are using, and check if proper kernel module is loaded. It doesn’t matter which happens first, insert the usb stick or load the kernel modules. Once both thing are inplace, you will see the successful message. This means you can keep your usb sound card stick to your box, and use an automatic script load the modules on each startup.
Build proper device under /dev (openlink specific)
Once you get usb sound card and kernel modules in place, you may want to start to play it with a sound player like mpg321. If you are using openlink, however, very likely you will get the following information:
libao: unable to find proper devices
That is because openlink does not comes with proper audio device files under /dev, these things needs to be built manually.
If you are using OSS support, what you are missing here is /dev/dsp; /dev/dsp1; /dev/mixer; /dev/mixer1; you can grab a MAKEDEV script from any Linux system and execute it under /dev directory, which will create these devices for you. Andre also put a copy of his /dev directory on his LS box (I suppose?) you can get the box address from the following link http://linkstationwiki.org/forum/3_889_0.html you can also choose to do this manually:
cd /dev mknod -m 660 mixer c 14 0 ; chgrp audio mixer mknod -m 660 mixer1 c 14 16 ; chgrp audio mixer1 mknod -m 660 dsp c 14 3 ; chgrp audio dsp mknod -m 660 dsp1 c 14 19 ; chgrp audio dsp1
I noticed that the number following ‘c’ is in match with number in the line contains “usbaudio: registered” in section 4. I think there is some relationship in it. I suppose you can check all such lines in dmesg output, and execute only the matching lines in the MAKEDEV script.
For alsa solution
Now you run mpg321 again you should be able to hear something.
Integer decoder (LS II specific)
If you happened to be an LS II user, when you try to play you might encounter FP operation issue (explained in section 1). If you hear cluttered sound output, see 99% CPU usage, use ‘time’ command to start your program and see most time are in system, you probably have FP performance issue here.
The solution is to find an integer decoder or player. There should be a seperate artical to list all the integer decoders and players. Maybe even a download section.
Anyway, if you have an LS II, you have more limitation on player selection than LS I or LS HG users. Or you will need to do a lot of hacking and programming. There will be more pain (or more fun?) in turning your LS II into an ideal sound system
This is just out of the topic but I’d like to put it here to make this artical complete.
To make your Linkstation sing is just the first step, then you need some softwares to provide a solution to manage your music collection and play it on demand. My objective is to turn my LS II into a juke box controlled by a gamepad. So I don’t need to control playing from another computer. Other people may have different target.
The following sites provide solutions that are worth investigating: