Part 4: Advanced Configuration
This is where things get fun! When looking at these options you will notice that the Okto has a lot of really nice features that are not available on the other DACs, namely IR volume control, a big volume display and a trigger output. Wouldn’t it be great if we could get the same functionality on the other DACs? Turns out you can do this relatively easily. In this section I will talk through implementing improvements to achieve the above mentioned functionality and will also cover a few other areas like USB wifi dongles and how to use the CamillaDSP GUI.
FLIRC USB IR Receiver
A
FLIRC IR receiver is an easy way to add IR volume control for around $20. I’ve created a python script so setting this up is very easy. The first step is to download the FLIRC software on your main computer and connect the FLIRC receiver to that computer. Pair your remote so that volume up is key up and volume down is key down.
Install evdev.
Copy / paste python script in attached “flirc.txt” in to ~/flirc.py using nano.
As of 03/29/2022 the FLIRC python script has some very simple source / configuration switching. As of 05/04/2022 the FLIRC python script slightly changed the way that source switching is implemented as the tutorial changed to using a symlink configuration (active_config.yml). If you want to implement source / configuration switching first pair KEY RIGHT to your desired source switching remote button in the FLIRC pairing software. Then edit flirc.py and edit the active, temp, config1 and config2 so they reflect your specific user name and configuration files. The default code will switch between an an analog input configuration for a MOTU M4 called "m4_analog.yml" and a streamer configuration called "m4_streamer.yml" by updating the active_config.yml symlink. There is a lot of flexibility here so let me know if there is another source or configuration change you would like to see implemented.
Rich (BB code):
active = "/home/michael3/camilladsp/active_config.yml"
temp = "/home/michael3/camilladsp/temp.yml"
config1 = "/home/michael3/camilladsp/configs/m4_streamer.yml"
config2 = "/home/michael3/camilladsp/configs/m4_analog.yml"
Create service to start FLIRC python script. You will need to change "ExecStart" line to reflect your username.
Rich (BB code):
sudo nano /lib/systemd/system/flirc.service
Rich (BB code):
[Unit]
After=syslog.target
StartLimitIntervalSec=10
StartLimitBurst=10
[Service]
Type=simple
ExecStart=python3 /home/michael3/flirc.py
Restart=always
RestartSec=1
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=flirc
User=root
Group=root
[Install]
WantedBy=graphical.target
Enable FLIRC service.
Rich (BB code):
sudo systemctl enable flirc
Enable USB-C port for use, this is needed if you want to run the IR receiver from the USB-C port (you will see why you might want to do this in the section discussing cases).
Rich (BB code):
sudo nano /boot/firmware/config.txt
Add ,dr_mode=host after dtoverlay=dwc2 so that the final line looks like:
Rich (BB code):
dtoverlay=dwc2,dr_mode=host
Trigger Output
It is pretty easy to add a trigger output to the MOTU Ultralite Mk5 using a
Bobwire DAT1. All you need to do is to connect the TOSLINK output of the Mk5 to the Bobwire DAT1 and use the Audio Detect output port. All of my configuration files are set to stop after 5 seconds of output less than -100 dB, as a result CamillaDSP will stop after 5 seconds and after 60 seconds the trigger from the Bobwire will stop and your amplifiers will turn off. Once CamillaDSP starts playing the Bobwire DAT1 trigger will fire up immediately. The only issues I have with the Bobwire DAT1 are that it is relatively expensive (~$70) and for me the provided power supply had a high frequency noise coming from the power supply itself, I swapped this out with another generic 12 V power supply and the noise went away.
OLED Display
A very nice feature of the RPi is it has GPIO pins which can be used to interface with a variety of displays. I’ve developed a python script that works with the
buydisplay.com 3.2” diagonal SSD1322 OLED display which is around ~$30 + shipping. Be sure to order the display in the 6800 8 bit configuration, I also recommend you have them solder a pin header as it is only an additional cost of $0.59.
I should warn that my code is messy and I am sure will make actual programmers cringe but it works well and it is decently easy to modify. The base setup turns the display off after 10 seconds of no volume changes to avoid OLED burn in. It will turn back on if you change the volume or the CamillaDSP status changes.
As of 03/29/2022 I also added some flexibility to the top line of the display to support source switching. If the capture device is "hw:Loopback,0" it will show "Streamer", if it is "hw:M4" it will show "Analog" and if it is something else it will show "CamillaDSP". This should be pretty easy to edit in the future to accommodate things like different configuration names or inputs on other devices.
Install lgpio.
Rich (BB code):
sudo apt install python3-lgpio
Copy / paste python script in attached “oled.txt” in to ~/oled.py using nano.
Create service to start OLED python script. You will need to change "ExecStart" line to reflect your username.
Rich (BB code):
sudo nano /lib/systemd/system/oled.service
Rich (BB code):
[Unit]
After=syslog.target
StartLimitIntervalSec=10
StartLimitBurst=10
[Service]
Type=simple
ExecStart=python3 /home/michael3/oled.py
Restart=always
RestartSec=1
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=flirc
User=root
Group=root
[Install]
WantedBy=graphical.target
Enable OLED service.
Rich (BB code):
sudo systemctl enable oled
Wiring configuration from the display to the RPi GPIO header is listed below.
01 -> ground
02 -> 3.3 V
03 -> no connection
04 -> GPIO 26
05 -> GPIO 13
06 -> GPIO 6
07 -> GPIO 5
08 -> GPIO 22
09 -> GPIO 27
10 -> GPIO 17
11 -> GPIO 18
12 -> GPIO 23
13 -> ground
14 -> GPIO 16
15 -> GPIO 12
16 -> GPIO 25
For wiring I used prefabbed 8” long 0.1” header jumpers. These are a bit long but allow you to remove the front panel with the wiring remaining connected which is a nice feature.
As an example of what the final functionality looks like see video below. This video demonstrates pretty much all the functionality including the MOTU M4 source switching.
Modushop Case
Modushop offers CNC machining of aluminum cases for custom projects. You provide the CAD files and they will do the machining. In general I have found ordering directly from Modushop is slightly cheaper than ordering from
DIYAudio Store which is the US distributor, this may change as exchange rates and shipping costs change so be sure to check before ordering. All cases are based on the Galaxy GX247 chassis (230 mm x 170 mm x 40 mm) with 2 mm aluminum covers. I really hate the 1 mm steel cover option as these are rather flimsy.
All case designs discussed below are designed to be used with a display and IR receiver. Drawings in dwg, pdf and vsdx format are attached to this post in a zip file.
A challenge with these cases was how to get a USB port in the front of the case for the IR receiver and how to get a power connection in the rear of the case. The only USB port that is accessible from inside the case is the USB-C port which is usually used for power, however this port can be used as a normal USB port and the RPi can be powered via the pin header. Therefore my solution was to use an USB A socket to USB C plug adapter on the USB-C port coupled with a panel mount USB A extension cable. This allows the IR receiver to be connected at the front of the case. For power I installed a
5.5 mm x 2.1 mm jack in the rear of the case. I soldered some 20 awg wire with pin connectors at the end to the jack. In my case I used two wires for 5 V and two wires for ground and connected both 5 V wires and both ground wires to the pin header. The doubling wiring is likely overkill but I wanted to make sure I avoided under voltage issues. I do definitely recommend using at least 20 awg here. This is the only part of the project that requires soldering. That being said if you are totally against soldering you can purchase a 5.5 mm x 2.1 mm jack with prefabbed wiring and then crimp some prefabbed 20 awg 0.1” header wiring on the ends. If you do this it is likely you will need to change the diameter of the power jack hole in the rear case, most the prefabbed options I have seen require a larger diameter than 8 mm so it would be easy for you to drill out the hole yourself to accommodate the larger diameter or you can modify the drawings and have Modushop drill a larger hole.
For a power supply you can either use a standard RPi4 power supply with a USB-C to 5.5 mm adapter or just get a 5.5 mm power supply. I used a Meanwell
GSM25B05-P1J (5 V @ 4 A) I had laying around. Your power supply should be at least 5 V @ 3 A.
10 mm front panel - single sided machining - 50€ add-on
This option machines a 10 mm aluminum panel from the back side only. The screen is set half way through the panel thickness and there is a hole for the FLIRC IR receiver, mounting holes for the screen and IR receiver are tapped for M2.5 screws so there are no exposed fasteners. Pictures of this panel are shown below. Overall this option looks very nice, one complaint is that due to the thickness of the front panel the top of the display text can be obstructed from view if you are sitting very near to the case and looking down on the screen. If that bothers you it is certainly possible to modify the layout of the text so that it is more more centered on the screen or you can look at my option which chamfers the screen opening from the front side at an additional cost.
Recommended hardware:
display mounting screws:
M2.5 x 5 mm long
FLIRC mounting screws:
M2.5 x 16 mm long w/
8 mm spacers
USB-C male to USB-A female:
Adafruit USB A Socket to USB Type C Plug Adapter
USB panel extension:
Adafruit Panel Mount USB Cable - A Male to A Female
10 mm front panel - double sided machining - 70€ add-on
This is the same as the first option but has a 45 deg chamfer around the screen opening to improve viewing angles.
Recommend hardware: same as single sided 10 mm front panel
3 mm front panel - 31€ add-on
This option uses all through holes so the machining cost is lower, it does require you to purchase a separate 3 mm front panel. It may be possible to swap out the default 10 mm front panel for a 3 mm front panel at reduced cost. This design has a lot of exposed fasteners due to the through holes but has no issues with viewing angle due to the thinner panel. The IR receiver holes are slightly larger than the display holes so that they can accept M3 screws which matches the threading of the Adafruit USB panel extension cable, alternatively you can use M2.5 screw with nuts to keep the hardware consistent.
Recommended hardware:
display mounting screws:
M2.5 x 12 mm long
FLIRC mounting screws:
M2.5 x 30 mm long w/
15 mm spacers
nuts:
M2.5
USB-C male to USB-A female:
Adafruit USB A Socket to USB Type C Plug Adapter
USB panel extension:
Adafruit Panel Mount USB Cable - A Male to A Female
2 mm bottom panel - 30€ add-on
I definitely recommend paying the 5€ for a solid aluminum bottom panel as in my experience the venting gets in the way of the mounting holes. However the additional 25€ machining cost for 4 RPi4 mounting holes is probably not worth it if you can drill 4 decently accurate holes yourself.
Recommended hardware:
RPi4 mounting screws:
M2.5 x 16 mm long w/
10 mm spacers
nuts:
M2.5 (as an alternative you can use the top part of
aluminum heatsink case which is tapped for M2.5 screws, this is what I used).
2 mm back panel - 25€ add-on
This is another area where you might be able to save money. For example it is certainly possible to leave the back panel completely off which is a way to save on machining costs. I’ve drilled / hand filed similar panels myself which is not fun but certainly can be done at home and the rear will likely not be exposed. This panel has cutouts for the RPi4 USB ports and ethernet port. There is also an 8 mm diameter hole for a 5.5 mm barrel connector.
For reference at the time of writing here are prices in USD including priority shipping to my location (Detroit, MI US) for the three basic case options including front panel, bottom panel and rear panel machining.
3 mm front panel: $171
10 mm front panel, one sided machining: $189
10 mm front panel, double sided machining: $212
USB Wifi Dongle
I have been using RPis for a while as squeezelite end points and noticed that if I use the built in wifi I would get the occasional drop out. As a result I switched to a more powerful
USB wifi adapter. This option may not be the best as it does require you to install a driver but it seems to work really well. Instructions below walk through how to install the driver and change the wifi setup to use this adapter.
Do this while connected to LAN!
Instructions shown here were originally found here:
Linux Driver for USB WiFi Adapters that are based on the RTL8811AU and RTL8821AU Chipsets - GitHub - morrownr/8821au: Linux Driver for USB WiFi Adapters that are based on the RTL8811AU and RTL8821A...
github.com
Run iwconfig from terminal and identify the name of your adapter. If you are using the same model as me it should be something like wlx984827e1c95c.
Rich (BB code):
sudo cp /etc/netplan/50-cloud-init.yaml /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg
sudo nano /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg
Rich (BB code):
wifis:
wlx984827e1c95c:
access-points:
networkname:
password: passed
dhcp4: true
optional: true
I also comment out the existing wlan0 entry so that only the USB adapter is used.
Rich (BB code):
sudo cloud-init clean
sudo cloud-init init
sudo reboot
Using the GUI
As mentioned previously you can view the GUI by going to any browser on your network and entering http://
raspberrypi3:5000 (where raspberrypi3 is the host name of your RPi running CamillaDSP).
By default the GUI will show the configuration file that you specified in ~/camillagui/config/camillagui.yml which may or may not be loaded as the active DSP profile. If you followed the instructions in this tutorial the default will be to load the configuration file at ~/configs/camilladsp.yml which is what will be loaded when CamillaDSP starts. When you make changes to the configuration in the GUI they will not take effect until you click the Apply to DSP button.
If you have any doubt on what configuration is loaded on the DSP you can click the Fetch from DSP button and it will show you the current configuration in the GUI.
Unless you save the changes to your configuration in ~/camilladsp/configs/camilladsp.yml any changes you make in the GUI (even if you load them to the DSP) will go away after CamillaDSP restarts.
Personally I like to have a few configuration files located in ~/configs. The GUI will show these as options under the Files tab so you can switch between them easily by clicking the Load in to GUI button and then clicking the Apply to DSP button. Once I have decided on what configuration file to use going forward I will save it in to ~/camilladsp/configs/camilladsp.yml and it will be loaded in the future. We will discuss how to do this when we go through the Files tab.
Let’s talk about the basic layout of the GUI. The first tab is the Devices tab, in general this will stay the same as it defines general parameters like capture device, playback device, sample rate and chunk size.
In the Filters tab you can add any filter you want. A big advantage to using the GUI over the manual configuration file is that it will prompt you for the necessary information for the filter type you are using. Once you have crated a filter you can also view the magnitude / phase response and make sure it matches your expectation. If you have questions about specific filter implementation see the CamillaDSP GitHub. Creating a filter in the Filters tab does not apply it to the pipeline, it just creates a filter that will be available for you to apply in the pipeline.
The Mixers tab defines your channel routing, in addition you can also change the gain and polarity of each channel. Like filters your mixer will not be in effect until you apply it in the pipeline.
The Pipeline tab is where everything comes together, this is where you apply the filters and mixer created in the previous tab. You can also plot the entire pipeline which will show you the how the mixer and filters are applied as well as the combined filter magnitude / phase response on each channel.
The Files tab stores configuration and convolution filters. It will show you any configuration files located in ~/camilladsp/configs/ and any convolution filters located in ~/camilladsp/coeffs/. You can also upload configurations and convolution filters from your local computer. You can also save the configuration currently loaded in to the GUI to either a new configuration file or an existing one. Remember that by default ~/camilladsp/configs/camilladsp.yml is the configuration loaded in to CamillaDSP and the GUI so whatever configuration you want loaded by default should be saved there.
Here are few things that I am thinking about implementing but currently do not have tons of motivation to do.
1) Sample rate switching, rather than have the player resample could have CamillaDSP load different configuration files as the source sample rate changes.
2) Source switching, with something like the MOTU Ultralite Mk5 would be nice to be able to switch sources and the click of a remote button, this is somewhat complicated by the need to change clock source for different sources.
3) Other players, would be interested in what other software players folks may be interested in as providing instructions should be pretty easy.
Something I do plan on doing is buying a digital output miniDSP Flex once it becomes available. This will provide an ideal front end to the MOTU Ultralite Mk5 as it has a built in ASRC, good input functionality, a display and a volume knob. Although I imagine it will be more expensive than a DIY case with display and IR receiver I think the extra functionality is worth it. The only downside is that CamillaDSP can implement dynamic loudness with it’s volume control and the miniDSP cannot.
That is it! Hope everyone finds this useful and if you have any questions or comments please let me know!
Michael