• NetBSD
  • Music Player Daemon (MPD) on NetBSD

Thanks for sharing this. Until only recently I've just been listening to music from Spotify using ncspot which was kindly packaged for NetBSD.

I have recently begun cultivating a local music library for which I am looking for new ideas on how to play my files.

The simplest method I've found is creating a playlist folder and just syminkinking music files from their respective folders into it and then using SoX and shuffle. Something like play $(shuffle *). However, this requires manually organising your music library/playlists etc. I'm sure you could use fzf in the pipeline also which might make it a little more interactive but it'll always be limited by your ability to keep your folders neat and tidy.

I've just come accross a cool mpd client called Davis (on reddit of course) which looks kind of cool. With your above tutorial I'll try and get mpd up and running and attempt to get somehting like this working.

@pin this is a rust client..... 😉

Thanks again 🙂

    pfr I've just come accross a cool mpd client called Davis ... @pin ...

    http://mail-index.netbsd.org/pkgsrc-wip-changes/2022/02/18/msg023327.html

    ===> Overriding tools for davis-0.1.1
    ===> Extracting for davis-0.1.1
    => Extracting local cargo crates
    ===> Patching for davis-0.1.1
    ===> Creating toolchain wrappers for davis-0.1.1
    ===> Configuring for davis-0.1.1
    ===> Building for davis-0.1.1
       Compiling log v0.4.14
       Compiling libc v0.2.97
       Compiling bufstream v0.1.4
       Compiling cfg-if v1.0.0
       Compiling lexopt v0.2.0
       Compiling configparser v3.0.0
       Compiling mpdrs v0.1.0
       Compiling davis v0.1.1 (/usr/pkgsrc/wip/davis/work/davis-f16a22288e6cac4b62ba8cc25cba06c6ae4a89ab)
        Finished release [optimized] target(s) in 1m 27s

    Please test and let me know what you need as external dependencies, if any. Currently I have no use for this.

      pfr I don't see portaudio being mentioned among mpd output plugins. On NetBSD 6 to 7, I was using OSS (as I had been for years, on FreeBSD ), but moved to SunAudio after the audio API rework. The output device has always been /dev/audio for me, so I don't know if this makes any practical difference, given NetBSD provides OSS emulation. Naturally, MPD can now coexists with other sound playbacks and won't lock /dev/audio, as opposed to what would have happened in the past.
      I think the alternatives on NetBSD would be OpenAL, libao, PulseAudio and Jack, but I don't know which of those is enabled by default or either available as a build option.

      • pin replied to this.

        JuvenalUrbino I think the alternatives on NetBSD would be OpenAL, libao, PulseAudio and Jack, but I don't know which of those is enabled by default or either available as a build option.

        Check http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/audio/musicpd/options.mk?rev=1.39&content-type=text/x-cvsweb-markup

        PKG_SUPPORTED_OPTIONS+= jack openal libao pulseaudio

        and

        PKG_SUGGESTED_OPTIONS= curl faad ffmpeg libao musepack samplerate shout vorbis

          @pfr to add something to my reply, I don't know if using an audio library on top of the native sound stack brings any significant difference quality-wise. So, if that's your concern, I'd rather seek out CDs and vinyls rips in lossless format (e.g. wavpack), use a good pair of speakers or headphones or even get a dedicated PCI sound card on a desktop PC. I don't know much on the topic, however; possibly @nia could provide a better advise.

          • pin replied to this.

            pin good; @pfr will probably know this at this point, but if options.mk is available for a given package, one can also display options-related info by running make show-options within the package dir, under the pkgsrc prefix.

            JuvenalUrbino seek out CDs and vinyls rips in lossless format (e.g. wavpack)

            It's enabled by default,
            PKG_SUGGESTED_OPTIONS+= wavpack

            As for the rest, it's outside my comfort zone.

            @pfr ncspot also has build options,

            PKG_OPTIONS_GROUP.backend= alsa portaudio pulseaudio rodio

            Unfortunately, if your concern is having two different backends and you would like to have only one of them, pulseaudio is the only common one between the two packages.

            That said librespot which ncspot uses under the hood supports more options, so maybe upstream ncspot could enable those.

            Currently, librespot supports the following

            PKG_SUPPORTED_OPTIONS= alsa gstreamer jack portaudio pulseaudio rodio sdl

            • pfr replied to this.
            • Jay likes this.

              pfr This was the only concern

              Well, using the Solaris output plugin allows MPD to speak directly to the kernel's sound stack, so it's arguably the simplest and most lightweight solution and doesn't introduce any new dependency. The plugin was adapted to work with NetBSD's API by Nia herself a couple of years ago.
              Portaudio is not a sound server per se (unlike pulseaudio, jack, esound, sndio), but a audio I/O library which manages sound stream by using a callback function to read from / write to, a ring buffer. By implementing portaudio on NetBSD, you're still using audioio.h and speaking directly to /dev/audio, a.k.a. SunAudio.
              The work as you can see, was again committed by Nia and avoids having to rely on OSS emulation (which happens at the kernel level anyway).

                pfr Works for me. Does mpd print out any errors if you run mpd --no-daemon --verbose --stderr in X? If not, double check your spelling and if mpd is located in /usr/pkg/bin/.

                  oui Thanks, it looks like mpd cant create the /tmp/run/1000/mpd.fifo set in ~/.mpd/mpd.conf copied from the example in step 4 from the OP.

                  ~ $ mpd --no-daemon --verbose --stderr
                  config_file: loading file /home/dave/.mpd/mpd.conf
                  path: SetFSCharset: fs charset is
                  libsamplerate: libsamplerate converter 'Fastest Sinc Interpolator'
                  vorbis: Xiph.Org libVorbis 1.3.7
                  opus: libopus 1.3.1
                  sndfile: libsndfile-1.0.31
                  hybrid_dsd: The Hybrid DSD decoder is disabled because it was not explicitly enabled
                  simple_db: reading DB
                  exception: Failed to configure output in line 26; Couldn't create FIFO "/tmp/run/1000/mpd.fifo": No such file or directory

                  Does it need to be run as root?
                  It works if I manually create this file.

                    pfr you really don't need a fifo unless you use a visualizer (and, for the record, the built-in visualizer for audio/ncmpcpp is even disabled by default on pkgsrc).

                    I use /tmp/run/${id -u}/ as personal user-owned XDG_RUNTIME_DIR and TMPDIR. Should have clarified that beforehand. This directory doesn't normally exists under /tmp –which is commonly mounted with a tmpfs– and is created at each login by my ~/.profile script. mpd will naturally fail to create the file if the parent directory tree is nonexistent.

                    • pfr replied to this.
                    • pin likes this.

                      @pfr, just adding to what @JuvenalUrbino already said, I use a few Qt-based applications and these are very capricious when it comes to XDG_RUNTIME_DIR.

                      I have the following in my .xinitrc to keep them happy,

                      mkdir /tmp/${USER}-runtime && chmod -R 0700 /tmp/${USER}-runtime
                      export XDG_RUNTIME_DIR=/tmp/${USER}-runtime

                      Just create the directory it needs as @JuvenalUrbino sugested.

                        pin I have the following in my .xinitrc to keep them happy,

                        This is what I was using up until recently, but then I realized that I may have needed a TMPDIR even outside of a X session. This is particularly true for programs like vi/ex, mutt, slrn, etc.. which will attempt to write the buffer on a temporary file within such dir, if told to do so, and complain if they find none. So, I decided to rather add the following section in my ~/.profile (which by default is only read on a login shell):

                                UID=$(id -u)                            
                        DIR=/tmp/run/${UID}
                        if [ ! -d "$DIR" ]; then
                        mkdir -p $DIR
                        chown ${LOGNAME}:users $DIR
                        chmod -R 0700 $DIR
                        fi
                        XDG_RUNTIME_DIR=${DIR}
                        TMPDIR=${XDG_RUNTIME_DIR}
                        • oui likes this.

                        Cool, thanks.

                        Weird behavior going on now though... basically I just moved/renamed some folders within my ~/Music dir yet mpd doesn't seem to recognise these new dir names but still accepts the previous dir names when attempting to add music to the queue. Of course when trying to play it complains with No such file or directory etc..

                        I've tried restarting mpd several times but it still looks for the old directories. Is there a cache file that need to be cleared or something?