Spectrum analyzer
CamillaDSP can be used to do spectrum analysis. It is also known as RTA (Real-Time Analyzer). In my set-up I run a second instance of CamillaDSP that listens in on the same audio source that I'm playing music from. Its pipeline has bandpass filters to create 60 outputs that represent frequency bands. (There are 30 bands, separately for the left and right channel.) The output is not sent to a playback device, but can be read by custom scripts to visualize it.
What it looks like
I can show the spectrum analyzer on a small display:
I can also show it as bars on the command line (when logged in with PuTTY):
I'm coloring the bars according to whether the frequency band is played by the subwoofers, woofers or tweeters. Besides looking nice that also gives insight.
Download it
This contains the CamillaDSP configuration and scripts to show the spectrum analyzer in the terminal or on a small display. You can upload it from Windows to the Pi with WinSCP and extract the archive as explained here. You could also download it directly in Linux with:
curl https://www.jarkko.nl/dokuwiki/_media/raspberry_pi/spectrum_analyzer_v1.1.tar.gz -O
How to use
One-time set-up:
- Edit start_camilladsp.sh to select the CamillaDSP version you're using.
- If you use CamillaDSP v2.x then edit spectrum_camilladsp_v2.yml and change the capture device. The the v3.yml file for CamillaDSP v3.x.
- Every program that reads from the same capture device must use prefix “dsnoop:” for the ALSA capture device. See also page about ALSA and ALSA connections for my set-up.
- Edit show_spectrum_in_terminal.py to select your crossover frequencies.
- The script to show it on the screen makes use of my OLED driver, which you need to download separately. It will be found if you put it in the same directory.
These commands will start/stop the CamillaDSP instance for spectrum analysis and visualize it. You can use Ctrl+C to stop showing the spectrum. This CamillaDSP instance uses about 11% CPU time on a Raspberry Pi 5, also when no music is playing, so you may want to stop it when you're not using it.
./start_camilladsp.sh
./stop_camilladsp.sh
./show_spectrum_in_terminal.py
./show_spectrum_on_display.py
I have tried this with CamillaDSP v2.x. It should be working for v3.x as well, but didn't try that yet.
References / thanks
The CamillaDSP pipeline was shamelessly stolen from: https:///github.com/Wang-Yue/CamillaDSP-Monitor