Welcome! Log In Create A New Profile

Advanced

Working Music Player Daemon (MPD) Config on Pogoplug

Posted by cefn 
Working Music Player Daemon (MPD) Config on Pogoplug
May 25, 2012 11:02AM
Hopefully I've remembered all the steps. Originally I had trouble with the C-Media USB card identifying itself with the right card identifier for MPD to pick it up, after getting MPD functional, I couldn't connect from a remote machine with an MPD client, and after connecting using ncpcpp I had skips and gaps in playback, which seemed to be to do with buffering or transcoding or something.

I installed...

apt-get install mpd madplay alsa-base alsa-utils mpc

The file /etc/modprobe.d/alsa-base.conf had to be edited to change the last line to

options snd-usb-audio index=0

where previously it prevented USB sound cards from being configured as card0 which many players seem to expect as a default.

To avoid skipping and gaps in playback I had to remove the configuration of the alsa card within the /etc/mpd.conf by commenting it out, leaving NO CARDS under the heading of "Audio Output" at all. This made MPD autodetect the card correctly on load, rather than trying to talk to it in an incorrect and inefficient way. My full MPD conf file is attached, but it has some other changes which are to my tastes as well, and you may or may not like them (e.g. Bonjour autoconfiguration, autorefresh of music directory).

Finally, the /etc/asound.conf file reads as per the original elsewhere in the forum...

pcm.!default {
    type plug
    slave.pcm "softvol"
}
pcm.dmixer {
       type dmix
       ipc_key 1024
       slave {
           pcm "hw:0"
           period_time 0
           period_size 4096
           buffer_size 131072
           rate 50000
       }
       bindings {
           0 0
           1 1
       }
}
pcm.dsnooper {
       type dsnoop
       ipc_key 1024
       slave {
           pcm "hw:0"
           channels 2
           period_time 0
           period_size 4096
           buffer_size 131072
           rate 50000
       }
       bindings {
           0 0
           1 1
       }
}
pcm.softvol {
       type softvol
       slave { pcm "dmixer" }
       control {
           name "Master"
           card 0
       }
}
ctl.!default {
    type hw
    card 0
}
ctl.softvol {
    type hw
    card 0
}
ctl.dmixer {
    type hw
    card 0
}
Attachments:
open | download - mpd.conf (14.2 KB)
Re: Working Music Player Daemon (MPD) Config on Pogoplug
May 25, 2012 11:04AM
If I didn't make this clear, it is now a working configuration of MPD, and sounds OK once these steps were taken. I shouldn't need to change anything else I hope.
Re: Working Music Player Daemon (MPD) Config on Pogoplug
May 29, 2012 02:54PM
Indeed the MPD system was working, and controlling a local USB soundcard, but I couldn't stop there. I wanted to be able to send the centrally controlled audio around to other parts of the house (I have various NSLU2 devices around the house running Debian with soundcards and wireless). There is a major problem with this as detailed below. One answer is as following...

#On the machine you want to receive the sound run this to create a long-lived daemon which waits for connection, and stays waiting after disconnection...
nc -k -l 17654 | pacat

#On the machine from which you want to send sound, you can target the waiting machine with a sound stream as follows...
pacat -r -d "alsa_output.usb-0d8c_C-Media_USB_Headphone_Set-00-Set.analog-stereo.monitor" | nc 192.168.1.60 17654

This relies on using Pulseaudio as an output on the source machine, and choosing the right source name. The pacat utility allows the bytestream from a pulseaudio source (in this case a sink monitor) to be streamed as bytes. Netcat allows bytestreams to be set up over the network, so if you launch these two command lines on two different machines after configuring MPD to use pulseaudio, and installing the needed packages, such as pulseaudio netcat-openbsd and so on, the audio from one is connected to the other.

This seems to settle at around 200kB consistently and about 3 seconds latency on my network, streaming to my ubuntu laptop's sound card.

BACKGROUND

The problem is that the ARM device isn't capable of accelerated floating point operations, (in contrast to a typical Intel chip). This means that the floating-point encoders which are normally used for MP3 cause the system to slow to a crawl (more than 100% of a Pogoplug's CPU anyway). The result of this is skipping, jumping audio if you activate MPD's built-in HTTP, or indeed attempt any other 'internet radio' strategy which re-encodes the signal, which is the normal way this works. Whilst the MAD decoder exists for MP3, which uses integer arithmetic, the equivalent mainstream ENCODER doesn't seem to exist, although people are experimenting with things derived from the (immature) Shine Decoder codebase, there's nothing simple to configure.

So I spent a bunch of time trying to find media-friendly ways of wrapping the wav output from MPD directly in a media stream without any reencoding, assuming bandwidth isn't an issue (local wireless lan) including this discussion which led to a working configuration of Rygel (but which simply revealed a problematic interaction with VLC).
http://osdir.com/ml/general/2012-05/msg56763.html

Having dug around and found various fifo-oriented tools for interacting with the wav stream I ended up trying the strategy described above, which worked as well as anything else, if you're happy with the command line. If you want something more GUI oriented, then look into the Rygel example a bit more, and find a less buggy client/mime-type configuration than mine. On the plus side, using Rygel you could potentially mount media from there as well as listening to a central MPD.

MISC DETAILS

Note the device name came from running...
pacmd list-sources

You can also try to minimise latency with the following extra options from the sending machine, but it's still a pretty long buffer for 3 seconds delay - that's in my router I guess...
pacat -r --latency-msec=1 --process-time-msec=1 -d "alsa_output.usb-0d8c_C-Media_USB_Headphone_Set-00-Set.analog-stereo.monitor" | nc 192.168.1.60 17654

Have fun with it. I'm saving the money on a baby monitor, feeding the microphone from upstairs to the stereo downstairs!

Cefn
http://cefn.com
Well till now I was as lost as you;

i tried streaming from windows to a pulse audio adaptator on a dockstar with a c media usb.
well execpt that running the deamon in root is highly unadvised , it works ok (minus i m still not able to autostart it at boot). you need linco and virtual cable; and the last kernel to get the updated pulseaudio that works far better.

and a lot of patience...

the delay is around 0.5ms, so not 3 sec, also on wifi.

if I would have to go from dockstar to dockstar I guess I would go to another strategy, that is UPNP or DNLA, so no convertion to make, sure it doesn t solve the problem for micro input, but you might try to encode locally with a 3rd party software in mp3 and stream it in http.if I had to do it, well i would push it on my nabaztag :-)

good luck to anyone trying that.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: