Upgrade my HiFi with an SBC + USB audio
My old HiFi…
I assembled my hodge-podge HiFi over 20+ years. It was first put together back in the days of CD and DVD players. I eventually ended up with a NAS in the attic and a laptop for music and movies.
42” LG monitor (keep)
This was sold as “digital signage”, which means it’s just a big monitor. Its job is to display things and it does that well, so I’m keeping it.
Yamaha AV receiver (keep)
The Yamaha HTR-5630 is a nice low-profile stainless steel effect unit. It’s ~18 years old, but still sounds perfect! (You can pick one something like this on ebay for ~50 bucks!). Its job is to play sound to a 5.1 speaker system. The audio quality is great, so it stays.
Living room: 5.1 speakers (keep)
In the living room I’m using a Yamaha subwoofer and center speaker along with 4 wonderful Dali Oberon 1 speakers.
Denon stereo amp (keep)
The RCD-M39DAV is a compact 60W amp that sounds great.
Kitchen: 4 ceiling car speakers (keep)
When we renovated the house 10 years ago I installed 4 Infinity Kappa 693 car speakers into the ceiling. I pciked them because they got rave reviews, and the low impedence of car speakers allowed me chain a pair in series for each of the stereo channels. These sound great.
Laptop (goodbye old friend…)
I had an old ThinkPad T430 directly connected to the system: VGA to the screen, and RCA line out to the Yamaha amp. No surround sound. Clunky to use. It has to go.
What do I want to achieve?
Required
- Low cost (a few hundred should do it)
- Low waste (don’t throw out existing components, where possible)
- Low power consumption (ie: not a full PC or laptop, headless operation for music)
- Playback of media from a NAS or external disk
- Surround sound (wherever the media provides it)
- Invisible (VESA mount?)
- Easy to control remotely (VNC, Android app, Bluetooth controllers etc)
Bonus
It would be great if I could also…
- Play the same audio (in stereo) in the living room and the kitchen
- Stream audio to it from phones and tablets.
Failed attempts
Fail #1: Chromecast + HDMI audio extractor
Many years ago I bought a Chromecast and a HDMI audio extractor, hoping that I could ditch the PC. I thought that I’d be able to stream anything to the Chromecast, split the audio and send it to the Yamaha over an optical connection. Smart, right?
No. Feeble.
Problem: Chromecast needs the TV on. All the time.
I didn’t see this written anywhere on the packaging. It sucked. Google released an audio-only version of the Chromecast later, but that didn’t do video, and I wanted both.
Can’t you use an EDID emulator?
Tried that. It didn’t work. Maybe I got a bad one, but no matter what way I chained things together, something failed because…
Problem: HDMI compat-a-$#%king-bility
HDMI is a ~20 year old technology, and in that time it has collected lots of features (HDR, 4K, ARC, eARC) and anti-features (HDCP). Just because the HDMI cable in your cable box can connects your old amp to your new TV, it doesn’t mean they’ll work together. Even with new, expensive cables you might find that some features don’t work. So adding HDMI splitters and emulators into the mix turns the whole thing into a dog’s breakfast.
So the expensive HDMI audio splitter didn’t work?
It worked, kinda. But not how I expected it to. TOSlink optical only supports ye olde compressed surround sound formats like Dolby Digital (AC3) and DTS. If that’s what your source puts out, and your media player is configured to do “AC3 passthrough”, then everything is hunky dory, because TOSlink can relay the signal and the old amp knows how to decode it. But everything else either fails or falls back two channels (including 5.1ch AAC and the newer DTS / Dolby encoded stuff).
Yay! Kitchen audio
So this worked. It had to, because it’s such a luddite solution: I connected the MiniDisc “record” output from the Yamaha to the line-in on the Denon. The only issue is that both amps need to be on, even if you’re just listening in the kitchen.
Fail #2: Raspberry Pi, 7.1 USB Audio, Bluetooth Audio Receiver
While living with Fail #1, I thought about upgrading the Yamaha AV receiver. But the more I researched my options, the more I realised that I had to buy a lot more than a receiver. I also knew, from various forums, that this is a problem that will keep happening every few years. When you posts asking “what version are your HDMI cables?” you should worry. So I decided to forget about HDMI for audio and keep my perfectly working Yamaha AV receiver. Instead I’d use a multi-channel sound card with a low-powered computer. The Raspberry Pi 4 seemed like the perfect choice!
Components list
- Raspberry Pi 4B+ (…and extras like a cases, m2.SSD + caddy)
- StarTech 7.1 USB Audio
- Logitech Bluetooth Audio Receiver hooked into the USB Audio line-in
Yay! Kitchen audio without the Yamaha amp!
I have enough outputs on my StarTech USB 7.1 to send audio to the Yamaha AV receiver and the Denon. This means that the Denon is no longer getting its feed from the Yamaha’s MiniDisc record output, so they’re independent of each other.
Yay! 5.1 surround sound!
It no longer matters that the Yamaha can’t decode Dolby TrueHD or Atmos because mpv can! I connected the StarTech’s RCA outputs to the “6 channel input” on my Yamaha receiver, and connected the ‘spare’ side channels to the line-in on the Denon!
Uh… What about 7.1 channel stuff?
You’re right. While the 5.1 speaker test files (in a variety of encodings like HE-AAC, Dolby TrueHD 5.1, DTS) worked perfectly, the 7.1 speaker test files did not. The side channels played in my kitchen! I usually turn off the kitchen amp when I’m watching a movie, but the bigger problem is that I don’t hear those channels! But we can fix that…
Remapping the ‘missing’ side channels to the rear
After some trial-and-error I ended up with this a Pulseaudio remap configuration in /etc/pulse/default.pa.d/remap-7.1-side-channels.pa:
load-module module-remap-sink sink_name=surroundsound sink_properties="device.description='Surround Sound'" remix=yes master=alsa_output.usb-0d8c_USB_Sound_Device-00.analog-surround-71 channels=8 master_channel_map=front-left,front-center,front-right,side-right,rear-right,rear-left,side-left,lfe channel_map=front-left,front-center,front-right,rear-right,rear-right,rear-left,rear-left,lfe
set-default-sink surroundsound
This creates a virtual sink called ‘surroundsound’, which maps the side channels into the rear channels. I use this as the default sink and run those 7.1 speaker tests again. It worked! All channels were now audible in the living room, and those Dolby Atmos trailers sound great!
What about stereo music?
I figured that this would be a problem but it wasn’t. Without having to do anything at all, stereo is “upmixed” to all channels. Music sounds great in both rooms, with the exception of surround sound music like the 4.1 version of Dark Side Of The Moon. But if I’m gonna throw that on, I’ll turn off my kitchen amp and sit in the middle of my living room with my eyes closed (mmmmm…)
Problem: No sleep, no Wake On LAN
While the Raspberry Pi 4 runs under 6W, it would still be nice to turn it off or put it to sleep at night. Unfortunately there’s no way to do that. Your only options is to fiddling with cables or toggling a power switch at the wall. It’s not a deal-breaker, but ugh. Especially if it hangs for no reason.
Problem: No MusicBee (because ARM)
OH NO! I absolutely need MusicBee and have been using it as my music player for a decade. Even on Linux, via wine. Wine works on the Raspberry Pi, so what’s the problem? Well, I feel stupid for not realising this before trying it, but… wine on the Raspberry Pi emulates* Windows for ARM. Many Windows apps aren’t available for ARM, including MusicBee. Fuckity fuck. I ended up running MusicBee on a laptop and streaming the music to the Raspberry Pi using an awful hack.
*I know I know, wine is not an emulator. Why don’t you think of a better word to use and let me know.
Problem: No Bluetooth Audio
PulseAudio lets you select a profile for your audio device. To get the surround sound and kitchen audio working I had selected the profile “Analog Surround 7.1 Output”. But to play audio from the Logitech Bluetooth Audio adapter, I needed to use the profile “Analog Surround 7.1 Output + Analog Stereo Input”. Unfortunately, when I did that the Raspberry Pi froze up in a weird way… the mouse stopped moving, the clock didn’t update, my terminal froze up. I was about to pull the power, but then thought, “what if I unplug the USB audio?”. As soon as I did that, the Pi woke up from its trance and continued working. Nothing showed up in strace, dmesg or any of the usual places, making it impossible to troubleshoot. This issue wasn’t reported anywhere online. I was vexed.
Problem: No YouTube (…um, what?)
I was dumbfounded to find that YouTube, of all things, didn’t work properly on the Raspberry Pi 4. Two very annoying long-running bugs get in the way, one on Chromium and the other on Firefox:
- Chromium browser crashes when you visit YouTube link
- Firefox ESR can’t play audio on most YouTube videos link
You can fix this! You work in tech!
Yes! Maybe? Oh fuck it I don’t know! I was so very tired of having to fight with this thing, trawling forums where people helpfully suggested all the usual crap that doesn’t work: “clear your cookies!”, “restart the browser”, “install this weird browser you never heard of”. At this point my wife was in my face saying “FIX YOUTUBE! Why don’t we get to have YouTube? Everybody else does!!”. Damnit, she’s right. While I could possibly fix this by installing a totally different OS on the Raspberry Pi, that might just have unearthed yet more shit that doesn’t work. Enough of this Raspberry Pi bullshit, I’m done.
yt-dlp, DLNA and other sad hacks
To work around all of the weird brokenness I implemented a bunch of hacky solutions that only a techfool could hack together. They worked, but were so user-unfriendly that my wife wanted to stamp on the Pi. Here are some of them, so you can laugh at me:
yt-dlpis not www.youtube.com no matter how you wrap it up.- DLNA renderer (gmrender-resurrect) and BubbleUPNP are not Bluetooth.
- Some things don’t DLNA so I wrote a two-part audio transmitter/receiver for my laptop. On the sending end, it recorded from from PulseAudio, compressed with FLAC and sent the stream to the Pi using netcat. On the Pi, I wrote a socket-activated systemd service that send input to
mbufferandmpv. Cool. Laggy. Brittle.
3rd time lucky? Replace the Pi with an x86 SBC
This looks exactly like attempt 2, except that I replaced the Pi with a MeLE Quieter 3Q.There may be other x86 SBCs that work just as well. I’m just telling you that this thing beats the socks off the Pi in every way:
- You can actually buy one - no stock issues
- Modern x86 CPU with more hardware encoders/decoders
- WiFi6 (AX), Bluetooth 5.2, USB 3.1, m2.SSD, Gbit Ethernet, Dual 4K HDMI
- Fanless case that isn’t much larger than a Pi 4 case (comes with VESA mount!)
- 128GB of built-in eMMC storage
- When I run Windows apps in wine, they actually work.
- Can be powered off, put to sleep and remotely started using Wake On LAN
You might say “but the Pi beats it on price!”. Not when you factor in extra purchases (case, m2.ssd + USB3 caddy) and the hours you’ll spend putting it together and working around problems that the x86 SBC won’t give you.
Yay! Everything just works!
All of the stupid problems I ran into on the Raspberry Pi 4 were absent.
- YouTube just works!
- Surround sound just works!
- Bluetooth Audio just works! (The weird Pulseaudio profile issue disappeared)
- MusicBee just works!
- … you get the picture
Minor tweak: always play line-in source (Bluetooth)
Now that I can select a Pulseaudio device profile with line-in, I discover that I need to make one small Pulseaudio change: I need to tell PulseAudio to connect a loopback to USB Audio’s line-in. I also want to set the volume for the line in so I don’t blow the speakers out! /etc/pulse/default.pa.d/play-line-in.pa
set-source-volume alsa_input.usb-0d8c_USB_Sound_Device-00.analog-stereo 33500
load-module module-loopback source=alsa_input.usb-0d8c_USB_Sound_Device-00.analog-stereo latency_msec=1
You can experiment with the source volume. I picked 33500 because it matches my other sources.
Extras: KDE Connect, VNC, MusicBee Remote, Kodi Remote
I set up my tablet to control everything on the MeLE device. I can wake it using this app. KDE Connect can:
- Run pre-defined commands (start an app, power it off)
- Control media players and sound volume
- Function as a keyboard and mouse, all using [KDE Connect]
For much better control over MusicBee, there’s a dedicated MusicBee Remote app for android which lets me browse playlists, queue up tracks, rate them etc.
Same goes for Kodi, whi has the Kodi Remote
This whole setup is now an absolute joy to use, and it’s 100% wife-friendly. As an extra bonus, the tablet is paired to the Logitech Bluetooth Audio adapter. This means that audio from any app (eg, audiobook player) on the tablet comes out on the multi-room system.
Fin
I just want to finish up by saying that I don’t hate the Raspberry Pi, now that I’ve plugged it out and put it away for some undiscovered future use. But I’d never recommend it for building a home entertainment system. I’m sure some people get good mileage from things like the Chromecast, Roku, FireTV etc, but google “Dolby” along with any of those and you’ll find that surround sound comes with a lot of caveats, eg this Roku forum post. So if you’re thinking about using a tiny computer to modernize your ancient HiFi system, I seriously recommend that you consider using an x86 SBC device instead of a Raspberry Pi. And those StarTech USB Audio devices are badass.