• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Using OrangePi Zero2 as an equalizer between USB source and USB DAC

IAtaman

Major Contributor
Forum Donor
Joined
Mar 29, 2021
Messages
2,461
Likes
4,338
For roughly $30, half an hour of your time and some opensource freeware, you can get a USB in USB out digital equalizer that you can use with any digital source and DAC.

There are quite a few options out there for hardware and software choices, but the one I personally find most convenient and easy is OrangePi Zero2, Armbian, CamillaDSP combination. Here is a rough reference guide on how to make that combination work.

@DeLub has written a very nice guide as to how to use RPi for the same purpose, and this reference is very much inspired by that guide. The reasons why I prefer Orange Pi Zero2 to RPI alternatives are:
  • its much cheaper, more readily available and much less of an overkill than both RPi 4 or RPi 5.
  • it does not require any additional hardware to seperate power and data in as it can be powered by the digital source it is connected.
  • it is relatively smaller, consuming less space on the desk physically.
RPi has the massive advantage of having current and future software support, so when there is a future kernel update, RPi will most likely get that. That might be the case for Armbian Pi Zero2 maybe, but it is not a given. If you find that more important or the advantages Pi Zero2 is not attractive to you, then definetively check out DeLub's guide here.

A few disclaimers before we finally get started so that I don't get Tektoned later on:
  • I am not a Linux expert. Not even close. If you can think of a better way of doing something, please let me and others know. No offense taken.
  • All of this is provided as-is without any guarantees, try it at your own risk.
  • I do not have any affiliation with any ecommerce platform and the links are NOT affiliate links. I refered to Aliexpress and Amazon as they are readily available and widely used all around. Feel free to buy the hardware wherever you want.

Back to the topic on hand...


Hardware
For starters, you will need an Orange Pi Zero2 and a Micro SD card.

Aliexpress link I used to buy the OrangePi Zero2 is here. You can use that or search on the site - there might be better offers at the time you are buying. Amazon might be offering Zero2 where you live as well. Please note this is tested with Zero2 only, and might not work with Zero2W, on the account that Zero2W does not seem to have OTG support. Here is a reference image of what you want to buy for sake of good measure.

1712999979307.png


For micro SD card, anything larger than 4Gb should do the trick I think. I use SanDisk 32Gb ones for these tasks as they are easy to find and cheap - even cheaper than lower capacity ones currently. They are $7 a piece on Amazon now.

You will also need a cable to connect your source to Pi Zero2, and another cable to connect Pi Zero2 to your DAC. I am assuming the DAC cable came with the DAC, and you'll have a USB A to USB-C cable lying around anyway. If not, you need to buy them as well.

You might also need a micro SD Card reader if your computer does not have one. Any reader that is compatible with the computer you use will be fine.

Finally, you will need to use the screen for the inital config of Armbian, and you will need a mini HDMI to HDMI (or DP if that is what your monitor uses) cable to be able to connect the Zero2 to a monitor. This will only be required once during install time, and maybe later on if for a reason Zero2 is no longer connected to your Wifi. Otherwise everything else can be done via ssh from your main computer, be it Mac, PC or Linux.

Optionally, you can also get a tiny aluminum heatsink for the tiny H616 SoC. You don't need to as we will not be even close to sweating the processor, but you can If you want. Dimensions of the SoC is 14x14mm (that is 0.55x0.55 in freedom units). Here is a link to a random one on Amazon.

And that is pretty much all the hardware required..


Software
For this to work, you will basically need 3 pieces of software - a stable operating system, a DSP software and a way to control the DSP.
For operating system, I used Armbian available at the link here. It is a recent kernel at the time of writing (6.6.16), work headlessly (is that a word?) and is quite lightweight. I use Jammy. Bookworm should also be fine.

You will need to download and expand the image, and burn it on the micro SD card. I personally use BalenaEtcher to do that, but any software will do fine.

Once the image is on the SD card, plug it into Zero2, connect it to HDMI, to your keyboard and to power, and boot it up. Once you configure some basic info, Armbian should be good to go. It will also help you connect to your WiFi so make sure you got your WiFi password ready. Once its all configured, check your ip address with ip a and you can disconnect the keyboard and HDMI. Rest can be done via ssh from your main computer.

Edit Note:
With CamillaNode v2, there is a much simpler way to do do all these to install both CamillaNode and CamillaDSP. Check out this post from later down the thread.

For DSP, I am using the wonderful CamillaDSP. There are other options out there, but none better I think.
@mdsimon2 has a amazing tutorial on how to install CamillaDSP on RPi4. Here is the link to that. I would recommend you to read that as it is a great reference for anyone who is interested in these topics.

For the rest of this basic reference, I will explain what I did to make CamillaDSP and CamillaNode work. I will bulldoze over and omit many details and options to make reference as simple as possible. If you want to make different choices, please ask and I, and most likely others, will try and help as much as we can.

Before I forget, CamillaNode is written by me. It is one, a non-offical way to control CamillaDSP, specifically built to function somewhat similarly to Peace. CamillaDSP also has an official UI which mdsimon2 expalains how to install as well, if that is what you prefer. For my use case, I obviously prefer CamillaNode.

Enabling USB Audio Gadget
Open modules file with the text editor with sudo nano /etc/modules and add g_audio to the end of it it before saving and closing. Basically this will ensure that g_audio module will be loaded at boot time.

Create a text file with sudo nano /etc/modprobe.d/usb_g_audio.conf , add options g_audio c_srate=48000 c_ssize=4 and save and close it. This sets the sampling rate to 48KHz and bit depth to 32bits.

That's it. Reboot and check if all is fine with arecord -l. You should see something like this:
Bash:
**** List of CAPTURE Hardware Devices ****
card 0: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Installing CamillaDSP
Create a camilladsp folder, download the app and extract it to common binaries folder:

Bash:
mkdir camilladsp
cd camilladsp
wget https://github.com/HEnquist/camilladsp/releases/download/v1.0.3/camilladsp-linux-aarch64.tar.gz -P ~/camilladsp/
sudo tar -xvf ~/camilladsp/camilladsp-linux-aarch64.tar.gz -C /usr/local/bin/

Important! Currently, CamillaNode does not support CamillaDSP v2.x. I will update it so that it will in the future. As I prefer to use CamillaNode as the control interface, I am still using 1.x version of CamillaDSP. If you do not intend to use CamillaNode, I recommend you to use the latest version, which is 2.0.3 at the time of writing this. In that case replace the URL for wget above, with the URL below:
Bash:
https://github.com/HEnquist/camilladsp/releases/download/v2.0.3/camilladsp-linux-aarch64.tar.gz


Create a camilladsp.service file to start CamillaDSP at boot time:
Bash:
sudo nano /etc/systemd/system/camilladsp.service

Copy paste the below text. Do not forget to change the USERNAME with the username you have created when installing Armbian.

Rich (BB code):
[Unit]
Description=CamillaDSP Daemon
After=syslog.target
StartLimitIntervalSec=10
StartLimitBurst=10

[Service]
Type=simple
ExecStart=camilladsp /home/USERNAME/camilladsp/default.yml -g-6  -a 0.0.0.0 -o  /home/USERNAME/camilladsp/camilladsp.log -p 1234
Restart=always
RestartSec=3
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=camilladsp
User=root
Group=root
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=10

[Install]
WantedBy=multi-user.target

Enable the service so that it automatically starts at boot time by systemctl enable camilladsp

This assumes you have a default.yml file in /home/USERNAME/camilladsp folder which will be the config file on startup. It enables the websocket server on port 1234, and binds it to all network interfaces so that you can access it via your home network as well. It also creates a log file called camilladsp.log so you can check what is the problem if something goes wrong, and starts CamillaDSP with -6dB volume filter, because we all forget the bring the volume down when we turn off stuff at times.

You can find more info on what each parameter does on the CamillaDSP github page linked.

Default config file can be created with sudo nano /home/USERNAME/camilladsp/default.yml and contains the following text:
Rich (BB code):
devices:
  samplerate: 48000
  chunksize: 4096
  enable_rate_adjust: true
  capture:
    type: Alsa
    channels: 2
    device: hw:UAC2Gadget,0
    format: S32LE
  playback:
    type: Alsa
    channels: 2
    device: hw:Pro
    format: S32LE

One thing you will need to change (unless you are using D30 Pro that is) is the device: hw:Pro part in playback section.
Connect your DAC to the Zero2 via USB, make sure DAC is on and USB input is selected. Then check the device name with aplay -l

Mine looks like this:
Bash:
**** List of PLAYBACK Hardware Devices ****
card 0: UAC2Gadget [UAC2_Gadget], device 0: UAC2 PCM [UAC2 PCM]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Pro [D30 Pro], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

I used Pro as that is the name of the device in my system. Use whatever is the name of your DAC in yours in device: hw:DEVICENAME format.

Installing CamillaNode
First thing first - make sure you have npm installed. You can check that by typing npm in command line. If you got an error message saying npm: command not found, you don't have npm installed.

First run sudo apt update and sudo apt upgrade then run sudo apt install npm to install npm.

For reference, npm is the Packet Manager for Node.js.

Once that is done, create a camillanode folder in your home folder, that is, /home/USERNAME/camillanode. Change to that directory and do the following:
Bash:
git init
git pull https://github.com/ismailAtaman/camillaNode.git
npm install

It will work if you have git installed (you most likely will). If not install it with sudo apt install git, and run the commands above.

This will download and install CamillaNode to your computer.

To make sure it runs at start-up, you will have to create a service. You can do that by creating a service text file with sudo nano /etc/systemd/system/camillanode.service, pasting below text into it and saving it.

Rich (BB code):
[Unit]
Description=camillaNode Service
After=network.target

[Service]
User=root
Group=nogroup
ExecStart=/usr/bin/node /home/USERNAME/camillanode/index.js
WorkingDirectory=/home/USERNAME/camillanode/
Environment=PATH=/home/USERNAME/camillanode/
Restart=always

[Install]
WantedBy=multi-user.target

Again, do you forget to change USERNAME to the username you chose when configuring Armbian.

Enable the service so that it starts automatically on start up time by systemctl enable camilladsp

That's it. You are done. Congratulations! If everything worked as intended, you should be able use your EQ solution now.

I'd do the following to make sure all is well:
Check camilladsp log with cat /home/USERNAME/camilladsp/camilladsp.log for errors.
Open a webrowser and type IP address of your Zero2 to see if you can access the webserver. Make sure you type ot with http, as in, if the IP address of Zero2 is 192.168.0.100, you type http://192.168.0.100. If you don't, modern browsers defaults to https.

Rest should be easy.

Hope this was helpful to you and if any questions, please don't hesitate to ask.



Links shared throughout the document
https://www.audiosciencereview.com/...between-an-usb-source-ipad-and-usb-dac.25414/
https://www.aliexpress.com/item/1005006168374134.html
https://www.amazon.com/SanDisk-128GB-microSDXC-Memory-Adapter/dp/B08GY9NYRM/
https://www.amazon.com/Heatsink-8-8x8-8x5mm-0-35x-035x0-2-Conductive-Dissipation/dp/B07ZC68LNM/
https://www.armbian.com/orange-pi-zero-2/
https://etcher.balena.io/
https://github.com/HEnquist/camilladsp
https://www.audiosciencereview.com/forum/index.php?threads/rpi4-camilladsp-tutorial.29656/
https://www.audiosciencereview.com/...ternative-to-control-camilladsp-as-peq.44745/
http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-Zero-2.html
 
Last edited:

phofman

Addicted to Fun and Learning
Joined
Apr 13, 2021
Messages
551
Likes
365
Very nice. Just a note - since the newer kernel has async UAC2 gadget, the CDSP config should enable rate adjust. CDSP will hit (sooner or later) xruns without that.

If the gadget were adaptive (as in older android kernels), it would require rate adjust and async resampler.
 
OP
IAtaman

IAtaman

Major Contributor
Forum Donor
Joined
Mar 29, 2021
Messages
2,461
Likes
4,338
Very nice. Just a note - since the newer kernel has async UAC2 gadget, the CDSP config should enable rate adjust. CDSP will hit (sooner or later) xruns without that.

If the gadget were adaptive (as in older android kernels), it would require rate adjust and async resampler.
Thank you for the suggestion, added enable rate adjust to the config file on the original post.
 

ShadowBoxer

Member
Joined
Apr 14, 2024
Messages
11
Likes
4
Excellent guide! Thanks for putting this together. I'm off to look for the HW now to give it a shot. Without having everything pulled together here I probably wouldn't have tried.
 
OP
IAtaman

IAtaman

Major Contributor
Forum Donor
Joined
Mar 29, 2021
Messages
2,461
Likes
4,338
One thing I find a bit irritating, especially at night time, is constantly blinking LEDs. If that also bothers you, you can do the following to turn off the LEDs on the board.

sudo nano /etc/rc.local into to rc.local file and add following two lines above exit 0 statement.

Bash:
echo 0 > /sys/class/leds/green\:power/brightness
echo 0 > /sys/class/leds/red\:status/brightness

This will ensure once Zero2 finishes booting, the LEDs will turn off.

If you want them back, you can remove them from the rc.local file, comment them out with # symbols in the beginning of each line, or change 0 to 1.
 
Last edited:

Weeb Labs

Addicted to Fun and Learning
Joined
Jun 24, 2020
Messages
623
Likes
1,458
Location
Ireland
This looks very interesting. What is the minimum achievable artifact-free latency from input to output with this configuration?
 
OP
IAtaman

IAtaman

Major Contributor
Forum Donor
Joined
Mar 29, 2021
Messages
2,461
Likes
4,338
This looks very interesting. What is the minimum achievable artifact-free latency from input to output with this configuration?
I don't know. I don't notice any delays when watching videos. while running 2 instances of CamillaDSP on the same SBC, one rendering 60 filters, the other 12. Utilization is around 30%.

If you could tell me how I can measure that, I can try.

1714071788142.png
 

mdsimon2

Major Contributor
Forum Donor
Joined
Oct 20, 2020
Messages
2,604
Likes
3,509
Location
Detroit, MI
Not sure how you can quantify latency when starting from a USB source.

For reference I've been running my SPDIF input CamillaDSP systems at 48 kHz with 128 chunk size for the past few months. This gives 6 ms latency with an Okto dac8 pro and 8 ms with a MOTU Ultralite Mk5.

I've been slowly ramping down chunk size from 1024. Next step will be to see how 64 chunk size works which will knock latency down to 4-5 ms. In limited testing I haven't had luck running at chunk size lower than 64 at 48 kHz.

MIchael
 

GeorgeWalk

Senior Member
Joined
Sep 6, 2019
Messages
478
Likes
806
Nice write up. Thanks for posting. I have built a number of projects, including audio players, with RPIs. I will have to investigate the Orange Pi next.
 

dorirod

Active Member
Joined
Oct 9, 2019
Messages
255
Likes
259
Nice guide!

I use a Topping EX5 so you'd need to adjust this to fit your DAC. I created a udev rule to restart camilladsp when my DAC comes online (since I turn it on and off at times). Saving to something like /etc/udev/rules.d/90-camilladsp.rules
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="152a", ATTR{idProduct}=="8750", ATTR{product}=="EX5", SYMLINK+="dacex5", TAG+="systemd", RUN+="/bin/systemctl --no-block restart camilladsp"

You should be able to see the details of your USB DAC by turning off and on (or taking it out and plugging it back in) and then look in syslog:
tail -100 syslog |grep usb

Or run lsusb when the dac is on, and get the bus and device id, and plug them into udevadm info, e.g.:
Code:
$ lsusb
Bus 002 Device 002: ID 1058:0827 Western Digital Technologies, Inc.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 152a:8750 Thesycon Systemsoftware & Consulting GmbH
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$ udevadm info -n '/dev/bus/usb/001/004'
P: /devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.2
N: bus/usb/001/004
L: 0
E: DEVPATH=/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.2
E: DEVNAME=/dev/bus/usb/001/004
E: DEVTYPE=usb_device
E: DRIVER=usb
E: PRODUCT=152a/8750/163
E: TYPE=239/2/1
E: BUSNUM=001
E: DEVNUM=004
E: MAJOR=189
E: MINOR=3
E: SUBSYSTEM=usb
E: USEC_INITIALIZED=97738220585
E: ID_VENDOR=Topping
E: ID_VENDOR_ENC=Topping
E: ID_VENDOR_ID=152a
E: ID_MODEL=EX5
E: ID_MODEL_ENC=EX5
E: ID_MODEL_ID=8750
E: ID_REVISION=0163
E: ID_SERIAL=Topping_EX5
E: ID_BUS=usb
E: ID_USB_INTERFACES=:010120:010220:fe0101:030000:
E: ID_VENDOR_FROM_DATABASE=Thesycon Systemsoftware & Consulting GmbH

Once you have your rule in place you can test it like this:
udevadm test $(udevadm info --query=path --name=/dev/bus/usb/001/004) 2>&1

Some more udev info here:
 

Rafaille

Active Member
Joined
Dec 5, 2021
Messages
110
Likes
61
Thanks very much @IAtaman for the guide and for your work on the development of CamillaNode.
Have you (or anyone else) tried this on an OrangePi Zero 3? It currently sells cheaper than the version 2 on Ali but I am wondering about usb otg support in particular since version 2w does not sport it.

I am really keen on the idea to avoid both external power supply and usb hub vs Raspberry Pi based alternatives. If on top of that I can save a few $, even better.
 
OP
IAtaman

IAtaman

Major Contributor
Forum Donor
Joined
Mar 29, 2021
Messages
2,461
Likes
4,338
Thank you @Rafaille

I have not tried 3, but I doubt it will work. Type C port is marked as power supply only and if there is OTG/USB Device capability, it is always listed.

0627-zero3%20(6).png
 
OP
IAtaman

IAtaman

Major Contributor
Forum Donor
Joined
Mar 29, 2021
Messages
2,461
Likes
4,338
There is a much easier way to get up and running with OrangePi Zero2 now. As I have mentioned on CamillaNode2 thread, I put together a simple bash script to do all the monotonous configuration and setting up. Afterall, isn't that what computers are for :)

This is what you need to do:
  • Setup Armbian as usual by etching it on an SD card. Go through Armbian setup during boot to setup the wifi and connect to Orange Pi Zero2 via ssh from your main computer.
  • Connect your DAC to check the device name of your DAC using aplay -l as you will need it later on.
  • Run the following command
Bash:
wget -O - https://raw.githubusercontent.com/ismailAtaman/camillaNode/master/setup.sh | sudo bash
  • This will update your system, install npm, CamillaNode and download all the installation files and scripts to the computer.
  • Once that is done, go to camillanode folder, and run the following command :
Bash:
sudo bash install.sh
  • It will ask you for your username, input and output device names, and will set up everything accordingly, including downloading, installing and configuring CamillaDSP. Below is a screenshot sample. Your default input device name will be UAC2Gadget, if it is, you can just enter to use the default.
1715668019025.png


That is it. install script will do all the work for you; put g_audio into modules; download and install CamillaDSP, setup default configs and services and update everything as per the information you have provided. Just reboot the computer and enjoy using it.
 
Top Bottom