Oct 14, 2012

Getting CMedia USB Sound to Work with MPD on the Raspberry Pi

This assumes that you have a working installation of mpd and mpc and you can get sound out of the analog port. Using 2012-09-18_wheezy.img, the analog sound still has loud pops when you change streaming stations in mpd, plus noticeable hiss in the background of quiet passages.

To get the CMedia USB Sound dongle (looks like this one available at Newegg) working, you need to install alsamixer (if not already installed) via the command:
sudo apt-get install alsa-utils
Once that is installed, you need to modify the appropriate section of /etc/modprobe.d/alsa-base.conf so it looks like this:

# Keep snd-usb-audio from beeing loaded as first soundcard
#options snd-usb-audio index=-2
options snd-usb-audio index=0
Setting the index to 0 allows the USB Sound dongle to be loaded first. Index=-2 prevents that.
Then, in /etc/mpd.conf, you want to change the sound section like this:
# An example of an ALSA output:
#
audio_output {
    type           "alsa"
    name         "My ALSA Device"
    device        "hw:0,0"    # optional
    format         "44100:16:2"    # optional
#  mixer_device    "default"    # optional
    mixer_control    "Speaker"    # added 2012-10-04 for USB Sound dongle
    mixer_index    "0"        # optional
}
"Speaker" is how alsa-mixer refers to the device (alsamixer partial screen show below):
 Card: C-Media USB Audio Device                       F1:  Help               │
 Chip: USB Mixer                                      F2:  System information │
 View: F3:[Playback] F4: Capture  F5: All             F6:  Select sound card  │
 Item: Speaker [dB gain: -26.69, -26.69]              Esc: Exit     
         
If you have problems, examine the output of mpd from /var/log/mpd/mpd.log by tail. When I was troubleshooting this, the log was helpful. Here are some sample messages which pointed me in the right direction:
Oct 14 19:46 : avahi: Service 'Music Player' successfully established.
Oct 14 19:46 : mixer: Failed to read mixer for 'My ALSA Device': no such mixer control: PCM
I tried using PCM because that is associated with the first installed sound card. Making the changes shown for alsa-base.conf to allow the USB Sound card to start first changes the alsamixer output to Item: Speaker from Item:PCM











Oct 4, 2012

Open WiFi settings on raspberry Pi

If you are trying to connect to an open wifi router with your Pi, change the following settings in
/etc/network/interfaces. These settings worked with Raspbian 2012-09-18-wheezy-raspian.

# my wifi device  auto wlan0  iface wlan0 inet dhcp wireless-essid [ESSID]   # your router SSID wireless-mode [MODE]  # usually mode is "managed"

Oct 3, 2012

LCD and Pandora on raspberry pi



Went to town on the raspberry pi this week while I stayed with my friend John in Eureka.
The picture shows my new Pi in a laser cut case I made at TechShop SF last week. On top is a TextStar tiny LCD showing one of 4 screens, this one the wireless USB adapter's IP address. See the post at jeremyblythe.blogspot.co.uk, "Raspberry Pi with TextStar Serial LCD Display" on how to set this up with python.
I used adafruit's nice Occidentalis v0.2 release for the main software, based on Raspbian Wheezy Debian. This has a lot of good packages already built in, including ssh. I just used my Mac Terminal program to set the Pi up over Ethernet initially.
To get pandora going, I used pianobar. The install is simple:
sudo apt-get install pianobar
Set up the config file for automatic login and you're good to go.
To get streaming radio on the Pi, I installed mpd, the Music Player Daemon. This is an easy install also:
sudo apt-get install mpd mpc
See the article at www.t3node.com/blog/streaming-audio-with-mpd-and-icecast2-on-raspberry-pi for setup.
Getting the Pi to work with the popular mpd iPhone client, MPoD, was a bit of a challenge. MPoD could see the Pi via avahi/bonjour, but not connect to it. John found out you have to have bind_to_address for "local host" commented out for MPoD to be able to connect to it.