Wednesday, January 10, 2018

Raspberry Pi - The Audio Engine - Part 1 - Introduction

Since 2013 I'm using and working with the Raspberry Pi and contributing this or that to the community.

The Raspberry PI family is by far the most successful single-board-computer (SBC).
Even if its base hardware can't be considered top notch, it can very well serve the purpose
of becoming a serious audio transport.

What makes a device like the RPI a success story is its wide market presence,
great and innovative SW (community) support and OEMs flooding the market with
all kind of (quality) gadgets.
Many other SBC companies failed to succeed (beyond becoming a niche product), because they were not able comply to these factors - even providing a potentially much better HW base wouldn't help.
Building HW is a one-off effort. Without SW these devices are worth nothing. 
Providing, evolving and maintaining SW is a continuous process over a long period in time. 
That's what many manufactures underestimate! And that's why they usually fail.

The challenge

Taking  a rather mediocre device (HW) like an RPI and make it a high quality audio transport.

With this article I'd like to give a little guidance to get you going.


The hardware I'm currently using is:

* Raspberry PI3
   I use the PI3. It gives me maximum flexibility and the best HW specs in the family.

* Allo Kali (I2S reclocker)
   I2S quality delivered by the RPI is rather poor. The I2S reclocker is the ticket into quality
   audio from RPI. With such a reclocker in place you'll achieve quality levels as known from
   highest quality USB-I2S interfaces!

* Allo Piano2.1 DAC (dual-mono mode)
   Kali+Piano2.1 in dual-mono mode can beat the Allo Boss. IMO It's worth trying!
   (I tried several other (DIY-) audio HATs and also USB DACs)

As power supplies I use

* 2x iFi iPower 5V (1 for the RPI and 1 for the Kali + DAC)
   (I also added some buffer capacitors to the power supply rails)
   (I did try high quality "linear" supplies as well. Just to mention it!)

Further I've a special HW setup for the network as described in my related articles.
If you're willing to walk the extra mile, don't miss that exercise!

All this IMO makes a very nice audio base. Of course you can choose whatever you want.
Above setup is the result of several projects I ran (in public on DIY-Audio).
There are numerous options out there. BUT. Make sure that a DAC is "fully" 
supported by any OS before you buy it! Preferably supported by more then one OS!!!!!!

HW alone won't make a great transport!! It'll be a combo of HW and ...


First you need to find the right operating system (OS). Meanwhile you'll find numerous
OS images that you just copy to SD card and you'll - almost - be set.

There are several feasible audio OS options for the RPI:

* Archphile (Arch Linux, MPD)
* DietPi (Debian, MPD, squeezelite)
* Moode (Debian, MPD, squeezelite)
* PiCorePlayer (TinyCore, squeezelite)
* Rune (Arch Linux, MPD)
* Volumio (Debian, MPD)
* and more

The differences between all of them are not earth shattering. Don't let you fool by marketing terms like "...phile..." or "" . Do I have to save a couple of  hundreds MBs of storage space, if I can't buy SD cards below 16GB anymore? The maker of Archphile tells us that he can't hear any differences no matter what "tweaks" he's building into his OS!?!?
Bottom line. You can try them all. There's absolutely no reason arguing about which one is better.
All the folks behind these packages do a great job in spending very long hours free of charge to build these packages.
If it takes you 1 "annoying" hour to get going, it took them 1 year to get you there! 

My OS of choice would be the one with the most up2date kernel and up2date SW packages
incl. gcc the compiler! Yep. There are tiny differences. The cream of the cake.
piCorePlayer is doing quite well on that account. pCP also offers an audio optimized low latency kernel and several special audio card drivers.

Moode, Volumio and DietPi are based on Debian/Raspbian. Debian is known for not coming with the latest SW. Rune and Archphile are doing better by using ArchLinuxArm as base. ArchLinuxArm is a rolling release. Basically you get latest SW with every update. And it's also quite stable.
But that doesn't necessarily mean the OS of choice delivers these updates to you too!

I go for an OS that offers squeezelite as audio engine.
Logitechmediaserver plus squeezelite IMO is by a large margin the best streaming solution out there.
It is flexible, it is opensource, it is highest quality, it is widely used, it is actively supported and it is free. Not to forget, there are plenty of apps on iOS and Android available as remotes. NO. I'm neither a fan of MPD based systems or even worse UPNP or some other wired Windows originated solutions.

This and some other factors than boils the list down to piCorePlayer, Moode or DietPi.

From that list I'd prefer piCorePlayer - as a (almost) perfect base for a single purpose Audio streaming engine.

piCorePlayer (pCP)

It's basically a single purpose OS - an audio streaming OS. 
pCP is a very, very slim OS. It requires less then 100MB.
The underlying OS (TinyCore) is a real "diet" OS.

It's greatest feature: 
pCP fully resides in RAM while up'n running.
There'll be no SD-card interaction during operation!
And still, on a PI3 we've got plenty of RAM left for our streaming task.

pCPs base OS (tinycore), makes it difficult to tweak though. However.
The pCP folks offer some tools 
to do some tweaking. I'll come back on that later.

pCP offers squeezelite as main audio engine. All what's needed to get going. 

pCP also offers LogitechMediaServer (LMS) as optional package for the RPI. 
You just have to enable it. And it'll work.
It's slow. It adds quite some extra load and noise. The lag on the remote apps are awful. 
A rescan of the database with several thousands tracks takes ages. If you then want to support multiple clients from that server, things get funny. 

If you look for a serious and powerful server performance, you better use your/a PC as LMS server.
I'm using a Broadwell NUC as Linux server. I also use the NUC as my day2day desktop machine. To be honest I would not recommend a NAS server. Running Windows and OSX
servers would never be my first choice either. There's a reason why the entire server/cloud world is based on Unix/Linux systems. 

Let's continue with piCorePlayer.

I'll skip the basic SD-card image installation procedure. Downloading and writing an SD-image to an SD card should be a known to most readers. There are also numerous guides out there how to do it.

NOTE: Make sure you download and install the "Audio Optimized Version" of piCorePlayer.

Let's start shaping up your Audio streaming engine step by step:

Part 2: piCorePlayer settings
Part 3: squeezelite and DAC settings
Part 4: pcP Advanced Tuning Measures 
Part 5: Building a tailored squeezelite binary
Part 6: DSD - DOP and native (applicable to upcoming pCP 3.5)
Part 7: Realtime kernel (work in progress)
Part 8: Network Dongle
Part 9: Hub Control

No comments:

Post a Comment