Setting up mpd / ncmpcpp

I was hopeing to set up mpd / ncmpcpp. I was looking for guidance. I have never setup mpd before, nor ncmpcpp.

Thanks ahead of time…

I have a script that does easy setup for pulse audio and handles pretty much all the config of mpd

#!/usr/bin/env bash

clear
username=$(whoami)
interface=$(ip route show | cut -d ' ' -f 3 | head -1)
# interface=$(ip route show | awk '{print $NF}' | tail -1)
echo "What is the full path of the directory containing your music?"
read -rpe "> " music_dir

if test -n "$(pgrep pulseaudio)"; then
    AUDIO='
    audio_output {
    type              "pulse"
    name              "Pulseaudio"
    }
'
else
    echo "No PulseAudio seems to be used, using autodetection instead"
    AUDIO=""
fi

cat <<EOF


Ready to write config file.
This will delete and re-create directory "$HOME/.mpd"

EOF

read -rp "Continue? (y/n) " yn

DO_CONFIG=
case $yn in
    [Yy]*) DO_CONFIG=yes ;;
    [Nn]*) exit;;
    *) echo "Please answer yes or no."; exit;;
esac

if test x$DO_CONFIG = xyes; then
    rm -fr "$HOME/.mpd"
    mkdir -p "$HOME/.mpd/playlists"
    touch "$HOME/.mpd/log"
    cat > "$HOME/.mpd/mpd.conf" <<EOF
music_directory                  "$music_dir"
db_file                          "$HOME/.mpd/database"
log_file                         "$HOME/.mpd/log"
pid_file                         "$HOME/.mpd/pid"
state_file                       "$HOME/.mpd/state"
playlist_directory               "$HOME/.mpd/playlists"
log_level                        "default"
#password                        "password@read,add,control,admin"
#default_permissions             "read,add,control,admin"
#user                            "$username"
#bind_to_address                 "$interface"
bind_to_address                  "127.0.0.1"
bind_to_address                  "$HOME/.mpd/socket"
port                             "6600"
gapless_mp3_playback             "yes"
auto_update                      "yes"
#auto_update_depth               "3"

input {
        plugin                   "curl"
        proxy                    "proxy.isp.com:8000"
        proxy_user               "user"
        proxy_password           "password"
    }
$AUDIO
#audio_output {
#               type             "alsa"
#               name             "Alsa output"
#               device           "hw:0,0"
#               format           "44100:16:2"
#               mixer_type       "hardware"
#               mixer_device     "default"
#               mixer_control    "PCM"
#               mixer_index      "0"
#}
#audio_output {
#               type             "httpd"
#               name             "Internet Stream"
#               encoder          "lame"
#               port             "8000"
#               bind_to_address  "192.168.1.13"
#               quality          "5.0"
#               bitrate          "128"
#               format           "44100:16:1"
#               max_clients      "3"
#}

#audio_output {
#               type             "recorder"
#               name             "My recorder"
#               encoder          "vorbis"
#               path             "/home/carnager/stream.ogg"
#               quality          "7.0" # do not define if bitrate is defined
#               bitrate          "128" # do not define if quality is defined
#               format           "44100:16:1"
#}

replaygain                       "album"
replaygain_preamp                "0"
#volume_normalization            "no"
#audio_buffer_size               "2048"
#buffer_before_play              "10%"
#connection_timeout              "60"
#max_connections                 "10"
#max_playlist_length             "16384"
#max_command_list_size           "2048"
#max_output_buffer_size          "8192"
#filesystem_charset              "UTF-8"
#id3v1_encoding                  "ISO-8859-1"
EOF
clear
cat <<EOF

EOF
echo "Trying to create systemd custom settings"
echo "Root previlegs needed..."
export username="$(whoami)"; su -c "mkdir /etc/systemd/system/mpd.service.d && echo -e \"[Service]\nUser=$username\nPAMName=system-local-login\" > /etc/systemd/system/mpd.service.d/mpd.conf"
echo "Setup complete"
echo " "
echo "If you want mpd to start at boot, run:"
echo ""systemctl enable mpd""
echo " "
echo "Otherwise simply run mpd as user now."

else
    echo "No config written, aborting"
    exit
fi

Ncmpcpp is just a matter of tweaking a config, if you want something just to get going here

## ncmpcpp.
ncmpcpp_directory = ~/.ncmpcpp

##### connection settings #####
mpd_host = localhost
mpd_port = 6600
mpd_connection_timeout = 5

## Needed for tag editor and file operations to work.

mpd_music_dir = /home/YOUR_USERNAME/Music/

mpd_crossfade_time = 5

# Display ..
song_list_format = "{ $8%a $1>> $2}{%t}$8"
song_status_format = "$8%a $5>> $2%t $5>> $2%b$8 (%y)$1"
playlist_display_mode = "classic" (classic/columns)

# Now Playing ..
now_playing_prefix = "$b"
now_playing_suffix = "$/b"

# Playlist ..
browser_playlist_prefix = "$2 ♥ $0 "

#
playlist_disable_highlight_delay = "1"
message_delay_time= "1"

# Progress Bar ..
progressbar_look = "─➤─"
progressbar_color = "red"
progressbar_elapsed_color = "blue"

# Colors ..
colors_enabled = "yes"
empty_tag_color = "red"
statusbar_color = "white"
state_line_color = "white"
state_flags_color = "green"
main_window_color = "black"
header_window_color = "white"
current_item_suffix = "$/r$(end)"
current_item_prefix = "$(blue)$r"

# Misc ..
display_bitrate = "yes"
autocenter_mode = "yes"
centered_cursor = "yes"
titles_visibility = "no"
statusbar_visibility = "yes"
empty_tag_marker=" -- ‼ -- "
mouse_support = "yes"
header_visibility = "yes"
display_remaining_time = "no"
ask_before_clearing_playlists = "no"
discard_colors_if_item_is_selected = "no"
display_volume_level = yes
screen_switcher_mode = media_library, playlist, browser, visualizer, clock
startup_screen = media_library

# Visualizer ..
visualizer_fifo_path = "/tmp/mpd.fifo"
visualizer_output_name = "my_fifo"
visualizer_sync_interval = "30"
visualizer_in_stereo = "no"
visualizer_type = "spectrum"
visualizer_look = "▋▋"
visualizer_color = blue, cyan, magenta, red

Cheers

3 Likes

Ran script, it seemed to work, but nothing happens…seems like mpd isn’t loading…

@TimApple, have you run mpd from the terminal? What’s the output?

Hi! My first steps are always these: First --> https://github.com/midfingr/youtube_notes/blob/master/ez_mpd
Second: To start MPD on login add the following to ~/.profile (or another autostart file):# MPD daemon start (if no other user instance exists)
[ ! -s ~/.config/mpd/pid ] && mpd

And then open your terminal and tip “mpd”(without the quotes), push return(Enter)and then ncmpcpp. If ncmpcpp is open, push Number 4 and add your music with “a”. Thats all.

Ps.: For the keybinding command you can use this: termite -e ncmpcpp

1 Like

@Dobbie03

    tatpap@micasa ~ % mpd
    Apr 10 05:33 : exception: Failed to bind to '127.0.0.1:6600'
    Apr 10 05:33 : exception: nested: Failed to bind socket: Address already in use
    1 tatpap@micasa ~ %                                                          :(

Can’t be of much help here since I have never tried mpd/ncmpcpp. Going by the message it looks as if either mpd is already running or there is some other service making use of port 6600 already.

Kill mpd. Then run

mpd --no-daemon --stdout --verbose

edit
post the entire terminal response

Will try this when I get a chance…thanks

When you do the things,which i describe in my post above than it
doesnt matter. I have the same. Here:
screenshot

Type now ncmpcpp and you get this:
screenshot_1

and ummm, sorry for my english.

@subjunkie
Kill mpd. Then run

mpd --no-daemon --stdout --verbose

and post the entire terminal response

@ector You have misunderstood me.:sweat_smile: I have no problems with mpd and ncmpcpp. All what i want was to show @TimApple
that i have the same error messages, but on a local mpd configuration it isnt important. Mpd + ncmpcpp is running with or without these messages.(For me)

1 tatpap@micasa ~ % mpd --no-daemon --stdout --verbose                       :(
config_file: loading file /home/tatpap/.mpd/mpd.conf
libsamplerate: libsamplerate converter 'Fastest Sinc Interpolator'
vorbis: Xiph.Org libVorbis 1.3.6
opus: libopus 1.2.1
sndfile: libsndfile-1.0.28
exception: Failed to access /home/tatpap/music: No such file or directory
simple_db: reading DB
curl: version 7.59.0
curl: with OpenSSL/1.1.0h
avahi: Initializing interface
avahi: Client changed to state 101
avahi: Client is CONNECTING
state_file: Loading state file /home/tatpap/.mpd/state
inotify: initializing inotify
exception: inotify_add_watch() has failed: No such file or directory

Mpd is a daemon, (it’s right in the name) you don’t access it directly, other programs are used to query, load, play, etc such as ncmpcpp.

I don’t see any reason to run it directly at any point… Use mpc if you want to interact with mpd on the command line, otherwise just run something like ncmpcpp

ncmpcpp -S visualizer

This will start you off with a split window of your library and a visualizer.

The rest is right at your fingertips my dude

man ncmpcpp

man mpd

man mpc  # mpc --help is also good as its just commands

Some keybinds ripped straight from the Arch wiki

Partial list of views within ncmpcpp:

  • 1 - Current playlist
  • 2 - Filesystem browser
  • 3 - DB search
  • 4 - Library
  • 5 - Playlist editor
  • 6 - Tag editor (very powerful!)
  • 7 - Output selector
  • 8 - Music visualizer
  • = - Clock
  • F1 - Help

Other UI keys

  • q - Quit
  • f - Seek forward
  • b - Seek backward
  • \ - Switch between classic and alternative views
  • # - Display bitrate of file
  • i - Show song info
  • I - Show artist info (saved in ~/.ncmpcpp/artists/ARTIST.txt)
  • L - Shuffle between available lyric databases
  • l - Retrieve song lyrics for current song Show/hide lyrics
  • > - Next track
  • < - Previous track
  • p - Play/Pause
  • + - Increase volume 2%
  • - - Decrease volume 2%
2 Likes

Seems you spelled it wrong, unless I am mistaken it should be /Music

Apologies if I am wrong

Cheers

2 Likes

I’m not big, but you should not have that mistake.
Regards

OK. You have right. Thank you. Have a nice day or night. Greetings

My way of using mpd.

# Files and directories #######################################################
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"

# General music daemon options ################################################
bind_to_address		"localhost"

auto_update    "yes"

# Symbolic link behavior ######################################################

follow_outside_symlinks	"yes"

follow_inside_symlinks		"yes"

# Input #######################################################################
input {
        plugin "curl"

}

# Audio Output ################################################################
audio_output {
	type		"alsa"
	name		"My ALSA Device"
    buffer_time     "50000"   # (50ms); default is 500000 microseconds (0.5s)
	mixer_type      "software"      # optional
#	device		"hw:0,0"	# optional
#	mixer_device	"default"	# optional
#	mixer_control	"PCM"		# optional
#	mixer_index	"0"		# optional
}

audio_output {
        type            "fifo"
        name            "Visualizer feed"
        path            "/tmp/mpd.fifo"
        format          "44100:16:2"
}
# Character Encoding ##########################################################
filesystem_charset		"UTF-8"

#############################################################################
#Notes------

# I only use Alsa on my system that includes if i'm using a DAC. No pulse-audio for anything first thing I remove.

# I store my music on a seprate drive and use symlinks to the music folders. 
# One of the best features of ncmpcpp is that you can have as many music folders as you like and they are shown as separate folders in library screen (2) .
# I always prefer to run mpd as a server.


#If you have troubles with volume being delayed at startup or get errors trying to change the volume set it to "software"
#mixer_type      "software"      # optional

#----------

#buffer time is mainly used for cava helps with sound sinking.
#buffer_time     "50000"   # (50ms); default is 500000 microseconds (0.5s)

#---------

Starting the mpd server after install.

$ systemctl start mpd
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to start 'mpd.service'.
Authenticating as: koo
Password:
==== AUTHENTICATION COMPLETE ====

$ systemctl enable mpd
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ====
Authentication is required to manage system service or unit files.
Authenticating as: koo
Password:
==== AUTHENTICATION COMPLETE ====
Created symlink /etc/systemd/system/multi-user.target.wants/mpd.service → /usr/lib/systemd/system/mpd.service.
Created symlink /etc/systemd/system/sockets.target.wants/mpd.socket → /usr/lib/systemd/system/mpd.socket.
3 Likes