How To Configure JustBoom With MPD

//How To Configure JustBoom With MPD
How To Configure JustBoom With MPD 2017-10-27T20:38:52+00:00

Set Up Your JustBoom With MPD

This guide will show you how to obtain, install and configure MPD using a JustBoom card.

This guide is suitable for both Raspbian Jessie Full and Lite. Some steps will be slightly different.

configure justboom with MPD

Before you start.

MPD has been tested with:

Note that the steps can also be adapted to work with the Digi HAT and Digi Zero.

Section 1 – Prepare Raspbian

MPD is the Music Player Daemon and in this guide we will be installing it and configure it over an existing Raspbian image.

You can find the official documentation for MPD at this link.

Step 1 Retrieve and burn an image of Raspbian Jessie Full or Lite to an SD card. Before ejecting the card remember to enable SSH and setup your WiFi connection.

Note that there is no need to follow our guide on Raspbian to configure MPD. Should you decide to do it be aware that the configuration file below will need to be changed.

Step 2 – Update the OS and retrieve MPD using the apt-get command.

sudo apt-get update
sudo apt-get install mpd mpc

In the second line we added mpc so that we can control MPD in later steps.

Step 2bis – For Raspbian Jessie Full only.
If you type

fuser -fv /dev/snd/*

you will get something like this

                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  pi          758 F.... lxpanel

to show that the audio card is busy because of controls within the GUI. The quickest way for a workaround is to change the booting option for Rasbian so that it starts in console mode.
Run

sudo raspi-config

Then choose “Boot Options” -> “Desktop / CLI” -> “Console” and reboot for the changes to take effect.
Running once again the command above should not return anything indicating that the sound card has been freed up.

Step 3 – Save the original version of the mpd.conf file by executing this command*.

sudo mv /etc/mpd.conf /etc/mpd.conf.org

then create a new one

sudo nano /etc/mpd.conf

and copy the following contents

follow_outside_symlinks         "yes"
follow_inside_symlinks          "yes"
music_directory                 "/var/lib/mpd/music"
playlist_directory              "/var/lib/mpd/playlists"
db_file                         "/var/lib/mpd/tag_cache"
log_file                        "/var/log/mpd/mpd.log"
pid_file                        "/run/mpd/pid"
state_file                      "/var/lib/mpd/state"
sticker_file                    "/var/lib/mpd/sticker.sql"

user                            "mpd"

bind_to_address         "localhost"

input {
        plugin "curl"
}

audio_output {
        type            "alsa"
        name            "JustBoom"
        device          "hw:1,0"
        mixer_type      "software"
        mixer_device    "digital"
}

If you have configured the config.txt to disable the onboard audio card bcm2835 then the device in the config above should be replaced with “hw:0,0”. Run aplay -l to make sure which device to use

*Note that the Digi boards require an extra step. Please check the “Digi boards” section of our documentation on Github for an alternative version of the mpd.conf file and the relative ALSA configuration.

Step 4 – Restart the mpd daemon

sudo systemctl restart mpd

and verify that it is running by executing

ss -l | grep 6600

which should return something like this

tcp   LISTEN   0   5   127.0.0.1:6600    *:*
tcp   LISTEN   0   5         ::1:6600   :::*

Section 2 – Play music on MPD

There are several clients available to control MPD. For this guide we will be using mpc but there are many alternatives for both the console and the GUI.

For the purpose of this guide we will be using music stored on the local file system but MPD offers several plugins to connect to remote resource like SMB, NFS, etc.

We have copied our files under “/var/lib/mpd/music” as specified in the configuration file.

Step 1 – Run

mpc update

then

mpc ls

to verify that the files have been added to mpd’s database.

Should you encounter problems when adding and playing files make sure that the files have the right permission. They should be accessible by the user mpd and the group audio.

Step 2 – Now we can add some of those files to a playlist

mpc add -filename-

and verify that the file is now in the playlist

mpc playlist

Step 3 – To play simply type

mpc play -filename-

other useful commands are:

mpc current
mpc outputs
mpc status
mpc volume 
mpc next
mpc pause
mpc stop

to find out more about the commands above and for more options use

mpc help