Raspberry Pi 5 DSP crossover music streamer

Results for the device sysdefault

pifieb@raspberrypi:~ $ aplay -Dsysdefault Pink.wav -v
Playing WAVE 'Pink.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Plug PCM: Soft volume PCM
Control: PCM Playback Volume
min_dB: -51
max_dB: 0
resolution: 256
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 22052
period_size : 5513
period_time : 125011
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 5513
period_event : 0
start_threshold : 22052
stop_threshold : 22052
silence_threshold: 0
silence_size : 0
boundary : 6207086186423386112
Slave: IEC958 subframe conversion PCM (IEC958_SUBFRAME_LE)
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 22052
period_size : 5513
period_time : 125011
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 5513
period_event : 0
start_threshold : 22052
stop_threshold : 22052
silence_threshold: 0
silence_size : 0
boundary : 6207086186423386112
Slave: Hooks PCM
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : IEC958_SUBFRAME_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 24
buffer_size : 22052
period_size : 5513
period_time : 125011
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 5513
period_event : 0
start_threshold : 22052
stop_threshold : 22052
silence_threshold: 0
silence_size : 0
boundary : 6207086186423386112
Slave: Hardware PCM card 0 'vc4-hdmi-0' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : IEC958_SUBFRAME_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 24
buffer_size : 22052
period_size : 5513
period_time : 125011
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 5513
period_event : 0
start_threshold : 22052
stop_threshold : 22052
silence_threshold: 0
silence_size : 0
boundary : 6207086186423386112
appl_ptr : 0
hw_ptr : 0
^CAborted by signal Interrupt...
aplay: pcm_write:2127: write error: Interrupted system call
pifieb@raspberrypi:~ $
 
here's the results with the specified arguments.

pifieb@raspberrypi:~ $ aplay -D default -v -c 8 -f S32_LE -r 48000 /dev/zero
Playing raw data '/dev/zero' : Signed 32 bit Little Endian, Rate 48000 Hz, Channels 8
ALSA <-> PulseAudio PCM I/O Plugin
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S32_LE
subformat : STD
channels : 8
rate : 48000
exact rate : 48000 (48000/1)
msbits : 32
buffer_size : 24000
period_size : 6000
period_time : 125000
tstamp_mode : NONE
tstamp_type : GETTIMEOFDAY
period_step : 1
avail_min : 6000
period_event : 0
start_threshold : 24000
stop_threshold : 24000
silence_threshold: 0
silence_size : 0
boundary : 6755399441055744000
^CAborted by signal Interrupt...
aplay: pcm_write:2127: write error: Interrupted system call
 
Oh, wait. I think I know what the problem is (or is related to). It's related to the LADSPA plugins and superuser I think. Your default device includes the LADSPA stuff but sudo cant' find it. I have run into something like this before. If you try send audio data directly to the actual audio device without using your LADSPA plug and do that as sudo does it work?

I forget whether this is because sudo does not have the LADSPA path in its path and so cannot find the so file, or what. So another thing to try is become superuser in the shell by running sudo su, then add the LADSPA path (see the ACDf README file for exactly what that is) to the current session (let us know if you do not know how to do that), and then try the aplay command to the default device (is it default also for su?) again.

We'll figure this out...
 
I forgot to add that there is no sound with aplay -D default -v -c 8 -f S32_LE -r 48000 /dev/zero
The AV receiver relay clicks into PCM Multichannel and displays 48khz, but there is no (pink noise) audio.

That is the expected behavior. What you are playing is the output of /dev/zero, which is data consisting of zeroes, and for audio data that is silence.
 
after sudo su I entered export LADSPA_PATH=/usr/local/lib/ladspa:/usr/lib/ladspa and confirmed presence with env.
Then

root@raspberrypi:/home/pifieb# aplay -D default -v -c 8 -f S32_LE -r 48000 /dev/zero
Playing raw data '/dev/zero' : Signed 32 bit Little Endian, Rate 48000 Hz, Channels 8
ALSA lib pcm_params.c:2226:(snd1_pcm_hw_refine_slave) Slave PCM not usable
aplay: set_params:1323: Broken configuration for this PCM: no configurations available
root@raspberrypi:/home/pifieb#


however for device "sysdefault" instead of "default"

root@raspberrypi:/home/pifieb# aplay -D sysdefault -v -c 8 -f S32_LE -r 48000 /dev/zero
Playing raw data '/dev/zero' : Signed 32 bit Little Endian, Rate 48000 Hz, Channels 8
Plug PCM: Soft volume PCM
Control: PCM Playback Volume
min_dB: -51
max_dB: 0
resolution: 256
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S32_LE
subformat : STD
channels : 8
rate : 48000
exact rate : 48000 (48000/1)
msbits : 32
buffer_size : 16384
period_size : 4096
period_time : 85333
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 4096
period_event : 0
start_threshold : 16384
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 4611686018427387904
Slave: IEC958 subframe conversion PCM (IEC958_SUBFRAME_LE)
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S32_LE
subformat : STD
channels : 8
rate : 48000
exact rate : 48000 (48000/1)
msbits : 32
buffer_size : 16384
period_size : 4096
period_time : 85333
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 4096
period_event : 0
start_threshold : 16384
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 4611686018427387904
Slave: Hooks PCM
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : IEC958_SUBFRAME_LE
subformat : STD
channels : 8
rate : 48000
exact rate : 48000 (48000/1)
msbits : 24
buffer_size : 16384
period_size : 4096
period_time : 85333
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 4096
period_event : 0
start_threshold : 16384
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 4611686018427387904
Slave: Hardware PCM card 0 'vc4-hdmi-0' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : IEC958_SUBFRAME_LE
subformat : STD
channels : 8
rate : 48000
exact rate : 48000 (48000/1)
msbits : 24
buffer_size : 16384
period_size : 4096
period_time : 85333
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 4096
period_event : 0
start_threshold : 16384
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 4611686018427387904
appl_ptr : 0
hw_ptr : 0


end post
 
  • Like
Reactions: 1 user
That is good to see. The sink (DAC) works when fed the proper audio format and rate. So the problem has to do with your pcm device and or LADSPA plugins.

There is also a slight possibility that there is an automatic internal conversion of the audio format to FLOAT32, which LADSPA requires, but this is then not converted back to e.g. S32_LE before it is sent to the DAC.

I'm not fluent enough in the ALSA language to tell you where you might insert the format specification when sending the post-LADSPA stream to the DAC. Maybe @phofman can give some useful advice...
 
fyi
I managed to get the LADSPA_PATH=/usr/local/lib/ladspa:/usr/lib/ladspa loaded at boot time. The trick is to add
export LADSPA_PATH=/usr/local/lib/ladspa:/usr/lib/ladspa to the file /etc/environment
For my Raspberry Pi 5 running 64bit OS the file /env/environment was empty so I just pasted in the instruction with sudo nano environment
 
speaker-test -t wav -Ddefault -c 8 and also speaker-test -t wav -Dpulse -c 8 give me audio on all the channels sequentially.
I get device/resource busy with devices hdmi:0,0 and hw:0,0 and plughw:0,0 and sysdefault
I get unknown error 524 with devices hdmi:1,0 and hw:1,0 (I dont have a cable plugged into this hdmi port)

playing audio with mplayer gives me audio to all the channels simultaneously without any of the processing of asound.conf being applied.

The Raspberry Pi 5 ships with PulseAudio and Pipewire by default and it does not appear possible to remove either/both of these entirely and fall back strictly to ALSA (as is the case on the Pi2 running Bullseye).

From what I can tell PulseAudio basically ignores everything in the asound.conf. Maybe the functions of asound.conf need to be punched directly into PulseAudio instead? I understand that PulseAudio uses "modules" with "sinks" and "sources".

Google search https://askubuntu.com/questions/43950/how-can-i-apply-a-ladspa-plugin-to-a-pulseaudio-stream for LADSPA plugins with PulseAudio shows that modules need to be loaded using pacmd load-module <module-modulename-sink/source> <plugin> <options> and there are examples for loading specific plugins. To have these modules load at system start they need to be added to the /etc/pulse/default.pa and then all the arguments of the plugin need to be specified. Maybe this is possible with ACDf.so where plugin=ACDf and the desired filter 21 is label=21 then remaining arguments would need to be noodled out. ugggh.

Available PulseAudio modules are listed at
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/#pulseaudiomodules
I'm not a linux programmer and I don't think I'm up to the challenge of getting ALSA to play nice with PulseAudio, at least on a multi-channel basis. I might be able to work up with one filter at a time, probably with plugin that only has one filter in it to start.

May be worth waiting until somebody else has already been successful with this on the Raspberry Pi 5.
For now I will enjoy listening to music using the active DSP crossover on my Raspberry Pi 2 !
 
I hate to ask this, but is there any particular reason that you are married to implementing the crossover filtering via ALSA directly? Are you trying to avoid resampling or want bit perfect playback or need the latency to be low so that video and audio remain synced? I use rather complicated crossovers and I found the native ALSA implementation a bit too challenging (and I LIKE to program).

In my own audio-only Linux system I playback using whatever app I want. Audio is automatically sent to PulseAudio by the OS. Then with another app I get the audio from PA, route and process it with LADSPA, and send it to the ALSA sink/DAC. I also get to use PAs' volume control, meaning that the keyboard volume keys work as expected. I configure PA to not use that particular DAC when it starts up or I manually disable it first. This approach does require that the audio is resampled within PA to a fixed rate and format, but I find that is totally transparent when you configure PA properly. I haven't used the Pi platform for awhile, so my expereience is from using miniPCs or a laptop running Ubuntu OS.

If you want to give my approach a try, drop me a PM.
 
Using ALSA for crossover filtering was just somewhere to start with the Raspberry Pi 5 since I had been successful with it on the Pi 2.

I've managed to get camillaDSP installed on the Pi 5, and at least partially operating with /etc/mplayer/mplayer.conf -ao:alsa:device=hw=Loopback.1 giving audio to camillaDSP. The vu meters for In and Out are bouncing around nicely!
camillaDSP is currently configured for
samplerate = 44100
chunksize = 1024
enable_rate_adjust = yes
resampler_type = none
capture device type=Alsa , channels=2 , sampleformat=S16LE , device=hw:Loopback,0,0
playback device type=Alsa , channels = 4 , sampleformat=S16LE, device=sysdefault
the AV receiver reports MCH PCM 2.1 at 44.1khz.
This is using Henriks default 2 channel crossover example.
Audio is going to the woofer and the mid at the moment, no tweeter.
With luck, I'll get the crossover configured from 2-way to 2.5-way and match the performance I have with the Pi 2.
 
  • Like
Reactions: 1 user
Had sound from camillaDSP briefly as noted on previous post. Pi5 Bookworm did an update this AM and now I get no sound at all. I can see the VU meters bouncing for the Input and the Output. I know they are showing that actual process and not just random noise because I am using mplayer -loop 0 -ao: device:Loopback.1 sweep2.wav which is a sine wave sweep. The Output VU meters shift with time as would be expected with the crossover filters active. Unfortunately there is no sound even with the blue volume slider at full volume. I've tried different playback devices with no luck (sysdefault, pulse, hw:0,0, surround71, etc.) If I change the Playback device to an invalid selection, this freezes the VU meters and throws an error into the log file telling me that the service has stopped. Then it is necessary to sudo service camilladsp restart to get it working again. Still no luck. alsamixer shows my soundcard as Pulse and all channels are at full volume. Perhaps this is a compatibility issue with Bookworm and I might have more success with Ubuntu.

I am using camillaDSP 2.0.3, pyCamillaDSP 2.02.2 Backend 2.1.0, . sudo apt update reports all packages up to date.
sudo apt-get install mplayer reports that mplayer is already the newest version (2:1.5+svn38408-1).
mplayer -h shows version unknown-12

I'll take a look through related posts on camillaDSP and see if there are any solutions.
 
Ok I have sound back again. Problem may have had something to do with PulseAudio Volume Control being active on my desktop.
Using sudo service camilladsp stop and then manually restarting with camilladsp -g-40 -p 1234 ~/camilladsp/configs/myfile.yml got everything working again.

When running camilladsp -g-40 -p 1234 ~/camilladsp/configs/myfile.yml -v it was flagging an error with AO_ALSA having something already in use. I think this was from having the PulseAudio Volume Control open on the desktop.

With the problem corrected I dropped the -v flag to eliminate the status scrolling on my terminal window.

Ok, now on to re-configuring the default example crossover filters for my speaker setup!
 
When running camilladsp -g-40 -p 1234 ~/camilladsp/configs/myfile.yml -v it was flagging an error with AO_ALSA having something already in use. I think this was from having the PulseAudio Volume Control open on the desktop.
When using an alsa device directly with pulseaudio/pipewire running, it's always necessary to disable the given device in PA/PW first.
 
  • Like
Reactions: 1 user