NanoPi NEO Music Player

No frills here, this is the cheapest Linux music player I have attempted to create, period.

That said, initial results are promising.  I do not have “Golden Ears” by any means, however the sound quality and noise levels are acceptable to me (after I figured some things out), and I am listening through a pair of Audio-Technica ATH-M50x headphones.

OS of Choice

I may have made this harder on myself, I’m not sure, but I chose the old standby for OS, Debian-based Armbian.  Easy setup and install, no issues there.  I am assuming the reader can handle SSH.  I then installed MPD and Samba

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mpd
sudo apt-get install samba

The Hard Part

That done, it was time to investigate the I2S issue I was certain I was going to have:  Where was the device?

aplay -l

Yielded only 2 devices, audiocodec and sndhdmi.  Neither of those are the I2S device.  Some rooting around on the internet, I came across a tutorial, which supplied the missing information on why my extremely expensive DAC was not on the device list:

Change Directory to boot:

cd /boot

Turn the script.bin to a fex-File and open it in an Editor

sudo bin2fex script.bin script.fex
sudo nano script.fex

Now change the following Entries:

[twi1]
twi_used = 1

to

[twi1]
twi_used = 0

and

[pcm0]
daudio_used = 0

to

[pcm0]
daudio_used = 1

Save your changes and do :

sudo fex2bin script.fex script.bin

After a reboot your done.

Again, this information is thanks to the folks over at the Armbian Forums, specifically Da Alchemist.

After performing the above magic, “aplay -l” should look like:

**** List of PLAYBACK Hardware Devices ****
card 0: audiocodec [audiocodec], device 0: SUNXI-CODEC sndcodec-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: snddaudio [snddaudio], device 0: SUNXI-TDM0 snddaudio-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: sndhdmi [sndhdmi], device 0: SUNXI-HDMIAUDIO sndhdmi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

“card 1” is the one we want.  Now to convince MPD to play.

MPD Configuration

Quite a bit of configuring MPD is quite simple, assuming you know your way around a linux command line and nano.  (I assume, if you got this far, you’re good)

The MPD config file lives in /etc/mpd.conf

I’m not going to cover every little thing you can and might do with the thing, I’m only going to hit the minimum to get you running, the rest can easily be researched starting with the MPD User Manual.

sudo nano /etc/mpd.conf

Open mpd.conf for editing.  Look around, there are a lot of things that live in there.  The only 2 we’re going to look at today are music_directory and audio_output.

The music_directory entry is quite straightforward, put in the path to your music on the device.  In my case, I use a central file and media server, which MPD can handle without a mount point.  In the case of a windows network drive (samba), you simply type in

music_directory "smb://ServerName/path/to/music/"

The audio_output entry is the really important one, and has some tricks.

audio_output {
        type            "alsa"
        name            "My ALSA Device"
        device          "hw:1,0"        
        mixer_type      "software"      
        format          "*:32:2"
        replay_gain_handler "software"
}

Your settings, if you followed this tutorial exactly without creative license, will need to, at least initially, look like that.  Above we saw that snddaudio was card 1, subdevice 1.  

The DAC we have does not have a  hardware mixer.  To control volume via an MPD client you have to enable the software mixer.  If you’re a purist and have the equipment, leave it “hardware” or “null” and use your stereo to do the volume adjustments for you.

So, I had trouble with the “format” line.  The driver appears to have trouble scaling inputs for the I2S, so the 32-bit DAC receiving 24-bit samples is *very* quiet.  Until, that is, you throw a 16-bit file at it, which the driver appears to handle just fine.  Then you lose your hearing.  The solution is to shift your input samples to make them 32-bit.  In this case the “format” line is the one of interest.  It tells MPD to make everything 32-bit, 2 channel, and to pass through whatever sample rate it gets (that’s the ‘*’, no transcoding or fiddling with the data outside of the shift).

The “replay_gain_handler” is optional.  I have it set to match the mixer type, what it does is adjust replay gain for files that specify what that gain should be.  Obviously the DAC does not have this as a hardware capability. 

Using The Thing

Finally!  Once you’ve decided where your music lives, rebooted the board, you need an MPD client.  I may, in the future, install one that can be gotten to via browser, but today I was a bit lazy and downloaded an app for my Android, called M.A.L.P.  Any MPD client will do, you simply point to the IP address or hostname of your player, and, since we didn’t mess with that setting, port 6600.  The program should connect no problem, and then you will be able to refresh the library, and start playing!

2 thoughts on “NanoPi NEO Music Player”

  1. I think you should look into the NAS add-on NanoPi now offers. Would help expand your storage on your music player greatly.

    1. I would love to try it out, of course my budget is only so big and I don’t really have a need for it right now, using my home media server as the storage point.

Leave a Reply

Your email address will not be published. Required fields are marked *