View Single Post
  #1   (View Single Post)  
Old 30th December 2013
shep shep is offline
Real Name: Scott
Arp Constable
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,235
Default Music Player Daemon (MPD) OpenBSD Howto

Music Player Daemon (MPD) OpenBSD Howto

Edit: See the next post for OpenBSD 6.3+ modifications

MPD /audio/mpd is one of the lightest, most responsive methods to access mp3, ogg files and internet streams. Installation entails 2 components; the daemon and one of a number of front ends. On an older i386, playback of locally stored mp3's or internet music streams uses less than 2% of the cpu.

In OpenBSD, the /audio/mpd port has two flavors, the basic port and a flavor that enables the tremor integer decorder. The tremor option enhances performance on *ogg files at the expense of network streaming.

There are multiple front ends that function as traditional clients to the music player daemon. Clients can be command line, console, embedded, or GTK+, Qt or Java based gui's. Plugin interfaces ranging from a Firefox extension, desktop specific controllers and emacs are available. The clients also can control some aspects of the daemon.

In OpenBSD, configuration is easy, just edit /etc/mpd.conf to delineate where your music is stored.
music_directory                 "/home/user/music"
The port maintainers have set defaults for local users with the libao backend. For Gnome3 users, libao will work in parallel with pulseaudio or /etc/mpd.conf can be edited to change mpd output from libao to pulseaudio.

The music files and the chain of directories all need to be executable. In OpenBSD, the executable directory chain is there by default when using /home/user/music. On initial startup and after any additions to the music folder, an update command will need to be run. Once the music directory is in place and configured in /etc/mpd.conf, add mpd to collection of package script daemons to be started in /etc/rc.conf.local. For example:
pkg_scripts="messagebus avahi_daemon mpd"
Note that mpd does not require the messagebus or avahi_daemon to function.

Either reboot or run
/etc/rc.d/mpd -f start
as su/root to start the daemon.

I'll mention two mpd clients; audio/ncmpc and audio/sonata.

Ncmpc can be run in the console or in a terminal. With the setup described above you should see that it is connected to the localhost. Ctrl-U will start a music database update. The F1 key will show the help file, F2 the playlist and F3 will let you browse the music folder.
Internet music streams can be added in the F2 playlist panel with the 'a' key. The 'S' key will save the music stream url where it can be found in the F3 panel. Two of my favorite stream sources are:
WNCW, an NPR station out of North Carolina
Radio Paradise which is a commercial free station out of California. Ncmpc also supports lyrics but at the expense of increase bandwidth and cpu cycles.

If the station you wish to stream is a *m3u link, the mp3 stream will be embedded with the *m3u file. For example, the WNCW web page provides this web page link
Download the link to your local directory view the contents

$ less 128K.m3u provides

#extinf:99999,88.7 WNCW
Some example menu entries:
For those using xterm:
xterm -g 54x18 +sb -T "NcMpc Music" -e ncmpc
Alternative terminals that support changing title bar icons, such as /x11/rxvt-unicode can use
urxvt -g 54x18 +sb -icon /usr/local/share/pixmaps/music.png -T "NcMpc Music" -e ncmpc
after copying an icon to the file path specified. Those running a desktop environment that supports freedestop menu entries can use the following entry in /usr/local/share/applications/ncmpd.desktop
[Desktop Entry]
Comment=MPD Front end
Exec=xterm -g 54x18 +sb -T "NcMpc Music" -e ncmpc
An example music.png icon and a screenshot of ncmpc running in rxvt-unicode:
Name:  music.png
Views: 2936
Size:  1.5 KB

Name:  ncmpc.png
Views: 2955
Size:  30.4 KB

Sonata, /audio/sonata, provides the same functionality with a mouse pointer interface and a system tray icon. Internet streams are added and stored under the 'streams' tab. Album art is available in addition to lyrics for those with bandwidth and cpu cycles to burn.

Edit: 5) dbus_daemon renamed to messagebus

Last edited by shep; 11th July 2018 at 10:21 PM. Reason: 1) Update RadioParadise to more robust server 2) Dealing with m3u links 3) Clarify pkg_scripts damons 4) Corrected WNCW link
Reply With Quote