Turn your Pine64 into a music server with mpd - Printable Version

+- PINE64 (
+-- Forum: PINE A64(+) (
+--- Forum: Pine A64 Projects, Ideas and Tutorials (
+--- Thread: Turn your Pine64 into a music server with mpd (/showthread.php?tid=4387)

Turn your Pine64 into a music server with mpd - JulianM - 03-22-2017

Hi together!

This topic is structured into a few categories.
• Prepare your Pine64
• Installing and setup MPD
• Fix sound problems with alsamixer
• Installing und setup Samba
• Control your MPD via IR remote control
• My own setup

» Prepare your Pine64

What do you need?
- Pine64 board.
- Speakers via audiojack.
- Install the latest Ubuntu image by longsleep.

What you'll get?
- A music server which can be controlled via Windows, Linux and Android.

First of all:
Download the latest Ubuntu image by longsleep.
Overview of all Ubuntu images powered by longsleep

I downloaded the following image:

After you have downloaded and burned the image on your micro sdcard you need to apply some pre requirements.

If you just downloaded the Ubuntu image you have to resize the partitions of your microsd card.
Just enter this command:

Next step: Update the software of Pine64.
apt-get update
apt-get upgrade

Ok, all pre requirements are given now.

» Installing und setup MPD

Let's install mpd!
apt-get install mpc mpd
mpc (Music Player Command, client) is a command line program to manage mpd (Music Player Daemon, server).

Fix permissions of mpd directories:
chmod 770 /var/lib/mpd/music/ /var/lib/mpd/playlists/
chown -R mpd:audio /var/lib/mpd/music/ /var/lib/mpd/playlists/

Apply my config for mpd:
cat <<EOF >/etc/mpd.conf
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"
port                 "6600"
log_level            "verbose"
restore_paused       "yes"
auto_update          "yes"
auto_update_depth    "3"
filesystem_charset   "UTF-8"
id3v1_encoding       "UTF-8"

input {
    plugin          "curl"

audio_output {
    type            "alsa"
    name            "My ALSA Device"
    mixer_type      "software"
The configuration of mpd is done.

Now activate audio output via 3.5 audiojack!
But please note:
The 3.5 audiojack will be the default device for all audio output with these configs!
cat <<EOF >/etc/modules-load.d/pine64-audiojack.conf
cat <<EOF >/etc/asound.conf
pcm.!default {
       type plug slave {
               pcm "hw:1,0"

ctl.!default {
       type hw
       card 1

Reboot your Pine64 to apply changes of sound cards.

Just copy all your music files into the following directory:
I'll explain how to copy files from your Windows machine easily to your mpd server at the end of this post!

Take note that ownerships are correct!
If not, apply them.
chown -R mpd:audio /var/lib/mpd/music/

Update the music database of mpd with mpc.
mpc update

Alright, you're done!

Feel free to manage your mpd server with different mpd clients!
These are my favourites:
• Linux & Windows: Gnome Music Player Client
• Android: MPD ControlDroid MPD Client

» Fix sound problems with alsamixer

Normally there should be no problems with sound if you are using the latest Ubuntu image by longsleep.
So, you are advised to check the following settings in alsamixer.
Unmute "Headphone" with toogling "m"
Set "ADCL Mux" to "DMIC".
Set "ADCR Mux" to "DMIC".
Set "AIF1 DAC timeslot 0 volume" to 85.
Set "AIF1IN0L Mux" to "AIF1_DA0L".
Set "AIFIN0R Mux" to "AIF1_DA0R".
Unmute "DACL Mixer ADCL" with toogling "m"
Unmute "DACL Mixer AIF1DA0L" with toogling "m"
Unmute "DARC Micer ADCR" with toogling "m"
Unmute "DACR Mixer AIFDA0R" with toogling "m"
Set "digital volume" to "0".
Set "headphone volume" to "75".

» Installing und setup Samba

How to copy your files from your Windows machine to your Pine64 - Use SFTP or... Let's install Samba!

apt-get install samba-common samba

Create a Samba user to manage your files:
smbpasswd -a mpd
Just set a password for mpd user.

Apply my config to login via Samba with mpd user:
cat <<EOF >/etc/samba/smb.conf
workgroup = WORKGROUP
server string = Samba Server %v
security = user
dns proxy = no

path = /var/lib/mpd
valid users = mpd
force user = mpd
force group = audio
create mask = 0660
directory mask = 0770
browsable = yes
writable = yes

Restart Samba.
/etc/init.d/samba restart
Now you are able to copy your music very easily from Windows to your Pine64.

Just add a "Network ressource" on Windows with the following path:
Username: mpd
Password: You have choosen it with "smbpasswd -a mpd"

[Image: mpdbsufd.png]

» Control your MPD via IR remote control

Control your MPD server with the official IR remote control by Pine64!

You need to install "keybinder", to re-mapping the keys of your IR remote control to execute commands.
apt-get install unzip gcc make
cd ~
mkdir keybinder
cd keybinder
cd keybinder-master/
make install
cd ~
rm -r ~/keybinder

Use "evtest" to determine the event input of IR receiver:
apt-get install evtest
Choose the event number with "sunxi_ir_recv".
The event number depends of the plugged in usb devices!!!

root@pine64:~# evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      sunxi-keyboard
/dev/input/event1:      axp81x-supplyer
/dev/input/event2:      sunxi-ths
/dev/input/event3:      audiocodec sunxi Audio Jack
/dev/input/event4:      sunxi_ir_recv
/dev/input/event5:      MCE IR Keyboard/Mouse (sunxi-rc-recv)

Now press a few buttons on your IR remote control.
You should see some entries like...
Testing ... (interrupt to exit)
Event: time 1490184760.781095, type 4 (EV_MSC), code 4 (MSC_SCAN), value 40400d
Event: time 1490184760.781095, type 1 (EV_KEY), code 13 (KEY_EQUAL), value 1
Event: time 1490184760.781095, -------------- SYN_REPORT ------------
Event: time 1490184761.023186, type 1 (EV_KEY), code 13 (KEY_EQUAL), value 0
Event: time 1490184761.023186, -------------- SYN_REPORT ------------
Event: time 1490184761.793386, type 4 (EV_MSC), code 4 (MSC_SCAN), value 404010
Event: time 1490184761.793386, type 1 (EV_KEY), code 16 (KEY_Q), value 1
Event: time 1490184761.793386, -------------- SYN_REPORT ------------
Event: time 1490184762.043188, type 1 (EV_KEY), code 16 (KEY_Q), value 0
Event: time 1490184762.043188, -------------- SYN_REPORT ------------
Event: time 1490184762.734733, type 4 (EV_MSC), code 4 (MSC_SCAN), value 404011
Event: time 1490184762.734733, type 1 (EV_KEY), code 17 (KEY_W), value 1
Event: time 1490184762.734733, -------------- SYN_REPORT ------------
Event: time 1490184762.983185, type 1 (EV_KEY), code 17 (KEY_W), value 0
Event: time 1490184762.983185, -------------- SYN_REPORT ------------
Event: time 1490184763.508206, type 4 (EV_MSC), code 4 (MSC_SCAN), value 40400e
Event: time 1490184763.508206, type 1 (EV_KEY), code 14 (KEY_BACKSPACE), value 1
Event: time 1490184763.508206, -------------- SYN_REPORT ------------
Event: time 1490184763.753183, type 1 (EV_KEY), code 14 (KEY_BACKSPACE), value 0
Event: time 1490184763.753183, -------------- SYN_REPORT ------------
Event: time 1490184764.026059, type 4 (EV_MSC), code 4 (MSC_SCAN), value 40400b
Event: time 1490184764.026059, type 1 (EV_KEY), code 11 (KEY_0), value 1
Event: time 1490184764.026059, -------------- SYN_REPORT ------------
Event: time 1490184764.273206, type 1 (EV_KEY), code 11 (KEY_0), value 0
Event: time 1490184764.273206, -------------- SYN_REPORT ------------

Now we can work with keybinder
keybinder /dev/input/eventX
X depends on the event number of your IR receiver!!!
You got the number by evtest.

Feel free to apply my config or create your own.
cat <<EOF >/etc/keybinder.conf
24,mpc volume +10   # Set the volume +10
23,mpc volume -10   # Reduce the volume -10
16,mpc prev         # Play previous track
17,mpc next         # Play next track
13,mpc toggle       # Play/Pause playback
69,mpc random       # De-/Activate random playback
77,shutdown -h now  # Shutdown the Pine64

[Image: ir_remote_controlwkus1.png]

Start keybinder automatically on boot.
(crontab -l ; echo "@reboot /usr/bin/screen -dmS keybinder /usr/local/bin/keybinder /dev/input/eventX")| crontab -
X depends on the event number of your IR receiver!!!

» My own setup

[Image: img_20170312_101912a4uj7.jpg] [Image: img_20170311_1211430aubd.jpg]  [Image: img_20170311_164216hwux7.jpg] [Image: img_20170311_212653b3uyo.jpg] [Image: img_20170311_212802wauce.jpg]
[Image: img_20170311_192506etu6v.jpg] [Image: img_20170312_1337249cu2d.jpg]

Have fun with it Smile

Best regards

RE: Turn your Pine64 into a music server with mpd - Luke - 03-22-2017

Great post Julian!

RE: Turn your Pine64 into a music server with mpd - tllim - 03-23-2017

Thanks on the good post.