MusicLounge: Add LIRC Service (Odroid IR Remote Ctrl)


# ###############################################################################
# if Triggerhappy RC service has been previously installed
it may not be necessary to install Lirc

# ###############################################################################

# STEP 16bis

# OPTIONAL: Remote Control Management with LIRC

# the previous tutorial on remote management by the very easy to use TriggerHappy did not make you happy? so you want a deep control of your RC? read the following…

# Using the integrated IR sensor of the Odroid board to drive your music library with a remote control is possible
# We are going to install a remote control management using LIRC (Linux Infrared Remote Control )

# for the example we use a very common Remote Control using the standard MCE (Media Center Remote Control) format
# reference Remote Control is XPC-RC01

# do not plug the USB IR sensor included with the remote control, in this example we do not need it as we use the IR sensor integrated on Odroid board
# more info on LIRC is available here: https://lirc.org/

# a snapshot of lirc remotes is available for download here:
# download it, extract it and browse remote images to find the closest one
https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/

# install LIRC

# Armbian for Odroid boards includes a wizard for LIRC installation,
# launch armbian-config and select Network > Install IR

  1. $ sudo armbian-config

# to install it manually

  1. $ sudo apt-get install lirc

# modify the driver

  1. $ sudo nano /etc/lirc/lirc_options.conf
[lircd]
nodaemon        = False
driver          = default
device          = /dev/lirc0
output          = /var/run/lirc/lircd
pidfile         = /var/run/lirc/lircd.pid
plugindir       = /usr/lib/aarch64-linux-gnu/lirc/plugins
permission      = 666
allow-simulate  = No
repeat-max      = 600

[lircmd]
uinput          = False
nodaemon        = False

[modinit]
code = /sbin/modprobe meson-ir

[lircd-uinput]
# add-release-events = True
# release-timeout    = 50
# release-suffix     = _EVUP

# modify the default remote control configuration file
# this one is based on Remote Control ShuttleX conf (PN31) available here
# http://lirc.sourceforge.net/remotes/shuttle/PN31
# Remote Control DB is available here:
# https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/

# create the remote config file

  1. $ sudo nano /etc/lirc/lircd.conf.d/myremote.lircd.conf
# copy the configuration
#
# this config file was automatically generated
# using WinLIRC 0.6.5 (LIRC 0.6.1pre3) on Mon Aug 25 22:24:07 2003
#
# contributed by lirc @ trollmaster.net
#
# brand:        made in china
# model:        XPC-RC01 based on PN31 from ShuttleX
# supported devices: 
#

begin remote

  name  CNRemote
  bits            9
  flags SPACE_ENC
  eps            40
  aeps          100

  header       3021  1469
  one           310   266
  zero          310   780
  ptrail        310
  post_data_bits  8
  post_data      0xFC
  gap          12038
  toggle_bit      0


      begin codes
          KEY_POWER                0x000000000000017B
          KEY_TV                   0x00000000000001BB
          print                    0x000000000000013B
          KEY_EXIT                 0x00000000000001DB
          KEY_AUDIO                0x000000000000015B
          KEY_IMAGES               0x000000000000019B
          KEY_VIDEO                0x000000000000011B
          KEY_MENU                 0x00000000000001EB
          KEY_BACK                 0x000000000000014B
          KEY_R                    0x000000000000018B
          KEY_OK                   0x0000000000000177
          KEY_PREVIOUS             0x000000000000016B
          KEY_PLAYPAUSE            0x00000000000001AB
          KEY_NEXT                 0x000000000000012B
          KEY_REWIND               0x0000000000000167
          KEY_STOP                 0x00000000000001B7
          KEY_FASTFORWARD          0x000000000000016F
          KEY_VOLUMEUP             0x00000000000001A7
          KEY_VOLUMEDOWN           0x0000000000000127
          KEY_INFO                 0x0000000000000137
          KEY_CHANNELUP            0x00000000000001AF
          KEY_CHANNELDOWN          0x000000000000012F
          KEY_MUTE                 0x00000000000001C7
          KEY_RECORD               0x00000000000001D7
          KEY_BACKSPACE            0x00000000000001CF
          KEY_1                    0x0000000000000147
          KEY_2                    0x0000000000000157
          KEY_3                    0x000000000000014F
          KEY_4                    0x0000000000000187
          KEY_5                    0x0000000000000197
          KEY_6                    0x000000000000018F
          KEY_7                    0x0000000000000107
          KEY_8                    0x0000000000000117
          KEY_9                    0x000000000000010F
          KEY_DOT                  0x00000000000001FB
          KEY_0                    0x00000000000001E7
          KEY_L                    0x00000000000001F7
          KEY_UP                   0x00000000000001B3
          KEY_DOWN                 0x000000000000011F
          KEY_LEFT                 0x00000000000001EF
          KEY_RIGHT                0x00000000000001BF
      end codes

end remote

# CTRL+O to save
# CTRL+X to exit

# change the default remote control buttons configuration to drive MPD with irexec a special daemon included with LIRC

  1. $ sudo nano /etc/lirc/irexec.lircrc
begin
 prog = irexec
 button = KEY_PLAY
 config = mpc play >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_STOP
 config = mpc stop >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_PAUSE
 config = mpc pause >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_PLAYPAUSE
 config = mpc toggle >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_NEXT
 config = mpc next >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_PREVIOUS
 config = mpc prev >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_FASTFORWARD
 config = mpc seek +10 >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_FORWARD
 config = mpc seek +10 >/dev/null
 flags = quit
end


begin
 prog = irexec
 button = KEY_REWIND
 config = mpc seek -10 >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_3
 config = /home/pi/scripts/./playlist3.sh >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_1
 config = /home/pi/scripts/./playlist1.sh >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_2
 config = /home/pi/scripts/./playlist2.sh >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_6
 config = /home/pi/scripts/./lowbass.sh >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_9
 config = /home/pi/scripts/./jbleq.sh >/dev/null
 flags = quit
end

begin
 prog = irexec
 button = KEY_0
 config = mpc enable only 1 && mpc play >/dev/null
 flags = quit
end

# CTRL+O to save
# CTRL+X to exit

# create a symbolic link to match any version of irexec

  1. $ sudo ln -s /etc/lirc/irexec.lircrc /etc/lirc/lircrc

# we can already enable LIRC service and run irexec manually to catch remote control button and drive MPD
# but it’s better to modify the irexec service to start it at boot

  1. $ sudo nano /lib/systemd/system/irexec.service
[Unit]
Documentation=man:irexec(1)
Documentation=http://lirc.org/html/configure.html
Documentation=http://lirc.org/html/configure.html#lircrc_format
Description=Handle events from IR remotes decoded by lircd(8)
After=network.target
Wants=lircd.service

[Service]
Type=simple
ExecStart=/usr/bin/irexec /etc/lirc/irexec.lircrc
Restart=on-failure
SuccessExitStatus=3 4
RestartForceExitStatus=3 4

[Install]
WantedBy=multi-user.target

# CTRL+O to save
# CTRL+X to exit

# activate LIRC and IREXEC service

  1. $ sudo systemctl daemon-reload
  1. $ sudo systemctl start lircd
  2. $ sudo systemctl enable lircd
  1. $ sudo systemctl enable irexec
  2. $ sudo systemctl status irexec

# be sure to stop lircd uinput service to not inject key events to kernel

  1. $ sudo systemctl stop lircd-uinput.service
  2. $ sudo systemctl disable lircd-uinput.service
  3.  
  4. $ sudo systemctl status lircd-uinput.service

# reboot and chek the status

  1. $ sudo reboot
  2.  
  3. $ sudo systemctl status lircd

# both services are now activated, enabled and running at startup

# if your remote control do not send the correct key use the dump function to
# identify the correct key and change your cmds in /etc/lirc/irexec.lircrc (see above)

# To dump all events received through your remote control (useful to get the corresponding keys):

  1. $ irw

# CTRL+C to exit

# Run your MPD Client (MALP Android for example) play an album
# use your remote control to stop, play, go next, prev,…

# Congrats! Your MCE Remote controls the Music Player Daemon!

Click the button NEXT below to continue…

MusicLounge: Add IR Remote Control


# STEP16

# OPTIONAL: Add A Remote Control Management
# this tutorial and the next one is about controlling the audio server with a remote control to play, pause, stop, go next / prev song, launch playlist, drive equalizer,…
# this one use a very easy to use tool named Triggerhappy and the other use Lirc a more complete implementation supporting hundreds remote controls

# Add a remote control management

# install triggerhappy (should be already installed)

  1. $ sudo apt-get install triggerhappy

# create a configuration file
# pressing ZERO button select the default (first) audio output

  1. $ sudo nano /etc/triggerhappy/triggers.d/triggers.conf


# add your key to play, stop,… copy/paste the lines below:
# in addition to the standard play, stop, pause,… commands,
# this remote control config will
# start playing playlist 1 to 3 random order by pressing the corresponding key 1, 2 or 3
# select 2 EQ setup by pressing key 6 or 9
# select the default audio output (NO EQ) by pressing 0 (zero)
#

KEY_PLAY 0 mpc play >/dev/null
KEY_STOP 0 mpc stop >/dev/null
KEY_PAUSE 0 mpc toggle >/dev/null
KEY_PLAYPAUSE 0 mpc toggle >/dev/null 
KEY_NEXT 0 mpc next >/dev/null
KEY_PREVIOUS 0 mpc prev >/dev/null
KEY_FASTFORWARD 0 mpc seek +10 >/dev/null
KEY_REWIND 0 mpc seek -10 >/dev/null
KEY_RECORD 0 /home/pi/scripts/./playlist.sh >/dev/null

KEY_LEFTCTRL+KEY_P 0 mpc play >/dev/null
KEY_LEFTCTRL+KEY_S 0 mpc stop >/dev/null
BTN_MIDDLE 0 mpc toggle >/dev/null
BTN_LEFT 0 mpc prev >/dev/null
KEY_LEFTCTRL+KEY_B 0 mpc prev >/dev/null
KEY_LEFTCTRL+KEY_F 0 mpc next >/dev/null
KEY_HOME 0 mpc toggle >/dev/null
KEY_LEFTSHIFT+KEY_B 0 mpc seek -10 >/dev/null
KEY_LEFTSHIFT+KEY_F 0 mpc seek +10 >/dev/null

KEY_NUMERIC_1 0 /home/pi/scripts/./playlist1.sh >/dev/null 
KEY_NUMERIC_2 0 /home/pi/scripts/./playlist2.sh >/dev/null
KEY_NUMERIC_3 0 /home/pi/scripts/./playlist3.sh >/dev/null

KEY_NUMERIC_6 0 /home/pi/scripts/./lowbass.sh >/dev/null
KEY_NUMERIC_9 0 /home/pi/scripts/./jbleq.sh >/dev/null
KEY_NUMERIC_0 0 mpc enable only 1 && mpc play >/dev/null
KEY_0 0 mpc enable only 1 && mpc play >/dev/null

KEY_1 0 /home/pi/scripts/./playlist1.sh >/dev/null 
KEY_2 0 /home/pi/scripts/./playlist2.sh >/dev/null 
KEY_3 0 /home/pi/scripts/./playlist3.sh >/dev/null 

KEY_6 0 /home/pi/scripts/./lowbass.sh >/dev/null
KEY_9 0 /home/pi/scripts/./jbleq.sh >/dev/null

# CTRL+O to save
# CTRL+X to exit

# activate triggerhappy

  1. $ sudo systemctl enable triggerhappy


  1. $ sudo systemctl start triggerhappy


  1. $ sudo systemctl status triggerhappy


# DEBUG THE KEY CODES
# useful if your remote control is not working, skip this during install
# if your remote control do not send the correct key use the dump function to identify the correct key and change your cmds in triggers.conf
# To dump all events received through your remote control (useful to get the corresponding keys):

  1. $ sudo thd --dump /dev/input/event*
EV_KEY KEY_5 1 /dev/input/event4
# KEY_5 1 command
EV_KEY KEY_5 0 /dev/input/event4
# KEY_5 0 command
EV_KEY KEY_5 1 /dev/input/event4
# KEY_5 1 command
EV_KEY KEY_5 0 /dev/input/event4
# KEY_5 0 command
EV_KEY KEY_5 1 /dev/input/event4
# KEY_5 1 command
EV_KEY KEY_5 0 /dev/input/event4
# KEY_5 0 command


# CTRL+C to exit


# OPTIONAL
# if you need to run script as root from triggerhappy (default user is nobody) do the following:
# giving root access is risky but if know what you’re doing this can be useful to run script to set parametric EQ or load playlist with the remote
# useful to drive ALSAEQ (equalizer plugin) for example

  1. $ sudo nano /lib/systemd/system/triggerhappy.service

change
–user nobody
to
–user root

# CTRL+O to save
# CTRL+X to exit

  1. $ sudo nano /etc/default/triggerhappy



# comment

#DAEMON_OPTS=""

# uncomment

DAEMON_OPTS="--user root"

# CTRL+O to save
# CTRL+X to exit

  1. $ sudo systemctl daemon-reload


  1. $ sudo systemctl restart triggerhappy


  1. $ sudo systemctl status triggerhappy

# add a playlist script
# if you followed our tutorials the playlist/ and scripts/ directory are already created

# from a remote PC, open the share point playlists and copy 2 playlists into it
# for example my_classical_albums.m3u and my_jazzy_albums.m3u

# create the script

  1. $ sudo nano ~/scripts/playlist1.sh
#!/bin/bash
#
# Script to load playlist
 
echo "start playlist"
mpc stop
mpc clear
mpc enable only 1
mpc load my_clasical_albums
mpc random "on"
mpc crossfade 0
mpc play

# CTRL+O to save
# CTRL+X to exit

# set exec permission

  1. $ sudo chmod +x ~/scripts/playlist1.sh

# create the script

  1. $ sudo nano ~/scripts/playlist2.sh
#!/bin/bash
#
# Script to load playlist
 
echo "start playlist"
mpc stop
mpc clear
mpc enable only 1
mpc load my_jazzy_albums
mpc random "on"
mpc crossfade 0
mpc play

# CTRL+O to save
# CTRL+X to exit

# set exec permission

  1. $ sudo chmod +x ~/scripts/playlist2.sh

# now pressing key 1 or 2 of the remote control plays the playlist classical or jazzy

# obviously for this to work you need to save your playlists in the playlists directory

 


# in our example of configuration above we have key 6 and 9 assigned to ALSA EQ,
# by pressing key 6 or 9 you are going to trigger the lowbass.sh or the jbjeq.sh which drive the ALSA Equalizer plugin to shape your sound
read the tutorial on how to add a real time EQ to your audio system to complete the installation of this 2 scripts

# more info: triggerhappy by Stefan Tomanek <stefan.tomanek+th@wertarbyte.de>
http://github.com/wertarbyte/triggerhappy/

Click the button NEXT below to continue…

MusicLounge: Alsa EQ Plugin


# ALSA EQ (alsaeq plugin)
# add a real-time adjustable equalizer plugin for ALSA sound server to your audiophile server

# install plugin

  1. $ sudo apt-get install libasound2-plugin-equal


# edit the .asoundrc (or create one if doesnt exist)

# mpd home

  1. $ sudo nano /var/lib/mpd/.asoundrc


pcm.!default {
type plug
slave.pcm plugequal;
}
ctl.!default {
type hw card 0
}
ctl.equal {
type equal;
}
pcm.plugequal {
type equal;
slave.pcm "plughw:1,0"; # NOTE this line MUST be your hardware device.
}
pcm.equal {
type plug;
slave.pcm plugequal;
}

# CTRL+O to save
# CTRL+X to exit

# reboot

  1. $ sudo reboot



# command for using the mixer through MPD user:

  1. $ sudo -H -u mpd alsamixer -D equal

# user this command to EQ your audio system (if needed) and then
# write down the values of the 10 bands to create the corresponding EQ script
# then edit your remote control configuration to assign a key (see below for sample scripts)


# Sample script to drive the ALSA EQ

# 66 == zero change

# script to change preset:

seteq(){
sudo -H -u mpd amixer -D equal -q set '00. 31 Hz' $1
sudo -H -u mpd amixer -D equal -q set '01. 63 Hz' $2
sudo -H -u mpd amixer -D equal -q set '02. 125 Hz' $3
sudo -H -u mpd amixer -D equal -q set '03. 250 Hz' $4
sudo -H -u mpd amixer -D equal -q set '04. 500 Hz' $5
sudo -H -u mpd amixer -D equal -q set '05. 1 kHz' $6
sudo -H -u mpd amixer -D equal -q set '06. 2 kHz' $7
sudo -H -u mpd amixer -D equal -q set '07. 4 kHz' $8
sudo -H -u mpd amixer -D equal -q set '08. 8 kHz' $9
sudo -H -u mpd amixer -D equal -q set '09. 16 kHz' ${10}
}

# usage:

  1. $ seteq 29 39 58 58 60 66 66 66 66 66

# see the IR remote control tutorials to trigger script by pressing a button of your remote control

# by default in the installation of triggerhappy or Lirc we assigned key 6 and 9 of the remote control to trigger ALSA EQ script lowbass.sh and jbleq.sh and key 0 (zero) to reset to dafault audio output (EQ is not used in the default)

# if you followed the installation the scripts/ directory is already created

# we are going to create a simple script to drive the ALSA EQ
# the script start to select the “ALSA EQ” audio output of MPD
# then it sets each band of the EQ

  1. $ sudo nano ~/scripts/lowbass.sh
#!/bin/bash
mpc enable only 'ALSA EQ'
sudo -u mpd /usr/bin/amixer -D equal -q set '00. 31 Hz' 39
sudo -u mpd /usr/bin/amixer -D equal -q set '01. 63 Hz' 39
sudo -u mpd /usr/bin/amixer -D equal -q set '02. 125 Hz' 58
sudo -u mpd /usr/bin/amixer -D equal -q set '03. 250 Hz' 58
sudo -u mpd /usr/bin/amixer -D equal -q set '04. 500 Hz' 60
sudo -u mpd /usr/bin/amixer -D equal -q set '05. 1 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '06. 2 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '07. 4 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '08. 8 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '09. 16 kHz' 66
mpc play

# set exec permission

  1. $ sudo chmod +x ~/scripts/lowbass.sh

# reshaping JBL speakers example

  1. $ sudo nano ~/scripts/jbleq.sh
#!/bin/bash
mpc enable only 'ALSA EQ'
sudo -u mpd /usr/bin/amixer -D equal -q set '00. 31 Hz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '01. 63 Hz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '02. 125 Hz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '03. 250 Hz' 60
sudo -u mpd /usr/bin/amixer -D equal -q set '04. 500 Hz' 60
sudo -u mpd /usr/bin/amixer -D equal -q set '05. 1 kHz' 62
sudo -u mpd /usr/bin/amixer -D equal -q set '06. 2 kHz' 66
sudo -u mpd /usr/bin/amixer -D equal -q set '07. 4 kHz' 70
sudo -u mpd /usr/bin/amixer -D equal -q set '08. 8 kHz' 71
sudo -u mpd /usr/bin/amixer -D equal -q set '09. 16 kHz' 66
mpc play

# set exec permission

  1. $ sudo chmod +x ~/scripts/jbleq.sh

# set owner of scripts directory to current user (pi)

  1. $ sudo chown $USER:$USER  ~/scripts/*

# Congrats! Now you can shape your sound with EQ plugin (obviously not suitable for native DSD playback)
# see the next tutorial to install remote control and select on-fly your EQ setup by pressing key 6 or 9 of the remote control,
# key 0 (zero) reset to default audio output (no EQ)

MusicLounge: Update MPD Database

 


# STEP14

 

# Congrats! MPD is installed and running!

# First Steps With Music Player Daemon

# it’s now time to update the tag db of MPD, we are using the client this time (mpc):
# type the following cmds to update the MPD database

  1. $ mpc update


# check the status to see if the update is done type:

  1. $ mpc status


# “Updating DB …” shouldn’t be in the status result (can take a while be patient, 1500 albums/19000 songs is about 10mn to be updated)

# loop with

  1. $ mpc status


# until the DB is updated

 


# STEP15

 

  1. $ mpc status


# play songs to check if everything is OKAY! 😉

# use your MPD music player like MALP for Android
# select the correct ALSA audio output
# and to browse your library and enjoy your music!

Click the button NEXT below to continue with optional features like:

# – add a WEB Client to browse/play music from firefox, chrome, safari, edge, …
# – add IR remote control management
# – add DLNA (upnp) server/renderer
# – add Spotify connect
# – add Airplay renderer
# – Roon server/bridge
# – ALSA EQ

Browse your music library with MALP for Android

MusicLounge: Samba Configuration


# STEP13

# share points (useful for browsing/updating server files from Windows or Mac ) add the lines below at the end of the smb configuration:
#
# also, add the home storage shared point
# if you want to get a full access to the sd card content from windows/mac
# (attention ‘root’ access here)
#

  1. $ sudo nano /etc/samba/smb.conf

# edit samba configuration by adding the settings bellow at end (playlists, music and storage access):

[playlists]
path = /var/lib/mpd/playlists
read only = no
public = yes
writable = yes
browesable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = mpd

[music]
path = /mnt/media
read only = no
public = yes
writable = yes
browesable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = mpd

[www]
path = /var/www/html
read only = no
public = yes
writable = yes
browesable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = www-data

[Downloads]
path = /home/pi/Downloads
read only = no
public = yes
writable = yes
browesable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = pi

[scripts]
path = /home/pi/scripts
read only = no
public = yes
writable = yes
browesable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = pi

[sdcard]
path = /home/pi
read only = no
public = yes
writable = yes
browesable = yes
guest ok = yes
create mask = 0777
directory mask = 0755
force user = root


# CTRL+O to save
# CTRL+X to exit

# restart samba:

  1. $ sudo /etc/init.d/smbd restart

# or

  1. $ sudo systemctl restart smb


# wait 5 sec and type the cmd below if shared points are NOT visible from your Windows network browser:

  1. $ sudo systemctl restart nmb


# the music contains the songs files and playlists directory is empty but visible using the Windows network browser on your PC

# reboot your device

  1. $ sudo reboot


# IMPORTANT: it’s recommended to remove the [sdcard] shared point from smb.conf as soon as your installation is working correctly.

Click the button NEXT below to continue…

MusicLounge: Activate MPD


# STEP11

# activate service

  1. $ sudo systemctl enable mpd


# restart MPD

  1. $ sudo systemctl start mpd


# if you have an error in your conf file and MPD didn't start type the following to get the error line:

  1. $ sudo systemctl status mpd


# loop step 10/11 to fix mpd.conf until MPD start correctly without error (see previous step)


# STEP12

# create playlists directory if not exists

  1. $ ls -l /var/lib/mpd/
pi@musiclounge:~$ ls -l /var/lib/mpd/
total 28
drwxr-xr-x 2 root root   4096 Feb 25  2019 music
drwxr-xr-x 2 mpd  audio  4096 Feb 25  2019 playlists
-rw-r--r-- 1 mpd  audio   189 Jun 18 04:37 state
-rw-r--r-- 1 mpd  audio 12288 Jun 18 04:29 sticker.sql
-rw-r--r-- 1 mpd  audio   241 Jun 18 04:41 tag_cache

# SKIP THIS STEP if playlists directory exists (should be already created by MPD installation)

# if the directory does not exist, create it

  1. $ sudo mkdir /var/lib/mpd/playlists


# change user:group if not mpd:audio

  1. $ sudo chown mpd:audio /var/lib/mpd/playlists



# set permission if not already 755

  1. $ sudo chmod 755 /var/lib/mpd/playlists


Click the button NEXT below to continue...

MusicLounge: Configure MPD


# STEP10

# YOUR USB DAC MUST BE CONNECTED TO THE USB PORT AND READY

# edit the configuration of MPD with a DAC USB connected but before:

# identify your USB DAC ID (usually card 1):

  1. $ aplay -l

# in case of *No Soundcard Error*, read our tutorial to install ALSA correctly and prepare your Linux distribution

# to list of playback hardware devices (card 0, card 1, car 2….) and to get the index of your USB DAC

# report this index number in the line device “hw:x,0” of all audio output in mpd.conf see below

# the USB DAC should be indexed 1 or 2

# BEWARE if you disable the RASPBERRY PI HDMI port later (see the corresponding howto) the ID of your DAC will certainly change which require to modify mpd.conf audio output as well


# backup default MPD config mpd.conf into our Downloads/ directory

  1. $ sudo cp /etc/mpd.conf ~/Downloads/mpd.conf

# erase the current config and replace with the settings below

  1. $ sudo truncate -s 0 /etc/mpd.conf
  1. $ sudo nano /etc/mpd.conf

# replace with the settings below

# nano shortcut: CTRL + K to cut an entire line
# this settings use USB DAC on card 1 (hw:1,0), change the index accordingly if needed

# copy the lines below and right-click on nano editor to paste
#

music_directory "/mnt/media"
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"
group "audio"
bind_to_address "any"
port "6600"
log_level "default"
restore_paused "yes"
#save_absolute_paths_in_playlists "no"
#metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc"
#metadata_to_use "+comment"
auto_update "no"
#auto_update_depth "3"
follow_outside_symlinks "yes"
follow_inside_symlinks "yes"
zeroconf_enabled "no"
zeroconf_name "Music DAC"
connection_timeout "120"
#password "password@read,add,control,admin"
#default_permissions "read,add,control,admin"
#
###############################################################################

# Database #######################################################################
#

#database {
# plugin "proxy"
# host "other.mpd.host"
# port "6600"
#}

# Input #######################################################################
#

input {
plugin "curl"
# proxy "proxy.isp.com:8080"
# proxy_user "user"
# proxy_password "password"
}

# QOBUZ input plugin
input {
enabled "no"
plugin "qobuz"
# app_id "ID"
# app_secret "SECRET"
# username "USERNAME"
# password "PASSWORD"
# format_id "N"
}

# TIDAL input plugin
input {
enabled "no"
plugin "tidal"
# token "TOKEN"
# username "USERNAME"
# password "PASSWORD"
# audioquality "Q"
}

# Decoder #####################################################################
#

decoder {
plugin "ffmpeg"
enabled "yes"
# gapless "no"
}

replaygain "off"
replaygain_preamp "0"
#replaygain_missing_preamp "0"
#replaygain_limit "yes"
volume_normalization "no"
filesystem_charset "UTF-8"

###############################################################################

audio_output {
type "alsa"
name "Default"
device "hw:1,0"
mixer_type "none"
dop "no"
}

audio_output {
type "alsa"
name "ALSA DAC DOP"
device "hw:1,0"
mixer_type "none"
dop "yes"
}

audio_output {
type "alsa"
name "ALSA DAC NoDOP"
device "hw:1,0"
mixer_type "none"
dop "no"
}

audio_buffer_size "4096"
#buffer_before_play "10%"
max_output_buffer_size "131072"
max_connections "128"

audio_output {
type "alsa"
name "ALSA EQ"
device "plug:plugequal"
# format "44100:16:2" # optional
# mixer_device "default" # optional
# mixer_control "PCM" # optional
# mixer_index "0" # optional
}



# CTRL+O to save
# CTRL+X to exit

# disable MPD user service as you run it on headless server:

  1. $ sudo rm /etc/xdg/autostart/mpd.desktop
  2. $ sudo systemctl --global disable mpd.service
  3. $ sudo systemctl --global disable mpd.socket

# MPD is now configured.
#

 


Control The Volume Good or Bad? - Read More...

# keep a Bit Perfect audio with a control of the volume, possible?
# yes, this is possible but only if this is supported by your USB DAC

# check if hardware volume is supported
# get the card number of your USB DAC
# (should be 1 if you only have 1 DAC connected)

  1. $ aplay -l
pi@musiclounge:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: S9Pro [Hidizs S9Pro], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: MQA [D90 MQA], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: SM1ODROIDC4 [SM1-ODROID-C4], device 0: fe.dai-link-0 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: SM1ODROIDC4 [SM1-ODROID-C4], device 1: fe.dai-link-1 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: SM1ODROIDC4 [SM1-ODROID-C4], device 2: fe.dai-link-2 (*) []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

# in this example we have 2 DAC connected
# list mixer contents of the device 1

  1. $ amixer --card 1 scontents
 
pi@musiclounge:~$ amixer --card 1
pi@musiclounge:~$

# nothing for the topping D90

# now for the S9 Pro

  1. $ amixer --card 0 scontents
pi@musiclounge:~$ amixer --card 0
Simple mixer control 'PCM',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 127
  Mono:
  Front Left: Playback 127 [100%] [0.00dB] [on]
  Front Right: Playback 127 [100%] [0.00dB] [on]
Simple mixer control 'PCM',1
  Capabilities: pvolume pvolume-joined
  Playback channels: Mono
  Limits: Playback 0 - 127
  Mono: Playback 87 [69%] [-20.00dB]

# great! the hardware volume is supported on this DAC
# now we change the mpd.conf to add this dac with hardware volume control

  1. $ sudo nano /etc/mpd.conf

# add this at the end of your configuration
# hw:0 must changed to corresponding card number of your DAC

audio_output {
type "alsa"
name "Hidizs S9 Pro Mixer ON"
device "hw:0,0"
mixer_type "hardware"
mixer_control "PCM"
mixer_index "0"
dop "no"
}

# CTRL+O to save
# CTRL+X to exit

# that’s it!

# Our recommendation is to avoid using volume control in MPD configuration if
# a physical or integrated volume control is already included with your DAC


 


 
Click the button NEXT below to continue…