Stop the press: Archphile is back! Codename: “corona”

Archphile used to be the RPi audio distribution of choice for the most hard-core RPi-lovin’ audiophiles around until last June when Michael (tuxx) decided to drop it.

Then in January he hinted to it coming back at some point.

Well, it appears that that moment has come. Head over here for more: https://archphile.org/blog/archphile-119-codename-corona-for-rpi23-and-odroid-c2-is-up/

And not a moment too soon.. My Audio Pi is pretty much ready and it is in desperate need of a proper audio distribution. This should be interesting.

Allo DigiOne S/PDIF HAT

First off, I’m ashamed to admit that I had this little gem in my possession for about 2 years before I finally got the chance to put it through its paces.

After all, it’s just a s/pdif output device for a Raspberry Pi, right? I mean, it’s just s/pdif, how good could it be?

It turns out it can be pretty damned good! But I’m getting ahead of myself.. Let’s start at the beginning.

The DigiOne is a HAT compatible with most if not all RPis and supported by most if not all audio distributions. It is intended to be plugged-in directly on top of the RPi, with no need for an isolator HAT. Plus, it is designed to be powered by the RPi via the GPIO header, so no need (or provision) for an external power source.

The DigiOne utilizes a WM8805 to convert the RPi’s I2S signal into s/pdif. The WM8805 is run in master mode, so as to minimize jitter due to the RPi’s problematic I2S clocking scheme. The WM8805 is clocked by the same oscillators that are used to reclock the s/pdif signal.

The WM8805’s s/pdif output goes through an Si8641 150MHz galvanic isolator and is passed to the “clean” side of the board.

There the signal is reclocked by a high quality flip-flop clocked by high quality NDK oscillators (housed inside a metal box, used for shielding against EMI/RFI). There exist two oscillators, one for the 44.1K family and one for the 48K family of sampling rates. The output of the oscillators is put through NB3L553s for buffering and isolation.

The entire isolated part of the board is powered by a DC-to-DC converter that offers galvanic isolation. Following this converter there exist a large number of LDO regulators and filter components. An LT3042 regulator is used to power one of the most critical parts of the circuit: the flip-flops that do the final reclocking.

So, very solid engineering all around. But how well does it sound?

The answer is, surprisingly well for the money.

My RPi stack included an RPi 3 with the DigiOne, powered by Salas’ new L-Adapter power supply and running Archphile. The music was coming from my NAS. No audiophile ethernet switches were employed. 😛
Pitted against that I had my Logitech Squeezebox Touch running the EDO plugin for up to 192K s/pdif from its coax output and my relatively pricey Pioneer DV-LX50 Universal Player (using its coax s/pdif output).

The music used was Dire Straits’ SACD album (having selected its CD (and not SACD) layer) which was also accurately ripped to my NAS.

Output from the s/pdif transports went into an AK4118-based s/pdif receiver of my own design which in turn feeds my dual mono AK4493 DAC. The DAC’s output goes through a Salas DCG3 preamp into my Hypex amp.

First up was the Pioneer. It had been a while since I had listened to it through its s/pdif output so I was in for a bit of a shock. Its output sounded coarse, strained, tiring. For a moment I thought that it was due to the SACD’s mastering (the CD layers of SACDs are rumored to be mastered intentionally bad so as to give the impression that the SACD layers sound even better than they actually do), but that changed when I switched to the Squeezebox. Things got noticeably better, actually listenable. Not exactly close to what I had been accustomed to using the Squeezebox’s USB port, but closer.
Then I switched to the DigiOne. Wow! All of the “coldness” of the music was gone, the stage gained depth and width, the music became more detailed and lifelike. This was definitely a step up.

I would dare say that this s/pdif setup came in fact close in SQ to my USB setup. This was a very pleasant surprise.

Now I need to do some A-B testing between the DigiOne and the USB output of the RPi. So to-be-continued..

An “Audio Grade” Raspberry Pi

Not much free time these days so updates have been slow.. but I have a lot of interesting stuff cooking in the back burner.

One of them is an audio grade RPi.

Essentially it will be a Compute Module 3 on a mainboard loaded with ultra low noise linear power supplies and some necessary peripherals.

The idea came to me quite some time ago but it wasn’t until last November that I decided to actually go ahead with it.

The proof-of-concept PCBs for the mainboard were done by December.

It appears that even the PoC board, with average quality power supplies, has a cleaner I2S output compared to a standard RPi3 powered by an equivalent linear power supply:

RPi 3:

Audio grade Pi:

The next part was the PoC board for the USB Hub & Ethernet controller. That took a bit more time and a 4-layer PCB with numerous 0402 sized components but it too ended up just fine (with the exception of a bad RJ45 footprint..).

So now I have a fully functioning set of boards with average quality power supplies that already performs better than my Squeezebox Touch as a USB transport.

Next step is to design a single board integrating all of the components plus ultra high quality power supplies.

That will probably be a summer project..

Orange Pi One & Lite as music streamers (Part 2)

In Part 1 we installed Armbian on our Orange Pi One (or Lite) and set it up on our local network. At this point, all our work can be done on any PC that is on our network, via SSH connection (putty etc.).

Enabling I2S output
First order of business is enabling the Pi’s I2S output. To do that, we need to edit what is called a FEX file. This FEX file (script.fex) is essentially a hardware configuration file for the Pi. For example, if we wanted to enable or disable a serial port at the hardware level, we would edit this FEX file.

The problem is, this FEX file exists in binary form in our file system so in order to edit it, we need to convert it to a text file. To do that we use the bin2fex command.
So, step by step:

Log into Pi as root and type:

cd ..
cd boot
bin2fex script.bin script.fex
nano script.fex

Nano is a relatively user friendly editor for Linux, I use it for all my text editing.

Look for twi1. Change it to this:

Then look for pcm0. Change it to this:

Once we are done editing the file, we hit Ctrl-X and choose to save the file before exiting.

Then we need to convert the .fex file back to .bin. We type:

fex2bin script.fex script.bin

and we reboot.

We confirm that we have a new sound device called snddaudio by typing in aplay –l :

Network Share configuration
Now that our I2S output is enabled, we need to give our Pi access to our music. I prefer to store my music in a Synology NAS so I need to configure a network mount on the Pi.

We start by creating a mount point for our share. That can be any empty folder. I choose to mount my shares in mnt/nas-samba. Let’s create that:

cd /mnt
mkdir nas-samba

Then we install the package cifs-utils:

apt-get install cifs-utils

Now we get to the actual mounting of the share:

nano /etc/fstab

For my setup, I add this line: //192.168.0.32/Music /mnt/nas-samba cifs username=,password=,ro,iocharset=utf8,nolock,noauto,x-systemd.automount,x-systemd.device-timeout=10,sec=ntlm,rsize=8048,wsize=8096

This tells our Pi to mount the share //192.168.0.32/Music to the folder that we created above using the credentials that I have supplied. You will need to customize this command to your own network environment.

After a reboot we go to our mount point and have a look inside:

To confirm that the share has been mounted we can use the df -h command, as can be seen above.

MPD Installation

The software on our Pi that does the actual music playback is called MPD (Music Player Daemon). To install it we enter:

apt-get install mpd

This will take a while, since MPD has a bunch of dependencies that will also be downloaded and installed.

Once the installation is finished, we will need to configure it. To do that, we edit mpd.conf:

nano /etc/mpd.conf

We need to do three things:

1) Set our music directory to /mnt/nas-samba:

2) Change network binding to “any”:

3) Change the “audio” setting to select our I2S audio output:

We put in this:

audio_output {
        type            "alsa"
        name            "I2S DAC"
        device          "hw:1,0"
        format          "*:32:*"
        mixer_type      "software"
#       mixer_device    "default"       # optional
#       mixer_control   "PCM"           # optional
#       mixer_index     "0"             # optional
}

This configuration creates an ALSA device called “I2S DAC” that utilizes the Pi’s I2S output. It up-samples all files to 32bits (don’t worry, it doesn’t deteriorate the SQ in any way. It just pads with zeroes when necessary) in order to make this setup compatible with my Buffalo III. Also, it enables software volume control. You can disable it by commenting out the relevant line.

Once we are done, we save the file and quit nano. We then restart MPD to apply the changes:

systemctl restart mpd

MPD Clients Installation

Once MPD is installed, we will need a “human friendly” way of interfacing with it.
In other words, we will need to install what is called a “client”. There exist all kinds of clients, from command line based ones, to web-based environments, to apps for smartphones and tablets. In my setup I install two clients, a command-line based one (mainly for testing purposes) and a web-based one for more general use.

To install the classic command line client “mpc” we enter:

apt-get install mpc

That should take almost no time.

Now that we have at least a basic client installed, is a good time to check that MPD is actually working. To do that, I usually do this:

mpc add http://netradio.live24.gr/886radio
mpc play
mpc status

What these commands do is:

1) Add my favorite internet radio station to MPD’s playlist
2) Start playback
3) Check that playback has indeed started.

If it all went well, you should see something like this:

If you have already connected an I2S DAC, you should be hearing music. This means that your MPD is functioning, so the hard part is done.

If by chance you’re looking for the Orange Pi One / Lite’s I2S pinout, you’re in luck. Here it is:

At this point you have a choice to make. You can either install an app on your smartphone or tablet and get things done that way, or you can install a web-based “rich” client. I like rich clients, so after a brief internet search I came across RompR.

Installing RompR

The people behind RompR have written a pretty comprehensive installation guide. All of the necessary info is there, for all platforms. But, since this post has to do specifically with the Orange Pi, I’ll give you a customized version of the installation guide. This should take you about 10 minutes. Let’s start.

First we’ll download and install all of the necessary packages:

apt-get install apache2 php5-curl php5-sqlite imagemagick libapache2-mod-php5 php5-json

Then we will download the actual binary into a temp folder:

cd /mnt
wget http://downloads.sourceforge.net/project/rompr/rompr-0.78.zip

Next step is extracting the files to /usr/bin/rompr:

unzip rompr-0.78.zip -d /usr/bin/

..and we get to the editing of .conf files part:

nano /usr/bin/rompr/apache_conf.d/Apache2.4/rompr.conf

We have to replace every /PATH-TO-ROMPR with /usr/bin/rompr:

When we’re done we exit nano, saving the file.

Then we copy this file to its final location:

cp /usr/bin/rompr/apache_conf.d/Apache2.4/rompr.conf /etc/apache2/conf-available/

We take care of a few permissions:

chmod -R ugo+rw /usr/bin/rompr/prefs
chmod -R ugo+rw /usr/bin/rompr/albumart

And we finish up:

a2enconf rompr
a2enmod expires
a2enmod headers
service apache2 restart

At last, it’s time to see if our installation works. We type into our browser our Pi’s IP followed by /rompr:

All we have to do now is update MPD’s library. We do that by hitting the red Update Music Collection Now button on the left and we’re done.

Enjoy..

Orange Pi One & Lite as music streamers (Part 1)

Meet the Orange Pi One:

Orange-Pi-One-1

Orange-Pi-One-2

and its brother, the Orange Pi Lite:

orange-pi-lite

They are single board computers (SBCs) much like the Raspberry Pi, but they will set you back just over 10€ plus shipping. That is just insane value.

They offer a quad core ARM Cortex A7 processor running at 1.2GHz, 512MBs of DDR3 RAM, an Ethernet port (One) or WiFi (Lite), a couple of USB ports, an HDMI port, etc.
They run Linux (of course..) or Android.

I came across them (the One actually) while watching Dave Jones’ channel on youtube and thought I would give it a try.

I needed an inexpensive way to listen to internet radio while I was in my kitchen. I already had a low end system set up, consisting of a couple of bookshelf speakers, a power amp and a Squeezebox Classic, but I had to move the Squeezebox to another room so I needed something to take its place. The Orange Pi One plus an inexpensive I2S DAC would fit the bill very nicely.

The idea was to load a stable Linux distribution onto the One and set-up MPD to work with my el-cheapo I2S DAC.

The steps that I am about to describe took me about a day to figure out and needless to say, I learned a lot in the process.

Let’s start with the basics.

You will need an Orange Pi board, a proper power supply (USB power will not work – I suggest that you buy a bundle of Orange Pi + Power Supply from aliexpress), a 4GB (or bigger) Micro SD card and an I2S compatible DAC that does not require a MCLK signal (like an ES9023-based one with an on-board oscillator). For the initial setup you will also need a monitor with an HDMI (or DVI with an adapter) input plus a USB keyboard. If you are a bit more hardcore, instead of using a monitor & keyboard, you can just use the Pi’s serial port with a serial to USB module and putty.

The first step is getting our hands on a Linux distribution that will be a good fit to our application. You might notice that there exist a number of official One distributions: http://www.orangepi.org/downloadresources/ The Lite is not so lucky.

The general consensus is that most of them have issues. The best choice appears to be the Armbian distribution:

For the One: http://www.armbian.com/orange-pi-one/
For the Lite: http://www.armbian.com/orange-pi-lite/

Armbian is based on Debian and is very similar to Raspbian (also based on Debian), so if you’ve used Raspbian on a Raspberry Pi you will feel right at home.

For our application we are going to go with the Jessie Server image. We need to put this image file on a Micro SD card. I use Rufus.

We insert the SD card in the Orange Pi, we connect our monitor, keyboard, ethernet and power the thing up.

After about 15-20 seconds, the green power-on LED will start flashing and soon after you will see the initial login screen:

orange_pi_one_1

The default credentials are root/1234.

You need to change the default password to one of your liking. Following that, your Pi will request that you create a new user account:

orange_pi_one_2

Once you’ve done that, you will be asked whether you would like to change your Pi’s resolution to match your screen’s:

orange_pi_one_4

In my case, my lab’s monitor has a 1920×1200 resolution, so I chose to go with the highest supported resolution, so I typed:

h3disp -m 10

One reboot to go and we will be done with the initial setup.

At this point I should point out that I routinely log in to my Orange Pis as root. I can see some of you cringing but I don’t care. Security is way low on my list of concerns when it comes to my SBCs that I use for music playback. If you use a normal user (and not root) on your SBC, all you have to do is prefix the commands that I use with the command “sudo”.

So now, if you have a Pi One and it is connected to your network, it should have acquired an IP from your DHCP server. If you have a Pi Lite, you will need to do some extra work to get it to connect to your WiFi network.

To configure the Lite’s WiFi adapter you need to edit the interfaces file:

nano /etc/network/interfaces

If you would like your Pi to get an IP automatically from a DHCP server, you do this:

# Wireless adapter #1
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

If you are the more traditional type and you would like to go for a static IP, you put in:

# Wireless adapter #1
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.200
netmask 255.255.255.0
gateway 192.168.0.250
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

replacing the above IPs with ones suitable to your environment.

You might notice that in both cases we are mentioning a supplicant.conf file. This file does not exist yet, so we have to create it:

nano /etc/wpa_supplicant/wpa_supplicant.conf

and then type in:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="your_ssid"
psk="your_password"
key_mgmt=WPA-PSK
priority=99
}

Again, replace your_ssid and your_password with your actual SSID and password. Note that it doesn’t matter if you are using WPA or WPA2, the script is the same.

When you are done, save the file (Ctrl-X and then Yes a couple of times) and reboot your Lite.

When the system comes back up log in and check if you are connected to your access point by typing:

ip a

You should see something like this:

1: lo:  mtu 16436 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: tunl0:  mtu 1480 qdisc noop state DOWN group default
    link/ipip 0.0.0.0 brd 0.0.0.0
3: wlan0:  mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:e0:4c:99:f8:3b brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.200/24 brd 192.168.0.255 scope global wlan0
    inet6 fe80::2e0:4cff:fe99:f83b/64 scope link
       valid_lft forever preferred_lft forever

You should see that your wlan0 interface now has an IP.

Congrats, your Lite now has network access. This means that you can put away the monitor & keyboard that you used to configure your Lite and continue on your desktop / laptop by logging in through SSH (using Putty or any other SSH compatible terminal program).

Logging in from Putty, we come to this prompt:

orange_pi_one_5

Next, we have to do a full update & upgrade of our installed packages:

apt-get update
apt-get upgrade

The update part should go pretty fast, but the upgrade part will take some time, depending largely on your SD card’s performance.

This concludes Part 1 (a.k.a. “the boring part”). Part 2 will include enabling the Orange Pi’s I2S output and setting up MPD.