CamillaDSP - Cross-platform IIR and FIR engine for crossovers, room correction etc

Hi All

I could really use some help to get this working. I have some baseline where it works but with quirks

what is working
- i was able to get camilladsp to work on Pulse audio
- played a local file using VLC, was able to select in the audio settings the output to be the PulseAudio null-sink
- got the config file to finally work
- i tested some filters and at least i have a working base line

what is not working
1) if i play that same local file using another player like Ryhtmbox ...i dont get the sound from my sound card. My guess is that its not outputting to the pulse null-sink. I would have thought that this becomes the default or there is something else

2) the same config file using alsa seems to show no error at least on the terminal but i dont get any sound from the sound card

3) in my config file ..the mapping of the channels seems weird. The creative 5.1 Xfi sound card that i have has the following ports ...headphone jack, mic in, line in. Then there are 6 output channels ....{left,right}, rear, {center, lfe}. The camilladsp out put is coming from the headphone jack, rear, and the center

My config file in Pulse audio
Code:
--- 
devices:
  samplerate: 48000
  chunksize: 1024
  capture:
    type: Pulse
    channels: 2
    device: "MySink.monitor"
    format: S16LE
  playback:
    type: Pulse
    channels: 6
    device: "alsa_output.usb-Creative_Technology_SB_X-Fi_Surround_5.1_0000038b-00.analog-surround-51"
    format: S16LE
    
mixers:
  to6chan:
    channels:
      in: 2
      out: 6
    mapping:
      - dest: 0
        sources:
          - channel: 0
            gain: 0
            inverted: false
      - dest: 1
        sources:
          - channel: 1
            gain: 0
            inverted: false
      - dest: 2
        sources:
          - channel: 0
            gain: 0
            inverted: false
      - dest: 3
        sources:
          - channel: 1
            gain: 0
            inverted: false
      - dest: 4
        sources:
          - channel: 0
            gain: 0
            inverted: false
      - dest: 5
        sources:
          - channel: 1
            gain: 0
            inverted: false
filters:
  highpass2k:
    type: Biquad
    parameters:
      type: Highpass
      freq: 2000
      q: 0.5
  lowpass2k:
    type: Biquad
    parameters:
      type: Lowpass
      freq: 200
      q: 0.5

pipeline:
  - type: Mixer
    name: to6chan
  - type: Filter
    channel: 2
    names:
      - highpass2k
  - type: Filter
    channel: 3
    names:
      - highpass2k
  - type: Filter
    channel: 0
    names:
      - lowpass2k
  - type: Filter
    channel: 1
    names:
      - lowpass2k
  - type: Filter
    channel: 4
    names:
      - highpass2k
  - type: Filter
    channel: 5
    names:
      - highpass2k

My config file in Alsa
Code:
--- 
devices:
  samplerate: 48000
  chunksize: 1024
  capture:
    type: Alsa
    channels: 2
    device: "hw:Loopback,0,0"
    format: S16LE
  playback:
    type: Alsa
    channels: 6
    device: "hw:S51"
    format: S16LE
    
mixers:
  to6chan:
    channels:
      in: 2
      out: 6
    mapping:
      - dest: 0
        sources:
          - channel: 0
            gain: 0
            inverted: false
      - dest: 1
        sources:
          - channel: 1
            gain: 0
            inverted: false
      - dest: 2
        sources:
          - channel: 0
            gain: 0
            inverted: false
      - dest: 3
        sources:
          - channel: 1
            gain: 0
            inverted: false
      - dest: 4
        sources:
          - channel: 0
            gain: 0
            inverted: false
      - dest: 5
        sources:
          - channel: 1
            gain: 0
            inverted: false
filters:
  highpass2k:
    type: Biquad
    parameters:
      type: Highpass
      freq: 2000
      q: 0.5
  lowpass2k:
    type: Biquad
    parameters:
      type: Lowpass
      freq: 200
      q: 0.5

pipeline:
  - type: Mixer
    name: to6chan
  - type: Filter
    channel: 2
    names:
      - highpass2k
  - type: Filter
    channel: 3
    names:
      - highpass2k
  - type: Filter
    channel: 0
    names:
      - lowpass2k
  - type: Filter
    channel: 1
    names:
      - lowpass2k
  - type: Filter
    channel: 4
    names:
      - highpass2k
  - type: Filter
    channel: 5
    names:
      - highpass2k

what can i share to help debug? Any help and direction would be greatly appreciated.
 
The Pulse config should work. To get all sound playing through camilladsp, just select the null sink as the default playback device in the sound control panel.


For the alsa config, you have to work a bit more to get Pulse to send the sound to the loopback device. It doesn't automatically list loopbacks in the control panel so you can't select it. But you can add it to the list manually:
camilladsp-config/default.pa at master * HEnquist/camilladsp-config * GitHub


About the channel mapping, this is all handled by the driver. I would expect the headphone jack to share the signal with front. The lfe could possible have a hardware lowpass filter, but usually they don't.
 
Here are the lsusb and stream0 files. If I read the stream0 file correctly, I need to set up actually 12 channels and not only 8 and use theS24LE3 format for it to work. Is that correct?

Edit: That did not work. CamillaDSP says 8 is an invalid destination, max is 7. Should I just set the number of channels to 12 and ignore the rest?

Edit2: I forgot to set the number of channels in the mixer to 12. Now it seems to be running!
 

Attachments

Last edited:
@HenrikEnquist thanks so much for you help. I was able to set the MySink as the default by using the command pactl set-default-sink MySink

when i looked at the link you provided...it is pointing to default.pa which from my understanding is a pulse configuration.

My goal was to ideally use Alsa directly without pulse. However when ever i use the config file with alsa as the playback and with the loopback as the capture ...i cant get to get audio from the sound card

when i try to use the Alsa directly...this is what i do
- i start the loop back with the command sudo modprobe snd-aloop
- the capture device in the config file is set as hw:Loopback,0,0 and the playback is set as hw:S51...but as i said i cant get any audio from any ports on the sound card.
 
I got a Behringer UMC1820 soundcard and I was able to set a config file with a 2 to 8 mixer.I can see the card in aplay -l and I can control volume in alsamixer. But when starting CamillaDSP, I get an error: "Playback error: ALSA function 'snd_pcm_hw_params_set_channels' failed with error 'EINVAL: Invalid argument'". Any ideas on what could be wrong will be appreciated.

My suggestion: Get the setup playing with "aplay" and/or "arecord" commands first. If those don't work, it's likely Linux related (or your command entry). CamillaDSP seems to honor and accept the commands for ALSA.

This is what I had to do for a while to figure out the whole Linux sound interaction.
 
Last edited:
Hi All

I could really use some help to get this working. I have some baseline where it works but with quirks

what is working
- i was able to get camilladsp to work on Pulse audio
- played a local file using VLC, was able to select in the audio settings the output to be the PulseAudio null-sink
- got the config file to finally work
- i tested some filters and at least i have a working base line

what is not working
1) if i play that same local file using another player like Ryhtmbox ...i dont get the sound from my sound card. My guess is that its not outputting to the pulse null-sink. I would have thought that this becomes the default or there is something else

2) the same config file using alsa seems to show no error at least on the terminal but i dont get any sound from the sound card

3) in my config file ..the mapping of the channels seems weird. The creative 5.1 Xfi sound card that i have has the following ports ...headphone jack, mic in, line in. Then there are 6 output channels ....{left,right}, rear, {center, lfe}. The camilladsp out put is coming from the headphone jack, rear, and the center

Don't use pulse. That's general Linux audio mantra. Pulse is fine for basic apps and general usage, but if you're really looking into audio you need to be using ALSA or Jack. I don't know much about jack, but ALSA is direct kernal calls. If you can structure your setup around ALSA (maybe through jack) you'll find it much easier.
 
My goal was to ideally use Alsa directly without pulse. However when ever i use the config file with alsa as the playback and with the loopback as the capture ...i cant get to get audio from the sound card

How are you going to use the system? As a music player, playing music through one or a few apps only? Or like a computer that sometimes plays music and other sounds with various desktop apps, some youtube videos in the browser and so on?

The first case should be possible completely without Pulse. But the second will be quite painful, and that is where Pulse becomes very helpful. If you use Alsa only, then only one app can play sound at the same time. Others will be locked out, until the active app releases the device.



when i try to use the Alsa directly...this is what i do
- i start the loop back with the command sudo modprobe snd-aloop
- the capture device in the config file is set as hw:Loopback,0,0 and the playback is set as hw:S51...but as i said i cant get any audio from any ports on the sound card.
In this case, your desktop apps are still sending their sound to Pulse, but then Pulse has no way of sending it on to the loopback. This is where the config I linked to comes in. That sets up an Alsa sink in Pulse, that sends the sound to the Alsa device you choose. In the link, it sends to the "camilladsp" device which is a Plug device that handles format conversion etc. It's defined here: camilladsp-config/asound.conf at master * HEnquist/camilladsp-config * GitHub
 
Thanks @HenrikEnquist. My aim is to just use the SBC as a headless unit with one app to play music only. I want to use shaiport-sync that allows me to airplay into the sbc then have the camilladsp to do the crossover and filtering and output through the sound card. Ideally i would love to do it with Alsa as my understanding is that Pulse sits on top of alsa to have a minimal and a direct chain if possible.

What i have been able to get working is this

Shaiport-sync -> MySink (Pulse) -> Camilldadsp -> Soundcard

when i replace the config file in the camilladsp (capture with the loopback, and the playback with the hw name i get) and play locally with VLC (i can even select the loopback as the audio output)...even then i am unable to get any output from the soundcard. If i could get that sorted then the only thing remaining would be to see how i can have Shaiport-sync send audio to Alsa.

Since i have working baseline with pulse, my understanding is that the issue is no longer the format or the channel mapping etc in the config file but something to do with the loopback and or Alsa. Any guidance or help with debugging would be appreciated.
 
Thank you for your quick reply, I've followed the recipe on minidsp page (example 1) correcting loudspeaker phase using rephase and importing that to minidsp 2x4 hd


rePhase FIR Tool

The MiniDSP 2x4HD is very tap limited being stuck at 96K and filters in the 20 to 100Hz area need a lot more taps for the filters to be anything other than very low resolution. It is quite hard to make a filter with significant pre-ringing due to low frequency phase shifts with that many taps, but it is easy to make a filter than ruins the response due to not matching the intended target properly.

Camilla would give you the ability to use more taps. Posting in the rephase thread might get you more help on what you are aiming to do and what is going wrong.
 
@HenrikEnquist, here is the output i get when i put in the -v argument
Code:
2021-05-09 19:54:19.949 DEBUG camilladsp - Read config file Some("test_10_alsa.yml")
2021-05-09 19:54:20.041 DEBUG camillalib::biquad - a1=-1.5346539759579207 a2=0.5887907064808636 b0=0.7808611706096961 b1=-1.5617223412193921 b2=0.7808611706096961
2021-05-09 19:54:20.041 DEBUG camillalib::biquad - a1=-1.5346539759579207 a2=0.5887907064808636 b0=0.7808611706096961 b1=-1.5617223412193921 b2=0.7808611706096961
2021-05-09 19:54:20.041 DEBUG camillalib::biquad - a1=-1.948313741843362 a2=0.9489816091639206 b0=0.00016696683013967437 b1=0.00033393366027934874 b2=0.00016696683013967437
2021-05-09 19:54:20.041 DEBUG camillalib::biquad - a1=-1.948313741843362 a2=0.9489816091639206 b0=0.00016696683013967437 b1=0.00033393366027934874 b2=0.00016696683013967437
2021-05-09 19:54:20.041 DEBUG camillalib::biquad - a1=-1.5346539759579207 a2=0.5887907064808636 b0=0.7808611706096961 b1=-1.5617223412193921 b2=0.7808611706096961
2021-05-09 19:54:20.041 DEBUG camillalib::biquad - a1=-1.5346539759579207 a2=0.5887907064808636 b0=0.7808611706096961 b1=-1.5617223412193921 b2=0.7808611706096961
2021-05-09 19:54:20.041 DEBUG camilladsp - Config is valid
2021-05-09 19:54:20.041 DEBUG camilladsp - Wait for config
2021-05-09 19:54:20.042 DEBUG camilladsp - Config ready
2021-05-09 19:54:20.042 DEBUG camillalib::filters - Build new pipeline
2021-05-09 19:54:20.042 DEBUG camillalib::filters - Build from config
2021-05-09 19:54:20.042 DEBUG camillalib::biquad - a1=-1.5346539759579207 a2=0.5887907064808636 b0=0.7808611706096961 b1=-1.5617223412193921 b2=0.7808611706096961
2021-05-09 19:54:20.042 DEBUG camillalib::filters - Build from config
2021-05-09 19:54:20.043 DEBUG camillalib::biquad - a1=-1.5346539759579207 a2=0.5887907064808636 b0=0.7808611706096961 b1=-1.5617223412193921 b2=0.7808611706096961
2021-05-09 19:54:20.043 DEBUG camillalib::filters - Build from config
2021-05-09 19:54:20.043 DEBUG camillalib::biquad - a1=-1.948313741843362 a2=0.9489816091639206 b0=0.00016696683013967437 b1=0.00033393366027934874 b2=0.00016696683013967437
2021-05-09 19:54:20.043 DEBUG camillalib::filters - Build from config
2021-05-09 19:54:20.043 DEBUG camillalib::biquad - a1=-1.948313741843362 a2=0.9489816091639206 b0=0.00016696683013967437 b1=0.00033393366027934874 b2=0.00016696683013967437
2021-05-09 19:54:20.043 DEBUG camillalib::filters - Build from config
2021-05-09 19:54:20.043 DEBUG camillalib::biquad - a1=-1.5346539759579207 a2=0.5887907064808636 b0=0.7808611706096961 b1=-1.5617223412193921 b2=0.7808611706096961
2021-05-09 19:54:20.043 DEBUG camillalib::filters - Build from config
2021-05-09 19:54:20.043 DEBUG camillalib::biquad - a1=-1.5346539759579207 a2=0.5887907064808636 b0=0.7808611706096961 b1=-1.5617223412193921 b2=0.7808611706096961
2021-05-09 19:54:20.043 DEBUG camillalib::processing - build filters, waiting to start processing loop
2021-05-09 19:54:20.043 DEBUG camillalib::alsadevice - Buffer frames 2048
2021-05-09 19:54:20.051 DEBUG camillalib::alsadevice - Opening audio device "hw:Loopback,0,0" with parameters: HwParams { channels: Ok(2), rate: "Ok(48000) Hz", format: Ok(S16LE), access: Ok(RWInterleaved), period_size: "Ok(512) frames", buffer_size: "Ok(4096) frames" }, SwParams(avail_min: Ok(512) frames, start_threshold: Ok(0) frames, stop_threshold: Ok(4096) frames)
2021-05-09 19:54:20.051 DEBUG camillalib::alsadevice - Audio device "hw:Loopback,0,0" successfully opened
2021-05-09 19:54:20.061 DEBUG camilladsp - Capture thread ready to start
2021-05-09 19:54:20.062 DEBUG camillalib::alsadevice - Opening audio device "hw:S51" with parameters: HwParams { channels: Ok(6), rate: "Ok(48000) Hz", format: Ok(S16LE), access: Ok(RWInterleaved), period_size: "Ok(256) frames", buffer_size: "Ok(2048) frames" }, SwParams(avail_min: Ok(256) frames, start_threshold: Ok(768) frames, stop_threshold: Ok(2048) frames)
2021-05-09 19:54:20.062 DEBUG camillalib::alsadevice - Audio device "hw:S51" successfully opened
2021-05-09 19:54:20.062 DEBUG camilladsp - Playback thread ready to start
2021-05-09 19:54:20.062 DEBUG camilladsp - Both capture and playback ready, release barrier
2021-05-09 19:54:20.062 DEBUG camillalib::alsadevice - Starting captureloop
2021-05-09 19:54:20.062 DEBUG camillalib::alsadevice - Starting playback loop
2021-05-09 19:54:20.063 INFO camillalib::alsadevice - Capture device supports rate adjust
2021-05-09 19:54:20.089 INFO camillalib::alsadevice - Starting playback from Prepared state
 
no, i dont see any additional activity on the screen for camilladsp. With the camailladsp running

i also tried few other things

a) ran a local wave file using VLC. In VLC, i could select the output to the loopback, no sound from the sound card
b) ran speaker-test to the loopback (-D hw:Loopback,0,0)...i could see it toggle through the 6 channels but no sound from the sound card

in both cases there was no additional log on the camilladsp terminal

i did run speakertest (-D hw:S51 -c 6) when camilladsp is not running and i do get sound toggling through the various channels
 
Ok, if there is no more output, then camilladsp is stuck waiting for something. So we need to figure out what it's waiting for and why.
Can you try that again with -vv?
Also, can you try putting another loopback as the playback device? That won't give you any sound, it's just to see if it gets stuck or not.
 
is there a way i can pipe or send audio to the loopback to test if there is any sound coming out of the sound card. When i run the config file with -vv ....i can copy paste it but its a continuous flow of log output. As of now it seems that the config is up but i am not sure if i am able to send anything to it to process
 
Ok now I see the problem! If you send the sound to "Loopback,0,0", then you have to record it from "Loopback,1,0"!


Try modifying your devices section like this:


Code:
---  
devices: 
  samplerate: 48000 
  chunksize: 1024 
  capture: 
    type: Alsa 
    channels: 2 
    device: [B]"hw:Loopback,1,0" [/B]
    format: S16LE 
  playback: 
    type: Alsa 
    channels: 6 
    device: "hw:S51" 
    format: S16LE
Then run:
Code:
speaker-test -c 2 -D hw:Loopback,0,0