DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 30th December 2013
shep shep is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,119
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.
Code:
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:
Code:
pkg_scripts="messagebus avahi_daemon mpd"
Note that mpd does not require the messagebus or avahi_daemon to function.

Either reboot or run
Code:
/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:
Code:
http://audio-mp3.ibiblio.org:8000/wncw-128k
WNCW, an NPR station out of North Carolina
and
Code:
http://stream-tx1.radioparadise.com:80/mp3-128
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

Code:
#extm3u
#extinf:99999,88.7 WNCW
http://audio-mp3.ibiblio.org:8000/wncw-128k
Some example menu entries:
For those using xterm:
Code:
xterm -g 54x18 +sb -T "NcMpc Music" -e ncmpc
.
Alternative terminals that support changing title bar icons, such as /x11/rxvt-unicode can use
Code:
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
Code:
[Desktop Entry]
Name=NcMpc
Comment=MPD Front end
Exec=xterm -g 54x18 +sb -T "NcMpc Music" -e ncmpc
Terminal=false
Type=Application
Icon=music.png
Categories=GTK;AudioVideo;
An example music.png icon and a screenshot of ncmpc running in rxvt-unicode:
Name:  music.png
Views: 2402
Size:  1.5 KB

Name:  ncmpc.png
Views: 2420
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; 4 Days Ago 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
  #2   (View Single Post)  
Old 20th October 2015
shep shep is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,119
Default

This is an update for OpenBSD release 6.3

In OpenBSD 6.3 release, the default /etc/mpd.conf file is now provisioned with sndio for the audio output. If I attempted to start mpd system wide in /etc/rc.conf.local, there were problems with audio streams.

What worked well is to setup a local configuration (per user) as described in the
Arch Linux mpd wiki.
I used OpenBSD /usr/local/share/doc/examples/mpd/mpd.conf when making a ~/.mpd/mpd.conf. If you have an /etc/mpd.conf, rename it to a non-functional backup.

I additionally used a Unix socket in my home directory by doing the following
1) ~/.profile
Code:
# $OpenBSD: dot.profile,v 1.5 2018/02/02 02:29:54 yasuoka Exp $
#
# sh/ksh initialization

PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games
MPD_HOST=${HOME}/.mpd/socket
export PATH HOME TERM MPD_HOST
2) In mpd.conf, Comment out
Code:
bind_to_address                        "localhost"
to
Code:
#bind_to_address                        "localhost"
and uncomment
Code:
#bind_to_address                 "~/.mpd/socket"
to
Code:
bind_to_address                 "~/.mpd/socket"
If you are using Gnome3, KDE4 or Xfce4, you can specify the xdg, freedesktop music directory
Code:
music_directory                 "~/Music"
4) Autostart the command on login
Code:
mpd ~/.mpd/mpd.conf
The above command can be added to ~/.xinitrc or ~/.xsession or the autostart file in your WM/DE.

Last edited by shep; 4 Days Ago at 10:22 PM. Reason: Updated for 6.3
Reply With Quote
  #3   (View Single Post)  
Old 6 Days Ago
beavers beavers is offline
Port Guard
 
Join Date: Nov 2017
Posts: 24
Default

Does mpd's built-in http option work on OpenBSD? I recall installing it some time ago, but failing to get music streaming over http -- I could only get it playing locally on the server, controlled with mpdroid and mpc.

Edit: super nice write-up!!!

Last edited by beavers; 6 Days Ago at 07:46 PM. Reason: Nice write-up!
Reply With Quote
  #4   (View Single Post)  
Old 6 Days Ago
ibara's Avatar
ibara ibara is offline
GNU gold linker
 
Join Date: Jan 2014
Posts: 557
Default

Where's the Like button?
We the people need Like buttons for threads like this!
Reply With Quote
  #5   (View Single Post)  
Old 6 Days Ago
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,290
Default

Quote:
Originally Posted by ibara View Post
Where's the Like button?
We discourage subject changing within threads which have a clear distinct singular topic.

However to answer the question, the "like" counter was disabled once it was discovered to contain a security flaw in this version of vBulletin.
Reply With Quote
  #6   (View Single Post)  
Old 6 Days Ago
ibara's Avatar
ibara ibara is offline
GNU gold linker
 
Join Date: Jan 2014
Posts: 557
Default

Sorry, I wasn't intending to change the subject; I was trying to thank shep for this tutorial with a bit of humor
(But good to know about the like button.)
Reply With Quote
  #7   (View Single Post)  
Old 2 Days Ago
beavers beavers is offline
Port Guard
 
Join Date: Nov 2017
Posts: 24
Default

So, is anyone using the http feature of mpd?
Reply With Quote
  #8   (View Single Post)  
Old 2 Days Ago
shep shep is offline
Rc.conf Instructor
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,119
Default

My setup on 6.3 Stable streams the WNCW and Radio Paradise url's given above.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenBSD : Ripping and writing music CDs with cdio(1) J65nko Guides 5 30th November 2011 08:33 PM
New to OpenBSD: problem with music, raid? barum87 OpenBSD General 3 24th June 2010 04:04 AM
Howto Compile in OpenBSD 4.5 shep OpenBSD Packages and Ports 2 7th May 2009 11:25 PM
I'm looking for a music text based music player that can play .m4p and .m4a formats cssgalactic FreeBSD Ports and Packages 4 14th July 2008 04:16 AM
whats playing on your music player? ephemera Off-Topic 22 10th June 2008 06:57 PM


All times are GMT. The time now is 06:47 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick