[Guide] C1+/C2 + MPD, YMPD, HiFi Shield | 192khz/24bit soxr

Post Reply
Fourdee
Posts: 298
Joined: Fri Apr 03, 2015 5:01 am
languages_spoken: english
ODROIDs: C1 / C2 / XU4 + Cloudshell.
Has thanked: 0
Been thanked: 1 time
Contact:

[Guide] C1+/C2 + MPD, YMPD, HiFi Shield | 192khz/24bit soxr

Post by Fourdee »

ympd_guide.png
(85.74 KiB) Downloaded 2210 times
Turn your Odroid C1+/C2 and HiFi shield into a lightweight HiFi monster.

Required:
- Odroid C1+/C2
- HiFi Shield
- Debian Jessie installation (Meveric's Jessie images, or DietPi)
- Logged in as Root (or sudo su)

Alternative installation: Complete this guide automatically with DietPi
You only need to:
- Download DietPi image: http://dietpi.com/download
- Select and install HiFi in dietpi-software
- Select your soundcard in dietpi-config > audio options

This guide will setup and install the following software/hardware:
- MPD: 192khz/24bit output and upsampling via soxr.
- YMPD (web interface for MPD)
- HiFi Shield Plus

Setup Alsa:
Packages:

Code: Select all

apt-get install -y alsa-base alsa-utils
Asound.conf for HiFi shield:

Code: Select all

cat << _EOF_ > /etc/asound.conf
pcm.!default {
   type hw
   card 1
}

ctl.!default {
   type hw
   card 1
}
_EOF_
Setup HiFi Shield modules

Code: Select all

echo -e "snd-soc-pcm5102" >> /etc/modules
echo -e "snd-soc-odroid-dac" >> /etc/modules

modprobe snd-soc-pcm5102
modprobe snd-soc-odroid-dac
Compile and install MPD:
Install Prereqs:

Code: Select all

cd "$HOME"

#Prereqs
apt-get install -y build-essential g++ \
  libmad0-dev libmpg123-dev libid3tag0-dev \
  libflac-dev libvorbis-dev libopus-dev \
  libaudiofile-dev libsndfile1-dev libfaad-dev \
  libfluidsynth-dev libgme-dev libmikmod2-dev libmodplug-dev \
  libmpcdec-dev libwavpack-dev libwildmidi-dev \
  libsidplay2-dev libsidutils-dev libresid-builder-dev \
  libavcodec-dev libavformat-dev \
  libmp3lame-dev \
  libsamplerate0-dev libsoxr-dev \
  libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev \
  libzzip-dev \
  libcurl4-gnutls-dev libyajl-dev libexpat-dev \
  libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev \
  libpulse-dev libroar-dev libshout3-dev \
  libmpdclient-dev \
  libnfs-dev libsmbclient-dev \
  libupnp-dev \
  libavahi-client-dev \
  libsqlite3-dev \
  libsystemd-daemon-dev libwrap0-dev \
  libcppunit-dev xmlto \
  libboost-dev \
  libicu-dev
Download MPD sourcecode:

Code: Select all

wget https://www.musicpd.org/download/mpd/0.19/mpd-0.19.16.tar.xz -O package.tar
tar -xf package.tar
rm package.tar
Compile and Install:

Code: Select all

cd mpd-*
./configure
make -j $(nproc --all)
make install
Install MPD default config:

Code: Select all

cat << _EOF_ > /etc/default/mpd
#Even though we declare the conf location in our service, MPD will fail to start if this file does not exist.

## The configuration file location for mpd:
MPDCONF=/etc/mpd.conf
_EOF_
Install MPD systemD service:

Code: Select all

cat << _EOF_ > /lib/systemd/system/mpd.service
[Unit]
Description=Music Player Daemon
After=network.target sound.target

[Service]
User=root
EnvironmentFile=/etc/default/mpd
ExecStartPre=/bin/mkdir -p /var/lib/mpd
ExecStartPre=/bin/mkdir -p /var/log/mpd
ExecStartPre=/bin/mkdir -p /var/run/mpd
ExecStartPre=/bin/mkdir -p /var/lib/mpd
ExecStart=/usr/local/bin/mpd --no-daemon /etc/mpd.conf

# allow MPD to use real-time priority 50
LimitRTPRIO=50
LimitRTTIME=-1

[Install]
WantedBy=multi-user.target

_EOF_

systemctl daemon-reload
systemctl enable mpd
Install MPD.conf for HiFi Shield:

Code: Select all

cat << _EOF_ > /etc/mpd.conf
#/etc/mpd.conf

music_directory                        "/mnt/dietpi_userdata/Music"
playlist_directory                     "/mnt/dietpi_userdata/Music"
db_file                                "/mnt/dietpi_userdata/.mpd_cache/db_file"
log_file                               "/var/log/mpd/mpd.log"
pid_file                               "/var/run/mpd/pid"
state_file                             "/var/lib/mpd/state"
sticker_file                           "/var/lib/mpd/sticker.sql"

user                                   "root"
#group                                 "nogroup"
bind_to_address                        "localhost"

log_level                              "secure"
#gapless_mp3_playback                  "yes"
#save_absolute_paths_in_playlists      "no"
metadata_to_use                        "artist,album,title,track,name,genre,date"
auto_update                            "yes"
#auto_update_depth                     "3"

#follow_outside_symlinks               "yes"
#follow_inside_symlinks                "yes"

#zeroconf_enabled                      "yes"
#zeroconf_name                         "Music Player"

#password                              "password@read,add,control,admin"
#default_permissions                   "read,add,control,admin"

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

replaygain                            "track"
replaygain_preamp                     "8"
volume_normalization                  "yes"

#audio_buffer_size                    "2048"
#buffer_before_play                   "10%"

connection_timeout                    "30"
max_connections                       "4"
#max_playlist_length                  "16384"
#max_command_list_size                "2048"
#max_output_buffer_size               "8192"

filesystem_charset                    "UTF-8"
id3v1_encoding                        "UTF-8"
audio_output {
    type                              "alsa"
    name                              "My ALSA Device"
#    device                           "hw:1,0"
    format                            "192000:24:2"
    mixer_type                        "software"
#    mixer_control                    "PCM"
#    mixer_index                      "0"
}

audio_output_format                   "192000:24:2"
samplerate_converter                  "soxr very high"

_EOF_

Create data directories
Put your music into /mnt/dietpi_userdata/Music

Code: Select all

mkdir -p /mnt/dietpi_userdata/Music
mkdir -p /mnt/dietpi_userdata/.mpd_cache
Grab some test music:

Code: Select all

wget http://dietpi.com/downloads/audio/fourdee_tech.ogg -O /mnt/dietpi_userdata/Music/fourdee_tech.ogg
wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=vrbb -O /mnt/dietpi_userdata/Music/Absolute-Radio.pls
wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a8bb -O /mnt/dietpi_userdata/Music/Absolute-Radio-80s.pls
wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a9bb -O /mnt/dietpi_userdata/Music/Absolute-Radio-90s.pls
wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a0bb -O /mnt/dietpi_userdata/Music/Absolute-Radio-00s.pls
Install YMPD:
Install package (Odroid C2 arm64):

Code: Select all

wget http://dietpi.com/downloads/binaries/all/ympd-1.2.3-arm64.tar.bz2 -O package.tar
tar -xvf package.tar
rm package.tar
mv ympd /usr/bin/ympd
Install package (Odroid C1)

Code: Select all

wget http://www.ympd.org/downloads/ympd-1.2.3-armhf.tar.bz2 -O package.tar
tar -xvf package.tar
rm package.tar
mv ympd /usr/bin/ympd
Install service:

Code: Select all

cat << _EOF_ > /etc/init.d/ympd
#!/bin/sh
### BEGIN INIT INFO
# Provides:          ympd
# Required-Start:    \$local_fs \$mpd
# Required-Stop:     \$local_fs \$mpd
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Daemonized version of ympd.
# Description:       Enable service provided by ympd.
### END INIT INFO
#Author: Andrew Karpow <andy@ndyk.de>

. /lib/lsb/init-functions

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="ympd Daemon"
NAME=ympd
DAEMON=/usr/bin/\$NAME
PIDFILE=/var/run/\$NAME.pid
SCRIPTNAME=/etc/init.d/\$NAME
LOG_OUT=/var/log/\$NAME.out
LOG_ERR=/var/log/\$NAME.err
YMPD_USER=root
DAEMON_OPT="--user \$YMPD_USER --webport 1337"

# Exit if the package is not installed
[ -x "\$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/\$NAME ] && . /etc/default/\$NAME

# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS

do_start()
{
    start-stop-daemon --start --background --quiet --pidfile \$PIDFILE --make-pidfile \
        --exec \$DAEMON --test > /dev/null || return 1
    start-stop-daemon --start --background --quiet --pidfile \$PIDFILE --make-pidfile \
        --exec \$DAEMON -- \$DAEMON_OPT || return 2
}

do_stop()
{
    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile \$PIDFILE --name \$NAME
    RETVAL="\$?"

    [ "\$RETVAL" = 2 ] && return 2
    rm -f \$PIDFILE
    return "\$RETVAL"
}

case "\$1" in
  start)
    [ "\$VERBOSE" != no ] && log_daemon_msg "Starting \$DESC" "\$NAME"
    do_start
    case "\$?" in
        0|1) [ "\$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "\$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  stop)
    [ "\$VERBOSE" != no ] && log_daemon_msg "Stopping \$DESC" "\$NAME"
    do_stop
    case "\$?" in
        0|1) [ "\$VERBOSE" != no ] && log_end_msg 0 ;;
        2) [ "\$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
  status)
    status_of_proc "\$DAEMON" "\$NAME" && exit 0 || exit \$?
    ;;
  restart|force-reload)
    #
    # If the "reload" option is implemented then remove the
    # 'force-reload' alias
    #
    log_daemon_msg "Restarting \$DESC" "\$NAME"
    do_stop
    case "\$?" in
      0|1)
        do_start
        case "\$?" in
            0) log_end_msg 0 ;;
            1) log_end_msg 1 ;; # Old process is still running
            *) log_end_msg 1 ;; # Failed to start
        esac
        ;;
      *)
        # Failed to stop
        log_end_msg 1
        ;;
    esac
    ;;
  *)
    echo "Usage: \$SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
    exit 3
    ;;
esac

_EOF_

chmod +x /etc/init.d/ympd
update-rc.d ympd defaults 80 00
Reboot system:

Code: Select all

reboot
Connect to YMPD web interface:
Replace the IP address with the IP address of your system:
http://192.168.0.100:1337

Update music database:
Once you have copied your music to /mnt/dietpi_userdata/Music, and, are connected to the YMPD web interface:
- Select Settings
- Click Update DB

Thats it!
Go wake the neighbors up ;)
Last edited by Fourdee on Tue Nov 15, 2016 8:40 pm, edited 1 time in total.
http://DietPi.com - Lightweight justice for your Odroid.
DietPi web hosting is powered by http://MyVirtualServer.com

best_odroidfreak
Posts: 366
Joined: Wed May 04, 2016 1:07 am
languages_spoken: english
Has thanked: 1 time
Been thanked: 0
Contact:

Re: [Guide] C1+/C2 + MPD, YMPD, HiFi Shield | 192khz/24bit s

Post by best_odroidfreak »

Fourdee wrote:[attachment=0]MPD
Go wake the neighbors up ;)

This is the file list of ready package mpd (0.19.19-1) in sid of architecture arm64 see link: https://packages.debian.org/sid/arm64/mpd/filelist
How it set up to use an Gmpc client?

Post Reply

Return to “Ubuntu (All Linux'es)”

Who is online

Users browsing this forum: Google [Bot] and 3 guests