Yes, I put an ES9028Pro on my Buffalo III

A few years back I was hit by Murphy and I was hit hard.

It was the time when you had to be very patient and even somewhat lucky if you wanted to buy a Buffalo DAC. You had to wait for the boards to go on sale and then be quicker than the other (equally “DAC hungry”) DIYers for the privilege of owning one.

I had just gone through all of that trouble and had managed to acquire a brand new Buffalo III board. I remember it like it was yesterday, even though it’s already been more than 5 years. I had it connected to my bench top power supply and was just doing a dry-run, I hadn’t even built the IVY-III yet, looking to see that everything was working as it should, when all of a sudden the lights on the Tridents all went very bright for half a second and then the magic smoke escaped. My power supply’s regulator IC had chosen the worst possible time to kick the bucket. Cost of repairing the power supply: ~1€. Cost of getting a new B3: ~400€ plus another 2 months of waiting.

An autopsy of the damaged board confirmed my suspicions: Almost every active component on the board was gone. Besides the Tridents and the AVCC module, the ES9018S and the Crystek clock were toast. The only components that survived were the ones behind the 3.3V regulator, which proved to be resilient enough to withstand the ~35 volts that were fed to it. So the cost of repair would be prohibitive, especially considering that I couldn’t find anyone that would sell a single ES9018S chip. So the bad board went into a cardboard box and lay there for close to 5 years.

Fast forward to 2016. ESS announces the successors to the ES9018S, the ES9028Pro & ES9038Pro chips.

These chips have a brand new digital core, much improved from the ES9018. There are new digital filters, a new DPLL system, new THD compensation features, a new gain compensation function, etc.
The ES9028Pro is supposed to be an ES9018S with an updated digital core, while the ES9038Pro is supposed to be an ES9028Pro with 4 times the output stages, resulting in an extreme output current capability. This very high current would be the reason why its DNR and THD+N performance would be off-the-charts. But it also meant that all of the existing I/V stages that were designed for the ES9018 would not work for the ES9038Pro. As of this writing, neither Twisted Pear Audio or Acko have on offering proper I/V analog stages.

I made this little table to give you a better idea of the differences between the old and new chips:

ES9018S vs. ES9028Pro vs. ES9038Pro
Feature ES9018S ES9028Pro ES9038Pro
Package 64-LQFP 64-LQFP 64-LQFP
DNR (dB) 8-ch current mode 129 129 132
DNR (dB) 8-ch voltage mode 120 no data no data
DNR (dB) stereo 133 133 137
DNR (dB) mono 135 135 140
THD (dB) current mode -120 -120 -122
THD (dB) voltage mode -108 no data no data
Differential voltage out (AVCC = 3.3V) 3.05V p-p 3.05V p-p 3.05V p-p
Differential current out (AVCC = 3.3V) 3.903mA p-p ~3.8mA p-p ~15.1mA p-p
Max PCM (w/oversampling) 500KHz 768KHz 768KHz
Max PCM (bypassing OSF) 1.536MHz 1.536MHz 1.536MHz
Max DSD (native) DSD128 DSD1024 DSD1024
DoP decoding N Y Y
Max DSD (DoP) N/A DSD256 DSD256
Digital filters (PCM) 2 7 7
Gain Calibration N Y Y
Programmable THD compensation N Y Y
Master or Slave mode support N Y Y
S/PDIF inputs 8 13* 13*
Power management N Y Y
Power consumption 100mW 500mW 500mW
1.2V (VDD) power consumption 37mA 82mA 128mA**
AVCC power consumption 25mA 47mA 90mA

* up to 13
** most likely an error in the datasheet

This info comes from the official brochures that are available on-line, with some additional info from the NDA-protected “full” datasheets. ESS, if you are reading this (and you probably are), there really is no point in trying to keep these datasheets secret. If someone like me (with my non-existant connections) can find them, so can your competitors. Plus I can’t really say that I found any content in your datasheets that would warrant such extreme measures. But I digress.

So, upon inspection of the datasheets the first thing one notices is that both new chips are pin to pin compatible with the ES9018S. That was just too convenient for me and my bad Buffalo board. Good job ESS, I really appreciated that. 🙂 🙂

On the software side, things were very different to the ES9018S. The number of registers had more than doubled (48 registers in the ES9018 versus 115 in the ES9028/38) plus their arrangement was totally different, so I would need to do a total rewrite of the code to support it. Good. More fun to be had. 😀

So now a lightbulb had lit up in my head. I didn’t have much to lose – I already had the board, I could hook up temporary power supplies and a temporary clock so all I had to buy was the actual chip. Considering that I would like to be able to use my existing analog stage, I chose to go with the ES9028Pro. I got on Ebay and ordered a couple (a friend had also decided to bite the proverbial bullet and do the same “mod” to his Buffalo).

Next up was power requirements. The required voltages are the same but the required current has doubled or even tripled, depending on which chip we are talking about. That could be a problem for the AVCC module and Tridents of the Buffalo 3. I needed to do some reading-up on the AVCC & Trident modules. It turns out that the Trident modules are capable of supplying up to 100mA of power (with the proper CCS resistors) so in theory they could be made to work. But my (burnt) Tridents were v1.1, meaning that they were not exactly famous for their robust-ness. Asking them to work near their thermal limits would be looking for trouble. Plus, while researching the Tridents I learned of their latest version, the Trident SR. These now use ultra low noise LDOs (ADM715x) and are rumoured to sound even better than their older shunt types. These days my ultra low noise LDO of choice is the LT3042 so I drew up a set of PCBs that would be a drop-in replacement for the Tridents & AVCC and made an order to a well-known Far East board house.

While waiting for the chips to arrive I had put together some Arduino code that would initialize the chip and provide some basic functionality. It was nothing special – serial port only – but it would get the job done.

After a few days the ES9028Pro chips came and there was no way I was going to wait another month for the new Tridents.

Off came the damaged components..

..to be replaced by fresh capacitors and the brand new ES9028Pro.

For the time being I chose to not solder on a new Crystek since I could not be 100% sure that the board would work.

Instead, I soldered on a two pin header to which I connected an Si570 programmable oscillator that I had lying around.

Power was to be delivered by the on-board die-hard 3.3V LDO with a little help from a small PCB holding a LT3042 taking care of the 1.2V.

I hooked everything up, connected my Arduino, powered the thing on and loaded an I2C scanner on my Arduino. I did a scan and found a single I2C address. That was not good. I should have found two (one for the on board port expander and one for the ES9028). I double checked my connections, my power, made sure that my Si570 was outputting a proper clock, but still nothing. It was time to go back to the datasheet.

My eye fell on the section pertaining to the Reset pin. It stated that it was an active-low pin and that a system reset could be performed either by pulling the pin low or by a software command. The Buffalo III design called for this pin to be pulled low by default so I hadn’t paid any real attention to it. It turned out that I should have. I soldered a 2 pin header and put a jumper on it. The board immediately came alive and was detected by my I2C scanner. 😀 So, the Reset pin should be pulled up.

With that out of the way, I connected my test I2S source (a Chinese clone of an Amanero – not as good as an original Amanero but OK for testing and pretty expendable). The DAC locked with no problem into all sampling rates up to 352K and DSD128 (I didn’t bother to try to go higher) and started playing music!

Now I’m waiting for the new replacement Tridents & AVCC module PCBs to arrive so that I can do a proper test vs. my Buffalo III.

I also need to do a version of my TFT HiFiDuino code for the 9028/9038. Stay tuned.

New page: S/PDIF receiver with the WM8805

It took me a little longer than usual (the board had been sitting around in my workshop for almost a year and a half), but it’s finally up. A page for a very good quality and very versatile Arduino controlled s/pdif receiver.

Check it out here: http://www.dimdim.gr/diyaudio/spdif-receiver-with-the-wm8805/

Mamboberry LS DAC+ vs. Boss DAC vs. Piano 2.1 Hi-Fi DAC with and without Kali FIFO Reclocker


Back in September Allo.com had sent me their Piano 2.1 DAC along with their Kali reclocker, but I didn’t have any other DAC HATs to compare it to and it wouldn’t be fair to it to compare it to my Soekris or my Buffalo III DACs. This changed this week, when they sent me their new Boss DAC and by happy coincidence I also had the chance to spend a few days with the Mamboberry LS DAC+.

It was showdown time.

Technology

But before I get to the interesting stuff, a few words about the technology used in RPi DAC HATs.

An RPi DAC HAT is fed audio using what is called an I2S protocol. I2S was designed for transferring audio between ICs located on the same PCB, but audiophiles have somewhat stretched its capabilities by using it to transfer audio data between PCBs and some times even between stereo components. It is considered the best, most accurate way to transfer audio data, provided that the I2S signals are properly generated. The RPi has a well-known and documented problem generating proper I2S signals. The problem has remained the same, even though the RPi is now at its 4th generation.

Right now, there exist two ways to deal with this problem:

1) Use some kind of FIFO buffer and reclocker in order to regenerate the I2S signals. Examples of such FIFO reclockers are Ian’s FIFO and allo.com’s Kali. The RPi is configured to output a standard I2S signal and then it’s the job of the FIFO buffer to “fix-up” this signal. The resulting I2S signal is of very high quality, since the FIFO buffers utilize very high quality oscillators and power supplies.

2) Run the DAC in what is called Master Mode. Let’s talk a little more about that.

There are two modes of operation for I2S compatible chips. In case of DAC chips:

Slave mode: The DAC receives all of the I2S signals (BCLK, LRCK and DATA) from the RPi. It is susceptible to jitter since the RPi’s I2S output is problematic.

Master mode: The DAC uses its on-board oscillators to generate the BCLK and LRCK signals, it then sends these signals back to the RPi which uses them to clock its DATA output. This way the RPi does not need to use its own clock, which is problematic for audio use. The end result is an I2S signal of reasonable quality.

Note that not all DAC chips can operate in either of the two modes. Most widespread is the Slave mode, in fact practically all DAC chips support it. The Master mode is supported by a small percentage of DAC chips, like the PCM5xxx series by Texas Instruments or the new ESS DACs (like the ES9038Pro). Well known DAC chips that do not support Master mode include the older ESS chips (ES9018, ES9018K2M, ES9023, etc) and the Asahi Kasei DACs (AK4490, AK4495, AK4497, etc.).

The DACs

With that out of the way, lets see our contestants.

The Mamboberry LS DAC+ is a moderately priced (54.90€) ES9023 based DAC designed to run in slave mode to the RPi. It is considered one of the better sounding HAT DACs out there.

It has an on-board high quality oscillator (by Fox) running at 50MHz (this essentially means that the 9023 is running at asynchronous mode, that is it is resampling all incoming PCM signals), very good quality LDO regulators and passive components.

It may be powered either through the RPi or by an external (preferably linear) power supply. Officially the ES9023 supports sampling rates up to 192KHz but unofficially it goes up to 384KHz / 32bit. It doesn’t really require special software support on the RPi, you just set it for “generic I2S output”.

The Allo.com BOSS DAC is a somewhat pricier (~70€) master mode DAC.

It is based on the PCM5122 DAC, powered by a top-quality LT3042 LDO regulator utilizing DC filtering by very high quality capacitors (including a 330.000uF supercapacitor!).

Clocking is done by a pair of NDK extremely low jitter and low phase noise oscillators (45.1584 & 49.1520 MHz), powered by their dedicated LDO regulator. Their output is buffered by an NB3L553 clock fanout buffer IC which further reduces the jitter.

Sampling rates up to 384KHz / 32bits are officially supported. It’s powered through the RPi, but it has an “Optional 5V battery power in connector” for future use. I suspect that this connector can also be used to power the Boss, but a certain resistor will need to be removed to isolate this power from the RPi. This DAC needs a special driver, since it needs to set the RPi in slave mode and also communicate with it via I2C to set operating parameters and utilize the PCM5122’s hardware volume control. When the DAC is receiving data from the RPi, the indicator “LED1” lights up.

The Allo.com Piano 2.1 Hi-Fi DAC is another moderately priced (~55€) slave mode DAC, based on PCM5142 DACs. Notice the plural.

On board this HAT we have two DAC chips that output a total of 4 channels. Each of the DAC chips also contains a DSP core, capable of doing equalization, filtering or other functions. These DSPs can be configured using TI’s PurePath software, but that is not a trivial task. The distributions that include built-in support for the Piano 2.1 come with a pre-built set of filters, capable of essentially configuring the DAC in 2.1 mode so that it can be used with one or two subwoofers. The analog sections of the DAC chips are powered by two top-quality LT3042 LDO regulators.

There exists no on-board oscillator, since the DACs are running in slave mode. Sampling rates up to 384KHz / 32bits are officially supported. Power is supplied by the RPi. As you can imagine, this DAC also needs a special driver, since it needs to set up the filters in each of the DAC chips plus to utilize the PCM5142s’ hardware volume controls.

A word about audio distributions

There are many audio-oriented distributions available, such as Archphile, RoonAudio, Moode and Volumio. In order to do a fair comparison, I opted to use the same distribution for all tests. The logical choice was Volumio, since it includes proper support for all of our DAC HATs.

Volumio is very easy to install and is very responsive in my RPi3. No complaints whatsoever.

Testing Methodology

The idea was to test the DACs in their default operating mode, that is with no mods and no exotic power supplies. When testing without Kali, the RPi3 & DAC were powered by a 5V 2A SMPS I had lying around from an old tablet. It’s a pretty high quality unit, made by HP. Still, at the end of the day it’s just a wall-wart SMPS.
When testing with Kali, I powered the RPi3 with the same SMPS plus I used an 7805-based linear power supply for the Kali & DAC (jumper on Kali was removed to isolate its power from the RPi’s). Again, nothing exotic. Just a relatively low power (1A max) linear power supply.

After I had an initial listen to all of the DACs in pretty much every possible combination, like “plain DAC” or “DAC with Kali” (where applicable of course) and drawn my conclusions, I thought I would take the system “on tour” to a couple of my friends and their superior sound systems. By doing this I was getting a second and third opinion. So, friend#1’s system is a full-blown MBL installation costing upwards of six figures. His main DAC & transport’s cost is in the 20K range. Friend#2’s system is a more DIY affair, consisting of big (and I mean BIG) Magnepan speakers, diy solid state power amp (several hundred watts per channel, many of them in class A, it makes a lot more than a ding in his power bill), diy preamp, Sony XA50ES modified CD player plus (on loan from me) a Soekris DAM1021 DAC.

At friend#1’s, we used an SPL meter to equalize the volume levels between all of the DACs. We listened to 3 specific tracks. At friend#2’s, we also listened to the same 2 or 3 tracks on all of the DAC combinations but didn’t take much care of level matching. The observations of my two friends were practically the same, so I won’t distinguish between them.

The Results

We started with just the RPi with Mamboberry LS. The sound was OK, not nearly what you would call “hi-end”, but considering the DAC’s cost it was more than satisfactory.
We then moved on to the RPi with the Boss. The improvement in audio quality was more than apparent. The soundstage became better defined, the instruments more clear, the bass just.. more, but in a good way.
Next up was the Mamboberry aided by Kali. Kali did more than just fix up the I2S signal – it also provided clean power to the Mamboberry. Now the Mamboberry began to show its teeth. This combination gave a more clear result than the Boss DAC, like the music became even more life-like. The bass did not have the same authority, but overall the combination Mamboberry & Kali definitely sounded superior to the Boss.
Finally, we teamed the Piano 2.1 to the Kali. The Piano was configured in stereo mode, since there were no subwoofers present. This combination gave the best overall result, giving a more “analog”, musical result. Its sound was the most smooth of all of the combinations, while at the same time it was the most life-like. You could say that it was the least fatiguing of the bunch.

After we were done comparing the HAT DACs, we thought we should listen to our “proper” DACs, just to put things into perspective. To no surprise, both my friend#1’s DAC and my Soekris properly cleaned the floor with the HAT DACs and it’s a good thing that they did – otherwise we would have felt pretty dumb having wasted so much money on so-called “proper” DACs while we could have got the same result with these DAC HATs. Phew.

So, the end result is not really surprising. The more money you spend, the better sound you will get. No giant killers here. But regarding value-for-money, I think that the Boss DAC claims the prize.

Happy π day everyone! 😀

Ideon Audio 3R USB Renaissance

OK, so this small Greek company comes up with a USB regenerator gadget targeted towards audiophiles.

They claim that it improves audio dramatically. It uncovers lost detail, enhances dynamics, etc.

We’ve heard all that hi-end mumbo-jumbo before, right?

Problem is, this time the gadget actually works. I didn’t believe it either until yesterday, when I was invited to a friend’s house. Also invited were a couple of friends and this little guy:

It was accompanied by its designer, Vasilis of Ideon Audio. Mind you, this is the same Vasilis that is behind the Mamboberry DACs.
I’ve known Vasilis for the better part of 10 years now. We have exchanged some pretty sharp remarks over the years, in regards to our shared hobby, but this time I must admit that he’s really on to something.

The 3R contains a TI chip with a low jitter clock and a bunch of LDOs. It is powered by an SMPS wall-wart (rumor has it that it works even better powered by a linear power supply).
What happens is that the 3R is detected by the PC as a USB device which essentially passes-through the DAC that it is connected to. It works like a USB hub – it’s an active device but it needs no drivers.
It works its magic by regenerating the USB signal using its own low jitter clock and low noise LDO regulators.

The end result is that the DAC manages to literally extract more detail from the music stream, be it from a PC or a Mac based transfort. It doesn’t matter what your DAC is – it will make a positive difference. We tested it with a Buffalo III dac (Amanero as receiver with no isolation) and with an Aune S16 (XMOS receiver, isolation, and FPGA doing FIFO and reclocking). In all cases, introducing the 3R into the chain made for better bass definition, more resolution, and better sound stage.

This is some upsetting stuff. This made me feel the same way I felt a few weeks back when I was auditioning Salas’ system and I could hear audible differences when we changed Foobar’s buffer length from 400ms to 1000ms. This shouldn’t happen, but it does.

I don’t know.. Perhaps this is a sign that I should switch to another hobby.

In conclusion, here is a picture of Darth Vader on the 3R:

If you have a half-decent USB dac and you’re serious about audio reproduction (a.k.a. you’ve already invested in a good sound system) you should get one. Not Darth Vader, the 3R.

STM32 Microcontrollers & Arduino

I love Arduinos as much as the next (nerdy) guy, but let’s face it, they are no powerhouses (DUE and ZERO excluded, but they discontinued the former.. go figure..).

The Atmel AVR series is 8-bit and its clock is ridiculously slow by today’s standards.

Sure, you can get it to do some things with impressive speed if you are willing to do some low-level programming but I myself do this as a hobby and thus don’t really want to deal with assembly-level code.

If only there was a fast and cheap microcontroller that was easy to program..

Enter the ST STM32F103C family of microcontrollers.

These little wonders are:

  • Friggin’ fast. 32bit ARM architecture running at 72MHz.
  • Very well equipped in the I/O department.. 2 x UARTs, 2 x SPI busses, 2 x I2C ports, etc.
  • Easy to program using the familiar Arduino IDE, thanks to the work done by the wonderful people at www.stm32duino.com
  • Dirt cheap. You can get an Arduino Nano – sized board for less than 3€ shipped.

It’s pretty easy to get started using these microcontrollers. All you have to do is buy a tiny board from Ebay. You will also need a USB to Serial adapter that works with 3.3V voltage levels (you probably already have one of those lying around already..).

These tiny boards are known as “Blue Pills” or “Red Pills”, according to the colour of the PCB. There are other variations as well, but the red and blue variants are the most commonplace. They have relatively minor differences.

This is the pinout for either one of them:

To get started, you have to connect your USB to serial port adapter to the STM32’s RX1, TX1 and GND pins. RX from USB adapter goes to TX1 (PA9 pin) and TX goes to RX1 (PA10 pin).

To make the Arduino IDE compatible with these boards, you have to download the necessary files from here: https://github.com/rogerclarkmelbourne/Arduino_STM32

You then unzip the libary to C:\users\\Documents\Arduino\hardware\ or C:\Program Files (x86)\Arduino\hardware\

At the time of this posting, IDE 1.8.0 (latest available edition) is properly supported. You will also need to install support for the Arduino DUE or ZERO from the Boards Manager, otherwise you will get a “/bin/arm-none-eabi-g++: no such file or directory” error.

If everything went fine, you should see in your IDE a number of new available boards:

You select “Generic STM32F103C series”, the 128k variant, 72MHz speed, and Serial upload method:

You are now ready to try your first code upload.

The classic test is the Blink sketch:


// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin PC13 as an output.
pinMode(PC13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

In case of the STM32 uCs, the only necessary modification is changing the pin number of the LED to one compatible with the Blue (or Red) Pill (PC13).

Pin numbers for this family of uCs are not just numbers like they are for the Arduino boards (like 1,2,3….,A1,A2,…) but are named as they are described in the uC’s datasheet (PC13, PC14, etc.).

The procedure for uploading code is a little different than the one for the Arduinos. The STM32s come with 2 built-in bootloaders. One of them boots from system memory and the other from program memory. These different bootloaders are selected by changing the position of the BOOT0 jumper. You set it to 1 to boot from system memory or to 0 to boot from program memory.

To upload our code, we do the following:

  1. Set ‘BOOT0‘ to 1. This way we will boot from system memory which contains a UART to flash uploader.
  2. Press the RESET button.
  3. In the Arduino IDE, choose ‘Upload‘. On the board, the blue LED will start to flash.

After the upload is completed, our sketch will start. We should see the blinking LED.

If we want our uploaded sketch to boot automatically after the next power-on/reset, we need to set ‘BOOT0‘ back to 0 (so that on next powerup we will boot from program memory).

That’s pretty much it. Your next step should be to go to STM32duino’s forum and check out the libraries that have already been ported to the STM32duino environment.

Troubleshooting

If your sketch fails to compile, giving you a “/bin/arm-none-eabi-g++: no such file or directory” error, make sure that you have installed support for the Arduino DUE or ZERO from the Boards Manager.

If you get an error on the IDE that it “Failed to erase memory”, that means that your STM32 chip is locked. No worries, all you have to do is go here and get ST’s Flash Loader Demonstrator utility. It will unlock the chip with minimum effort.

st_flash_loader_demonstrator_1

st_flash_loader_demonstrator_2

Blue Pill reference: http://wiki.stm32duino.com/index.php?title=Blue_Pill

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..

Controlling an AK4490 DAC with an Arduino

These days I’m co-developing an AK4490 based DAC. The aim is to end up with a no-compromise dual mono design, one that would perform at the very least on par with my Buffalo III.

Of course, to do that one has to run the 4490s in software mode.

As a matter of fact, it is generally preferred to run a 4490 in software versus hardware mode, for several reasons.

To begin with, in software mode the 4490 supports DSD decoding. It goes as far as to support a “Volume Bypass” feature which bypasses most of the processing done on the DSD signal (a.k.a. “the ΔΣ modulator”), resulting in more pure sound. But of course we do lose the ability to do volume control in software.

Software mode also allows us to try out all of the supported SQ features, like the different “Sound Setting” modes.

At last but not least, we get digital hardware volume control.

This is the prototype that we designed, getting I2S input from an Amanero and being controlled by my custom STM32 controller (more on that in the near future).

I searched the Net for any ready-made code that would control the 4490, but I couldn’t find anything worthwhile, so I began virtually from scratch.

So, my Arduino code (a.k.a. “aKduino”) enables:

  • Controlling an AK4490 through the I2C bus.
  • Automatic switching between PCM and DSD. It does rely on getting a “DSD type signal” from our USB-to-I2S interface of choice. The 4490 by itself is not capable of determining whether its input is PCM or DSD.
  • Setting the volume (in 9 steps.. just to confirm that volume control does indeed work).
  • Selecting “Volume Bypass” for direct DSD processing.
  • Selecting the internal DSD filter’s cutoff frequency (50KHz or 150KHz).
  • Selecting one of the 4 available PCM filters.
  • Enabling or disabling the Super Slow filter.
  • Selecting one of the 3 available “Sound Quality” settings.
  • Displaying all of the registers’ settings (for troubleshooting purposes).

Software Requirements:

  • Nothing (for now)

Basic Hardware Requirements:

  • Any Arduino (*)

(*) I should note here that the AK4490’s datasheet states that all of its I/O pins are expecting 3.3V logic levels but there has been a large number of reported cases of 5V Arduinos working without problems. I’m too much of a coward to try that myself so I used level converters for my initial testing and eventually a custom STM32 board that uses 3.3V logic but you may want to try your luck with 5V logic levels. Just don’t blame me if your 4490 gets damaged in the process.

Currently the code is at v1.35: aKduino Code (488 downloads)

Here is the revision history:

v1.35 20/12/2016:

  • Code cleanup for first public release.

v1.33 19/12/2016:

  • Added full control of sound parameters through serial port.

v1.27 18/12/2016:

  • First functional version.
  • Automatic switching between PCM and DSD by monitoring DSDPIN.

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.