Custom DietPi OS For Raspberry Pi 4 Audio Streamer

Hello,

I started using Moode Audio a few years ago and was always blown away by the difference between a dedicated Pi Streamer (with moode at that time) and my normal desktop pc... this is also where my "audiophile" jorney kinda began, things in the OS and on the hardware seems to really to matter
And while Moode Audio is a kinda good out of the box expierence, it really lacks the ability to be customized (you can do it but updates could break things you changed for example and there is always a limit of how much you can do and stay combatible with existing things)

I also looked at Volumio... but it never apealed to me, specially since i also heard the worse SQ as many others people reported
SqueezeBox/PiCorePlayer also never really appealed to me but i actually never tried it, i just never was a fan of LMS since it looks and feels kinda outdated

I recently started using DietPi (after trying to run Arch Linux) and i think its one of the best OS bases for the Raspberry Pi 4, you stay completely in the official "Raspberry Pi OS" realm but with benefits that DietPi brings via minimalizing the OS and their scripts
I currently just use the DietPi OS to use the raspberry pi 4 as "Audio Gadget" and CamillaDSP to route the audio from usb input to the dac output (this also sounds better then going directly from PC to usb input of the dac, this way you can also use RPI4 hats and use the RPI4 as "DDC" for your PC, which will be one core feature of this custom os)

Soo... now to this thread, while it would be great to make a own streamer os image from the ground up and share it with others this is way out of my comfort zone, so what i actually wanna do here is document my journey of tweaking the dietpi os to my liking and needs, so other users may get inspired or even try to help build with me the perfect streamer OS

i wanna document each step so that it would be easy for others to actually replicate the exact OS im using (well and for me in case something goes wrong, haha)

So what goals do i actually have?
1. being able to use the raspberry pi 4 as DDC for your PC
2. use the raspberry pi 4 as standalone player (basicly what moode/volumio does) for possibly best quality (tho from my tests using the RPi4 as DDC isnt far off if not identical!)
including for example cd support and dlna support
3. keep the OS as minimalistic as possibly
4. try to find the best software for each "step" (for example one huge step up for me was using linear phase EQ inside EasyEffects instead of other IIR solutions like CamillaDSP)
5. tweak the OS itself for better SQ (for example underclocking the RPI4, maybe trying realtime kernels later and so on)

i did got some inspiration by "GentooPlayer" and one thing that really intrigues me is the script-server, it could be used to offer install scripts (and other things) of the software i use to make things way more userfriendly (install dietpi, install script server, get my config files and go from a nice web interface 🙂) this seems way less hassle then building a own OS image too i think

What you guys think about this? would some of you interested in such a custom OS ?
 
Depending up how far you want to go with this project, you may want to look at the VitOS by Silent Angel. You can read about it here. I use it exclusively as the USB bridge from my RPi streamer and commercial DAC.
thanks i didnt know this OS yet
but ready made distros just never seem to offer the flexibility i need

for example, im thinking about integrating pipewire and either carla or easyeffects for a linear phase EQ (and stuff like crossfeed, pitchshifter etc VST plugins seem to be the best option here)
pipewire also offers some network protocols so we could use the rpi not just over usb but over the network too

im not 100% sure yet but thats definitely a option i consider currently
 
Today my Ian Canada TransportPi Digi arrived, really pleased with the soundquality over toslink compared to USB, i also tried a Accusilicon clock, definitely a improvement but without burn in i would say the improvement is around 30% of that what the transportpi digi does on its own compared to USB connection (i use a Aune X8 XVIII Dac, which is kinda important to know since the transportpi digi replaces the clocks of the dac)

---

maybe a bit of talk about my ultimate goal with the DietPi OS:

i wanna build a DDC for my PC setup in the first place, the first important thing was to switch over to Linux and use Pipewire, this seems way more transparent then the Windows audio mixers

Using the RPI as "DDC" (and configuring the RPI as "Audio Gadget" which lets you route music from the Desktop PC over USB to the RPI) is just a cheap way of utilizing the Ian Canada hats for use with PC/as a DCC , which really seems worth the money after testing it, i think its the best SQ i got so far out of the PC

this is one main goal of this setup, being able to use all kind of programs on your PC with high quality playback (just think about watching videos on PC, over Kodi etc..) with low-ish latency... its not perfect but i think it can be tweaked to 100-200ms latency, maybe even lower but its not that critical for me unless i notice some heavy lip-sync issues, which imo is not the case with 100-200ms latency

while the pc playback already sound very good, can we improve of it? maybe/probably, i dont think there is much to gain but i have to test

im currently also oversampling with pipewire to 176,4khz, this a area i think improvements can be done, there are definitely audible differences between resampling implementations (but keep in mind, for me oversampling in good-ish quality is definitely a improvement over native samplerate, specially with CD quality...

while im not 100% yet since its kinda expensive but i think the ultimate way to improve SQ, if there is any SQ to gain, is using hqplayer and the raspberry pi as NAA (network audio adapter), basicly as endpoint, this would bypass most of the setup that needs to be done to use pc playback over usb over the rpi

this actually made me think of the goal i wanna approach, and its not building a highly featurerich streamer, which is nice on its own too but my goal is to build a "Minimal" solution and i think the "endpoint-approach" is in line with what i ultimately want to do/have

Question here is, do people wanna try this? i could try to implement different endpoints.... LMS/Roon/Hqplayer are all options, DLNA would be nice too but it seems a bit more tricky to implement, i would probably need to install MPD for it to work even if we dont use the MPD player functions

tho for me the ultimate endpoint would be definitely hqplayer which might be my first priority to get working, its also way cheaper than a chord mscaler or roon for that matter

while i would use the RPi just for PC Playback and as hqplayer endpoint (probably, im not 100% yet) i would definitely consider implementing other endpoints if people are interested
 
i tried to find a solution for a good somewhat painless setup and i think a script with whiptail as "TUI" might be a good solution

there are certainly other ones, a web interface like volumio/moode for example, but it needs more skill (which i dont have) to make and it also has more overhead which i try to avoid
DietPi comes with SSH out of the box so why not utilizing it

best case scenario would be installing dietpi, copying my script, go over some points in my script (like installing different software and "manage" them, like including paths to config files for manual intervention without searching for files and also do a inital config that just works) and you are ready to go

one point i definitely will look into is also custom kernels and other stuff that was talked about in https://www.diyaudio.com/community/threads/path-to-noiseless-linux-streamer.391202/

Features im somewhat certain i will include are:
  • My setup/manage script
  • Custom kernels
  • USB Gadget (you basicly can hook up a PC over USB for Audio and Ethernet at the same time)
  • CamillaDSP (its needed for the USB Gadget to work, it routes audio from usb gadget input to dac output, without any resampling/buffer underruns, other solutions struggle with this)
  • HqPlayer NAA
  • modfied /boot/config.txt and /boot/cmdline.txt (which you can apply/tweak/change trough my script)
  • tuned-adm (its a program that lets you tune your system a bit further without really having much knowledge of the underlying stuff)

and thats kinda it, personally i dont need more and i wanna keep this as minimalistic as possible
i havent looked into custom kernels/hqplayer/my script yet but this setup works great otherwise so far

if people want i can include other things like a Roon endpoint or DLNA/Airplay later on

proof of concept definitely works to basicly use the rpi as DDC with a hat for your PC, sound quality was even slightly better then directly connecting to the PC, which was my goal (and this also shows that the additonal routing trough the RPI is transparent if done right) and my guess is that if you isolate USB the RPI produces less noise then a convential PC, i might look into other usb connection solutions like some of these optical usb cables but my goal with this setup is to basicly make the differences the desktop PC has non existent, there is no need for a expensive music server anymore, and it still allows to use all outputs of your pc eg for videos/youtube/games etc

remember: the data from usb/pc is fine, the reason why usb cables and tweaks on the RPI (or on a music server directly connected to your setup) matter is mostly about noise imo but this is a much cheaper solution then investing heavly in your music server

while the difference from host pc usb to rpi usb was a slight improvement, what really made a quite huge improvement was to use the ian canada transportpi with upgraded clocks, this setup lets you utilize those hats as DDC which potentially improve your dac because you can use better clocks
 
Hi. I've also just received Ian's Pi Digi and PurePI and have yet to setup into my new RPi4. I also have an Aune X8 XVIII with its linear power supply and Sparkos Pro opamp. I'm also planning to use DietPi although I want to try Libreelec First as I want to play videos and tv with the DVB hat.

You say you want to build a DDC with your RPi, camilla DSP software and your newly arrived Pi Digi. My question is: Isn't it easier to stream DLNA from your PC via Foobar2000 UPnp controller plugin instead of feeding USB to your PI and re-routing to Digi's Coax?
 
You say you want to build a DDC with your RPi, camilla DSP software and your newly arrived Pi Digi. My question is: Isn't it easier to stream DLNA from your PC via Foobar2000 UPnp controller plugin instead of feeding USB to your PI and re-routing to Digi's Coax?
the problem with upnp is that it adds latency, its not possible to get good "lipsync" for videos on your PC, for music its fine tho
i think upnp has usually 1-3 seconds latency, this is kinda annoying if you wanna watch movies

with usb connection i get around 200ms latency consistenly, no hiccups whatsoever, and i also use quite high buffers in camilladsp (on the pi) and pipewire (on the pc host)

i might add network protocols later on but these will probably require pipwire on the PC, but these network protocols also have better lipsync/latency then Upnp

imo a usb gadget is the best solution to use rpi hats as low latency ddc`s

but if people are concerned about SQ over the usb connection (my test showed that its fine tho, there is no degredation) a step up would be using the rpi as endpoint for hqplayer for example, this should really give you the best SQ possible, specially if we talk about resampling where hqplayer is king
 
I see. If you are playing both video and audio from your computer the solution is an audiophile USB card like this from Matrix Audio. It has its own femtosecond XO clocks, and external supply support for cleanest USB data, similar to Pi Digi. I think it might be worthwhile when USB is your source.

This way you can play native DSD512 to the Aune X8 and up to 768KHz PCM sampling rate.

As a curiosity, I have my Aune X8 connected to both optical and USB to my tv. Both sound different, optical sounds better but I have micro dropouts due to tv's high jitter. Usb sounds drier, and I'm using a good short cable. I'm sure it's due to the tv bad clock and jitter. If you use a good card like the Matrix Audio you may get the best performance of your Aune. Eventually the clock that converts to analog is the Aune internal one, however the better the source clock the better sync they'll have. SPDIF source clock doesn't replace Aune internal clock, it still has to sync to it.
 
Last edited:
If you are playing both video and audio from your computer the solution is an audiophile USB card like this from Matrix Audio. It has its own femtosecond XO clocks, and external supply support for cleanest USB data, similar to Pi Digi. I think it might be worthwhile when USB is your source.
im kinda curious how the usb card sounds but imo spdif sounds way better then usb and i already have a galvanic isolator (topping hs01) + usb filter (ifi isilencer)

i was considering a usb card before but they cost way more money, they start at 350€ i think and more expensive ones go for 800€ also dont forget how pricey good usb cables are
this is more of a guess but from what i heared a 130€ ian canada hat blows usb away, no matter how many tweaks you use
a DDC also gives more isolation to the PC i think, just think about toslink or even coax is usually galvanicly isolated on both(!) ends

i ordered supra trico cable + silverplated tellurium chinch plugs which im still waiting for to compare coax to toslink, since many people say coax sounds better then toslink
 
Yes, I also think 350€ is kinda expensive for what it is.

Beware of additional gadgets that can introduce more harm than good. Galvanic isolator has a power generator chip with a data clock to sync on its own and some latency. Go figure what the Ifi Silencer does.. The usb best transport IMO is the simplest, the Matrix card with a external power supply.

In theory, when done right, USB should be as good as Coax. If you really play from a computer, I think you should try one.
You can opt for the Pink Faun SPDIF transport card for pc, for a similar price.

I, for one will run my Pi Digi as a A/V transport for my TV and hifi setup, Kodi Libreelec for tv and media and DietPi for DLNA. I don't run anything special on my pc.
 
Last edited:
Beware of additional gadgets that can introduce more harm than good. Galvanic isolator has a power generator chip with a data clock to sync on its own and some latency. Go figure what the Ifi Silencer does.. The usb best transport IMO is the simplest, the Matrix card with a external power supply.
well the galvanic isolator + ifi isilencer actually improved things, so i dont think they do "harm" necessarly but you are kinda right
tho with usb its strange... usb ports (and usb hubs) matter, usb cables matter etc this just shows how fragile usb is imo

also the matrix card is just another usb hub with external power from what i know... i dont believe that it will be a good "endsolution", its imo just another flavour of USB SQ in a whole range of SQ changes, you may like it or not but i dont think its "all you need"

In theory, when done right, USB should be as good as Coax.
"in theory" seems to be quite often different to reality, from what i heared toslink sounds way different (smoother imo, where usb sounds more "on the edge")

You can opt for the Pink Faun SPDIF transport card for pc, for a similar price.
i actually didnt know that pink faun also makes spdif cards ... but two things to think about...
1. it doesnt have exchanable clocks
2. it still sits in a very noisy PC, unshielded as it looks

I, for one will run my Pi Digi as a A/V transport for my TV and hifi setup, Kodi Libreelec for tv and media and DietPi for DLNA. I don't run anything special on my pc.
ah i get it, this custom dietpi os i make will be mainly for pc use, where you can also for example install kodi on the PC with no problems

---

what i still need to investigate is, since the rpi is connected over usb, how much the usb still matters in this setup, tho from what i heared so far its because of the xmos chips in dacs are kinda crappy at their job
 
whati still need to investigate is, since the rpi is connected over usb, how much the usb still matters in this setup
usb maters as much as spdif does: clear signal and stable clock. If you feed a good usb signal, the XMOS chip and the dac's clock will sync bettter.

I wouldn't connect the noisy pc usb to the PI, because you mingle with a dirty signal to begin with.

I would get a dedicated usb card with good XO clocks and external power. The pc bus noise doesnt matter as much because the usb card regenerates it.
 
usb maters as much as spdif does: clear signal and stable clock. If you feed a good usb signal, the XMOS chip and the dac's clock will sync bettter.

I wouldn't connect the noisy pc usb to the PI, because you mingle with a dirty signal to begin with.

I would get a dedicated usb card with good XO clocks and external power. The pc bus noise doesnt matter as much because the usb card regenerates it.
idk, like i said i still need to investigate how much usb matters in this setup but if you ask me the real culprit that makes things "fragile" are the xmos chips inside dacs/ddc, not usb itself

also i dont believe that the usb cards are "perfect" by any means ...they dont even implement galvanic isolation...

and well fact is, ian canada hats sound vastly different (better imo) then usb and this audio gadget setup is the only way to utilize them for PC use
 
Well, if you power the usb card with a linear power supply, the transformer inside it actually provides galvanic isolation.
since they dont advertise galvanic isolation ground is most probably directly connected to the PC or usb handshaking wouldnt work

also im unsure where the injection of the plus pole of the external power supply happens, worst case would be that its just injected into the cable and the whole card is still powered by the PC
 
You have a switch to disconnect Vbus power after handshake.
They dont advertise galvanic isolation because it'd be externally powered and replaces pc power.
The card switches to its power filters when pc powered, nonetheless. But all that matters is that clocks are precise and data bus is clean. The only 'dirty' signal it'd take is data bus from pc, but that is replaced and regenerated by the card.
 
the switch probably just disconnects vbus, but not ground from pc
well its kinda hard to believe that "the clocks are precise and data bus is clean"
"regenerated" is a fancy word for a usb hub with better clocks

many people are happy with these cards but imo they dont make usb "perfect"


either way, we can continue to discuss but for me the rpi route (in combination with a good ddc hat) is the best solution i found so far
 
If you use a external supply, the ground is taken from the it.
PI Digi also 'regenerates' the signal from noisy RPI gpio.
PiDigi is good, I've bought it myself. But doing a DDC with a PI and a software mixer/router it is not an orthodox way to do it, because you begin with a 'bad' signal from the PC, and you are not 'cleaning' it only mixing.
 
If you use a external supply, the ground is taken from the it.
thats not how usb works, either you galvanicly isolate ground or you still need a ground connection to the pc to make usb even connect to the device

But doing a DDC with a PI and a software mixer/router it is not an orthodox way to do it, because you begin with a 'bad' signal from the PC, and you are not 'cleaning' it only mixing.
try it yourself or trust me, the data itself is fine(!), there is no real need for reclocking to get "good data" from usb

i was thinking kinda like that first too... since you complicate the audio chain like this but i tried it anyway and going through a pi actually sounds slightly better with a untweaked usb connection then directly connected to the pc, this shows me that there is no degredation but a slight benefit since the rpi "isolates/decouples" the noisy pc in some ways from the dac

like i said before i suspect the xmos chip implementation of dacs/ddc to make things way more susceptible to reclocking/usb cables etc

while there was a slight benefit rpi usb vs pc usb ... the rpi hat actually made it really easy to hear a huge improvement compared to usb

just to show you what i tried... i recently switched from windows to linux to use pipewire... that made a good improvement compared to windows too
with pipewire there is no need for ASIO/WASAPI and circumstancing the windows resampling since pipewire is able to route music without any resampling
Also pipewire allows for way higher quality resampling and resampling to 176,4khz/192khz for CD files actually made a improvement too (i have the same dac as you, aune X8 + burson V6 Vivid opamp, so i can just suggest to try (good implemented) resampling, windows resampling is not one of them tho)

On the Pi side you are also able to route music from usb input to dac output without any resampling with CamillaDSP .... the audio data arrives in the same state it left the PC, there is no real need of reclocked usb data since the pi itself reclocks/buffers the signal
you have to understand that usb just sends data, the xmos chip might be susceptible to this but linux/the rpi just buffers the arriving data to one complete stream

its hard to believe but the sound i get from my pc now never was better (!) but you have a good point there... im unsure if you use windows if you can use the audio gadget (RPI) trough ASIO/WASAPI, ASIO most probably not since it needs special drivers but i think WASAPI will work,, i havent tried it tho

imo also software mixer vs hardware mixer is not "really" a issue unless you turn the software volume "way" down+
there is no degredation with software mixer ... the only thing you are "potentially" missing out on is dynamic range but if your pc processes data in 24bit/32 bit ... and the pi is able to do this too then even dynamic range isnt a issue here

i know "bitperfect" purists will disagree but the benefits i get from this setup even with software mixer on the PC is way better then any direct usb connection i had before, trust me or try it yourself ones my script is ready 🙂
 
  • Like
Reactions: wyup
i actually started today to write the menue of my script, with whiptail as a command line UI it was kinda a hassle to get working like i wanted it to be
so i started doing it as command line only tool which made things way easier to implement like i want to

for example i wanted to implement shortcuts to config files, so in my script you just hit the option to configure config file X and it automaticly executes "sudo nano "path to config file"" so a easy way for users to keep tracks of config files (which is not really necessary to get things working but might be useful for "powerusers")
this was way harder to implement with whiptail, since its hard to get rid of the whiptail ui to show you nano once the script is running, i believe there are ways to make it work like dietpi does with there scripts but dietpi also uses 4000 lines of code for one of these scripts 😀
thats why i opted for the command line only option to make things easy on me ... its actually the first time for me to make an bash script so bear with me x)