After struggling for some time with installing PulseAudio, and getting MPC/MPD working with HTTP streaming on Raspian I have put together some notes (mainly for my benefit), but would appreciate any feedback from members of the community as to if I have missed anything.
I would class myself as an intermediate user, so I am sure some experts out there could suggest improvements.
I still have a few minor issues which I will document later this week. I will also add more on usage of MPC and streaming.
Kind regards, and thanks in advance for any feedback.
http://caramel.pancakeapps.com/
Raspberry Pi
PulseAudio & MPD/MPC Installation
Initial Installation
Start by entering these commands from the terminal to update your system
sudo apt-get update sudo apt-get upgrade
Now install PulseAudio and the other required packages
sudo apt-get install mpd mpc pulseaudio pulseaudio-module-zeroconf mpg321 lame mplayer pavucontrol paprefs
Installing mplayer, mpg321 and lame will ensure that the MP3 codecs are setup, and that we can play MP3 files from the command line
At this point it is worth rebooting the system
sudo shutdown -r now
Configuring mpd
The configuration file for mpd is stored in /etc/mpd.conf
By default mpd will look in /var/lib/mpd/music
for music files, and in /var/lib/mpd/playlist
for .M3U playlists
Edit the mpd configuration file with the nano text editor by issuing the following command
sudo nano /etc/mpd.conf
Change the music_directory
and playlist_directory
settings to point to the location where your music files are stored
We also need to tell mpd to use the PulseAudio sound system rather than ALSA. Add these lines to the end of /etc/mpd.conf
audio_output { type "pulse" name "MPD PulseAudio Output" }
Remember to save the changes to the file when you exit
Issue the following commands to set the correct permissions for the folder
sudo chmod -R o+r (CHECK!) sudo chmod -R o+r (CHECK!)
For example if you use the default directory you would type
sudo chmod -R o+r /var/lib/mpd/music
At this point it is worth rebooting the system again
sudo shutdown -r now
Configuring PulseAudio
The first step is to edit the PulseAudio configuration file with the nano text editor
sudo nano /etc/default/pulseaudio
Add the following two entries to the end of the file
PULSEAUDIO_SYSTEM_START=1 DISALLOW_MODULE_LOADING=0
Step two is to make some changes to another PulseAudio file
sudo nano /etc/pulse/system.pa
Comment out the `load-module module-suspend-on-idle' by adding a '#' to the start of the line
Add the following two entries at the end of the file (Most home networks use '192.168.0.0/24', but it is worth checking with your provider if you have problems
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/24 auth-anonymous=1 load-module module-zeroconf-publish
The final step is to convert the ALSA configuration libraries to PulseAudio
sudo nano /etc/asound.conf
Add these entries to the file
pcm.pulse { type pulse } ctl.pulse { type pulse } pcm.!default { type pulse } ctl.!default { type pulse }
My Raspberry Pi is connected to our television via and HDMI cable, and I find the by default the sound does not work. To resolve this we need to edit the Raspberry Pi configuration file
sudo nano /boot/config.txt
Add the following line to select HDMI audio mode
hdmi_drive=2
Save the file and exit back to the terminal
Adding HTTP streaming (Optional)
Edit the mpd configuration file
sudo nano /etc/mpd.conf
Add the following code to the end of the file and save
audio_output { type "httpd" name "My HTTP Stream" encoder "lame" port "8000" quality "5.0" # bitrate "128" format "44100:16:1" }
Issues Resolved
I found that when I played sounds with MPD that the sound was played twice with a slight delay between the two outputs. The only way I could stop this was by disabling the 'ALSA' section in the MPD configuration file
Edit the mpd configuration file
sudo nano /etc/mpd.conf
Find the following section of code
# 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 "PCM" # optional mixer_index "0" # optional } #
Now comment out this section as shown below
#audio_output { # type "alsa" # name "My ALSA Device" # device "hw:0,0" # format "44100:16:2" # mixer_device "default" # mixer_control "PCM" # mixer_index "0" #}
Save, and exit back to the terminal
If you have not already done so now would be a good time to copy some MP3 files to the music_directory
specified in the 'mpd.conf' file
At this point it is worth rebooting the system
sudo shutdown -r now
Remaining Issues