Media Centre Odyssey 3: Architecture Revision

Hello, weary traveller. You might want to start at the beginning.

My original architecture used a uPnP Android device with Bubble uPnP and connected to my Bluetooth speaker. It seemed to work fine, but occasionally it would drop out for up to a minute at a time. Now, the problem of debugging this. It could be:

  1. The Pi not supplying the file fast enough
  2. The Wifi not supplying the file fast enough
  3. An encoding bottleneck on the tablet
  4. A Bluetooth problem communicating with the speaker

I could hardly believe the supply of a small MP3 file could cause the problem, but on the other hand local files on an Android device played over the Bluetooth without problems. This was also a frustratingly intermittent problem – sometimes it would play for over an hour with no blips.

I also tried changing the architecture slightly by installing mpd on the Pi and using mpdroid on the Android device. I used the mpd http stream support to play the music on the device and pipe through Bluetooth onto the speaker. In this scheme, the Pi is acting as both storage and decoder, with the tablet as controller but also a conduit from the Pi to the speaker. This architecture is the most complicated yet, and even more intermittent. I heard from the Bubble uPnP developer that http streaming on older Android devices like my HTC Desire was buggy and I should upgrade.

But this seemed like hard work and I thought the number of moving parts in this solution was bound to have problems. I also still didn’t like the dependency on a conduit Android device that was subject to battery life (or, for example, the person with the phone wanting to leave the house). Time for a rethink.

Although the http streaming didn’t work, I really liked mpd, which has server-side playlist you can control from multiple client devices. The mpdroid control is a fully fledged smart-phone remote controller with the ability to edit the upcoming tracks and search for the music you want to play. Also, the search is fast; my 10,000 track collection usually returns from a search in under a second. You can also use a software volume control that you can, again, access from the remote if you uncomment this line in the /etc/mpd.conf

mixer_type "software"

It was time to relax one of my previous constraints, that the Pi should be sited anywhere. If I sited the Pi next to the speaker I could connect them with a robust and easy to debug technology – a wire into the 3.5mm audio jack. Multiple Android devices, each with an mpdroid install, could control the playlist. Having connected all this together, I was very pleased – it all seemed to work! The remote was easy enough that I could install it on my wife’s Android phone and she actually felt able to use it!

Unfortunately, the solution was still not perfect. I found that when the volume was turned down too low, the sound quality became very poor. I spent ages trying to change drivers and tune ALSA (which is bloody awful, by the way) on the Pi. I’d even gone as far as assuming my Pi was broken and ordering another when I found out the answer. The Pi is not meant to have high quality audio through the audio jack. Of course.

The solution, apparently, is to buy a USB sound card. So I tried this one, reported by lsub as:

C-Media Electronics, Inc. Audio Adapter (Planet UP-100, Genius G-Talk)

It kind of worked, but was fuzzy. I tried a lot of hints I found online, including this and some of this but it was still fuzzy. Then I bought this only to find it contained identical hardware. Argh! Then I tried this (notice how I’m gradually getting more expensive), but when it arrived it reported as this:

C-Media Electronics, Inc. Audio Adapter

Argh again! It looks the same! However, this one works without fuzziness. I only had to buy three sound-cards to get there. I also had to do this in /etc/modprobe.d/alsa-base.conf:

options snd-usb-audio index=0

and this in /etc/mpd.conf:


audio_output {
type "alsa"
name "USB Audio"
device "hw:0,0"
}

So now, we have a completely working high-quality audio jukebox, controlled from multiple remotes that are easy enough my wife can use them. Of course, this might now seem moot since you can get a canned Raspberry Pi distribution that does this. But I’m not done yet!

Advertisements

One Response to “Media Centre Odyssey 3: Architecture Revision”

  1. hooliganshark Says:

    Peter, thank you for taking the time to document your odyssey. Similar to my Pi issues but have not given up yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: