Digital Streamer Based on a Raspberry Pi

When my old Slim Devices Squeezebox streamer died, I debated how I was going to replace it. I liked the functionality and the way the media server organized my digital music library. The server function is now called LMS (for Logitech Media Server). Before Logitech bought Slim Devices, the server part had various names, including SlimServer, Squeezecenter, Squeezebox Server, and Slimp3. (This was before products like Sonos came into being). All along, the idea was that the server was to be open-source software, with the community making periodic contributions and providing support. Most of the original developers have moved on, but Logitech has continued to provide support for an engineer to do bug fixes and issue periodic new releases. It is now in its 8th major release.

Players connect to the server over a LAN (including WiFi) and can be synchronized so that you can have the same music streaming in different rooms (or not if you want different music in each). The server can hold your personal library of music files, but also supports streaming over the internet.

It was a very nice system until Logitech decided to drop the hardware that Slim Devices had created. There were various efforts to emulate the player functionality in software (running on a computer) but that was not terribly interesting to me.

Over the years, alternative media servers have appeared, such as plex, roon, and volumio. I have no opinion on these since I have not played with them and LMS combined with Slim Devices compatible hardware do the job for me.

Then a small group of enthusiasts set about designing a hardware player that could mimic all the obsolete devices. When the Raspberry Pi single-board computer was released in 2012, that became the logical choice for a hardware platform. Combining the Pi with a stripped-down version of Linux enabled the group to begin development. Around early 2013, the group announced piCorePlayer. This required a Raspberry Pi and a DAC "hat" sitting on top, or an external USB DAC. Enhancements continued over the years, including a color touch screen and support for more DACs. It is now in its 7th major release and is actively maintained. Oh - and by the way, the software is completely free to use!

This has been great for DIYers because you can configure players in many different ways, using different DACs. In my case, I chose the Allo Boss DAC "hat" along with the Allo Isolator. The Boss is a cost-effective little D/A board with pretty good specs at a good price. It is enhanced by using the Isolator, which "galvanically" disconnects the Boss from the noisy digital Pi environment.  There is no direct electrical connection between the DAC and the Pi, neither signal with the GPIO pins nor power and ground. This assumes you use a separate power supply for the Pi and the DAC.

All the typical low-cost DAC "hats" for Raspberry Pi use the I2S serial bus for receiving the digital audio signal. This is problematic in many cases since the onboard Pi clock has a large amount of jitter. This is further exacerbated by power supply noise. Jitter causes A/D converters to produce distorted and noisy outputs. This can be removed by re-clocking the stream with a low-jitter oscillator and buffering it in a FIFO (first-in, first-out) buffer before conversion. This is similar to the way USB DACs operate using special chips from companies such as XMOS. A more direct and elegant approach for a HAT DAC is to run in what is called "master" mode, where the DAC has its own high-quality oscillator and supplies the clocking for the I2S bus back to the Pi. This is what the Boss does, so it does the conversion with very low jitter and phase noise.

Several DACs have recently come on the market which use the same approach, but the Boss was one of the first and the one I chose in 2018. 

piCorePlayer software is well documented here and the forum discussion is here.

One of the people in the Slimdevices forum posted a picture of a pi-based player he built based on a Hammond enclosure and a Raspberry Pi touch screen.

This seemed like a nice form factor, so I decided to build one of my own design.

The "Official" Raspberry Pi display is a 7" touch screen which plugs into a Pi via a flat ribbon cable. The supplied cable was not long enough to reach the Pi where I intended to place it, so I ordered a longer Pi "camera" cable. I also had to fabricate an aluminum backing plate to mount the display to the chassis with angle brackets.

This is a Raspberry Pi 3B+ single-board computer, like the one I used.

This an Allo Isolator which sits between the Pi and the DAC and provides galvanic isolation

This is an Allo Boss DAC, based on the PCM5122 chip. It also has very low jitter oscillators on board.

Since I wanted to power the DAC from batteries - for the lowest possible noise - I used a two-chassis approach, putting the power supply in a separate box. I had switches and a relay to switch the batteries (LiPo cells) between a charging circuit and supplying power to the DAC. When the DAC was running on battery, it was "galvanically" isolated from the Pi, which tends to be electrically noisy. The Raspberry Pi itself was powered from a linear regulated 5 Volt supply board.

The biggest problem I had was cutting the front of the player box at about a 10- degree angle so the touch screen would be tilted back slightly. I used a table saw with a composite blade, but there was a lot of smoke and melting aluminum.

While it worked, I did not really like this arrangement too much, since it was pretty inelegant. There is a lot of wasted space in the player enclosure. Plus, the power connectors I used were total crap, causing intermittent operation.

So the question was, how to cram all that stuff into a single little enclosure? The only way I could do it was to design my own power supply and charging circuit. This required a way to automatically switch the batteries in and out, complicated by the fact that the Isolator and DAC required about 7 Volts to operate (two LiPo cells in series) but the cells need to be in parallel for charging. So relays and a simple control circuit were required. I could have used one big 6-pole relay, but they are very scarce and expensive. The solution was to use 3 DPDT miniature power relays working in tandem.

This is the power supply schematic I came up with. The AC from the transformer is rectified by a Schottky bridge and filtered by 4 caps. The batteries are charged in parallel by a small constant current charging module which switches to trickle mode when they are fully charged.

The relays are energized simultaneously by a Darlington transistor which is in turn turned on by a GPIO pin on the Raspberry PI. This pin is controlled by the piCorePlayer software and LMS. When the player is idle, the software toggles the pin and the relays switch the batteries to charging mode. When the player is playing, the batteries will power the DAC for about 10 hours, which is good enough for me.

The schematic was created in EasyEDA, a free online PCB design and editing software package. This is a 3D view of the resulting PCB. You can use the editor to move components around and do the routing of the copper traces. Once you have the design finalized, you can download the resulting Gerber files, or send them straight to JLCPCB in China. 5 prototype boards cost about $11.00 total, plus shipping. They arrived in a week.

One thing to note: the component libraries in EasyEDA are contributed by users, and many parts contain errors, causing problems with your circuits. I had to add a wire to the board to correct this. After I used EasyEDA, I have subsequently switched to KiCad which seems a bit more powerful.

This was where I ended up. The Pi-Isolator-DAC stack in the lower right. The power transformer at the top, and the custom PCB in the middle. The rectifiers and 5 Volt regulator are bolted to the chassis bottom for heat sinking, although they do not get very warm. The battery cells are mounted on top of the display controller, which is flopped down to a horizontal position (usually is mounted on the back of the display - but I had to fabricate an aluminum panel to cover the back of the display, so there was nowhere else to place it. The back panel has a power switch, fuse holder, IEC line input connector, a USB WiFi dongle, a USB flash drive with my music library (about 250 albums), and RCA jacks for audio out. This was a lot to cram into a 1.5" high box, but it worked out OK.

The completed player (without its cover) running piCorePlayer. The VU meters are simulated video but actually work. The screen has multiple display modes, including album art covers, so it acts like a jukebox. Touching an album brings it into the playlist.

On the right is an iPad Mini running iPeng software, which gives full remote control over WiFi. This software works on any iOS device, including my cellphone.

 Recently I added a wireless remote which works over RF (another USB dongle is inserted into the Pi). It kind of works and maybe an even more convenient way to control the player, although some of the key mappings are goofy. Things like fast-forward, song skip, etc. are fine. Soon I will try a new Alexa control interface, which requires some software to be added to piCorePlayer. That should be fun.