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

Well we all know what opinions are like right? You're welcome to look at the initial commit of the Makefile for the cflags.
I am sorry for not checking first. GCC 10 does not complain indeed.

Still the method snd_pcm_ioplug_hw_avail https://www.alsa-project.org/alsa-d..._plug.html#ga3b211c9fd355e60822a1015ee29206e8 takes and returns snd_pcm_uframes_t. This calculation mixes the two types as well https://github.com/scripple/alsa_cdsp/blob/master/libasound_module_pcm_cdsp.c#L372 . Have you perhaps considered using snd_pcm_uframes_t for io_hw_ptr, delay, buffer_delay, avoiding snd_pcm_sframes_t alltogether?
 
I am sorry for not checking first. GCC 10 does not complain indeed.

Still the method snd_pcm_ioplug_hw_avail https://www.alsa-project.org/alsa-d..._plug.html#ga3b211c9fd355e60822a1015ee29206e8 takes and returns snd_pcm_uframes_t. This calculation mixes the two types as well https://github.com/scripple/alsa_cdsp/blob/master/libasound_module_pcm_cdsp.c#L372 . Have you perhaps considered using snd_pcm_uframes_t for io_hw_ptr, delay, buffer_delay, avoiding snd_pcm_sframes_t alltogether?
I inherited much of this code from bluez_alsa. I'm thankful it was there as I really had no idea how to wake the player thread with the event_fd mechanism and not chew up tons of CPU. alsa documentation was its useful level of helpfulness. But the event_fd code in bluez_alsa had its own issues too. There was a race condition that might still be there. I found it only because one person in this thread reported a problem on one particular machine having 100% cpu usage which made me go carefully through it all and spot the race condition. I'm pretty sure it actually did affect bluez_alsa and mpd in the past also causing high CPU usage but unrelated changes to mpd magically avoided the race condition.

Now we have alsa randomly removing access to sw_params. Just like they make hw_params unreadable inside the hw_params hook. alsa has this bad idea of trying to recreate a public/private scenario like c++ classes in c. But it's just a hot mess. That and I have no idea why they want to make read only access to audio stream variables private. You know the joy of getting alsa to fix something though and even if they did it would be years until all the big distributions saw the changes in their LTS/stable branches.

Obviously we collectively found several other bugs with my timing/sleep calculations just in the last few days. Honestly I feel alsa plugins are just unnecessarily inconsistent and thus hard to get right. I tried this plugin in basically all the forms. External processor or whatever should be a good fit, but it has no mechanism to intercept drain and handle filter transients. So I had to go the more complicated IO plugin route to get the most control which alsa is now taking away.

Now we have io_hw_ptr which was unsigned up until yesterday and as you've pointed it out making it signed while making certain versions of gcc happy is still wrong. It really should be unsigned for its purpose but alsa chose to make it signed in the IO Plugin to make -1 a signal even though their own function wants it unsigned. The plugin probably needs carefully looked over to do the right thing and only use -1 when signalling the IO plugin code. I also am certain that the pointer boundary/wrap code is or will soon be a problem as it's a sw_param too. Probably safer but slower to try and make the buffer size wrap option the use case as the IO plugin provides buffer size in an explicit variable. However when I tried it quickly the plugin stalled as written. So that needs fixed too.

Unfortunately I have serious health conditions which drastically limit how much energy I have for such things and I just don't have the reserves to continue this now. If the plugin seems especially broken with the past few days' changes I suggest people revert back to the year old code which seems to have worked for many people and just deleting the avail_min read/update in the sw_params callback.
 
I just gave the updated plugin a quick spin. Seems to be working correctly on both Mint and Manjaro. Thanks for all the work @seashell !

About the Alsa bugs we have discovered, should we submit a bug report? I could do that. I know the "snd_pcm_sw_params_get_avail_min" returns rubbish. Does it do that always, or only in some cases? What others functions are broken?
 
In terms of actual plugin altering bugs avail_min and boundary need to be available to the IO plugin. We know for certain avail_min is not and yes that is consistent in newer versions of alsa but I don't know if it started in 1.1.19 or 1.2.x. I'm not sure of the boundary call. Boundary is an odd and large number so it might be returning the right value and it at least has a return code of 0 as documented.

I also noticed that snd_pcm_hw_params_get_period_size and snd_pcm_hw_params_get_buffer_size return and provide bad values like avail_min in the hw_params callback as the bluez_alsa workaround for the rate plugin calls them. Those two values are supplied explicitly in another way though.

Then there is the issue that the hw_ptr is signed in the io_plugin but unsigned in some alsa calls.
 
seashell - I keep fingers crossed for your fast recovery.

Please do not take my posts as a criticism. I am just trying to find potential issues for the sake of the project.

Yes, alsa is a VERY complex API, unfortunately with lots of inconsistencies. The API is huge, but it provides level of access and features unparalleled to any other existing audio framework. My experience with the core developers (i.e. Jaroslav and Takashi) is very good, I am convinced they would/will respond to bug reports constructively.

Unfortunately often the "rubbish" API output data turn out as a result of incorrect usage and/or incorrect input data. I believe the code/the plugin can work properly, it may just take more iterations to converge there. The code is not long, we should be able to put it right, should it be with assistance of core alsa developers.

Thanks for your great work.
 
  • Like
Reactions: 1 user
The discussions from reading this thread tend to the detailed development and bug-fixing but try as I might I cannot find any thread with a 'camilladsp' help for beginners. Is there one ?
Seems that a healthy coding background is a per-requisite to using camilladsp ?

I have used the included camilladsp with MoOde and had a smooth path to running with a custom .yml for AKG-K240 headphones and crossfeed..(thanks Micha !)
For 2 whole days now I have tried to install and run camilladsp on Xubuntu 20.04 and my brain is fried.

I have the binary running with the custom .yml, the gui accessed and showing the custom .yml, but no audio output and the gui reports 'offline' even when playing from the Parole music player.

Worse than that...audio no longer plays from any source :-(

Very happy to post configs etc but checking where best to post as I cannot find any help thread...:-(

Links would be most appreciated :)
 
The discussions from reading this thread tend to the detailed development and bug-fixing but try as I might I cannot find any thread with a 'camilladsp' help for beginners. Is there one ?
Seems that a healthy coding background is a per-requisite to using camilladsp ?

I have used the included camilladsp with MoOde and had a smooth path to running with a custom .yml for AKG-K240 headphones and crossfeed..(thanks Micha !)
For 2 whole days now I have tried to install and run camilladsp on Xubuntu 20.04 and my brain is fried.

I have the binary running with the custom .yml, the gui accessed and showing the custom .yml, but no audio output and the gui reports 'offline' even when playing from the Parole music player.

Worse than that...audio no longer plays from any source :-(

Very happy to post configs etc but checking where best to post as I cannot find any help thread...:-(

Links would be most appreciated :)

If you are using loopback rather than alsa_cdsp then there is a thread over at AudioScienceReview which might be helpful :

https://www.audiosciencereview.com/forum/index.php?threads/rpi4-camilladsp-tutorial.29656/
Its for RPI but its going to be close to what you need. And help is available here too. Have you perhaps altered or added asound.conf?

what do you get from aplay -l and aplay -L ?
 
thanks ! I did initially try the ASR tutorial modified for amd64 and same result.
Then followed the camilladsp site install using the binary.
what do you get from aplay -l and aplay -L ?

Code:
bob@bodaudacity:~$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Generic [HD-Audio Generic], device 0: ALC255 Analog [ALC255 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
bob@bodaudacity:~$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
    Playback/recording through the PulseAudio sound server
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
hw:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Direct hardware device without any conversions
hw:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Direct hardware device without any conversions
plughw:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Hardware device with all software conversions
plughw:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Hardware device with all software conversions
sysdefault:CARD=Loopback
    Loopback, Loopback PCM
    Default Audio Device
front:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Front output / input
surround21:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
dmix:CARD=Loopback,DEV=0
    Loopback, Loopback PCM
    Direct sample mixing device
dmix:CARD=Loopback,DEV=1
    Loopback, Loopback PCM
    Direct sample mixing device
usbstream:CARD=Loopback
    Loopback
    USB Stream Output
hw:CARD=HDMI,DEV=3
    HDA ATI HDMI, HDMI 0
    Direct hardware device without any conversions
hw:CARD=HDMI,DEV=7
    HDA ATI HDMI, HDMI 1
    Direct hardware device without any conversions
plughw:CARD=HDMI,DEV=3
    HDA ATI HDMI, HDMI 0
    Hardware device with all software conversions
plughw:CARD=HDMI,DEV=7
    HDA ATI HDMI, HDMI 1
    Hardware device with all software conversions
hdmi:CARD=HDMI,DEV=0
    HDA ATI HDMI, HDMI 0
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=1
    HDA ATI HDMI, HDMI 1
    HDMI Audio Output
dmix:CARD=HDMI,DEV=3
    HDA ATI HDMI, HDMI 0
    Direct sample mixing device
dmix:CARD=HDMI,DEV=7
    HDA ATI HDMI, HDMI 1
    Direct sample mixing device
usbstream:CARD=HDMI
    HDA ATI HDMI
    USB Stream Output
hw:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    Direct hardware device without any conversions
plughw:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    Hardware device with all software conversions
sysdefault:CARD=Generic
    HD-Audio Generic, ALC255 Analog
    Default Audio Device
front:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    Front output / input
surround21:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
dmix:CARD=Generic,DEV=0
    HD-Audio Generic, ALC255 Analog
    Direct sample mixing device
usbstream:CARD=Generic
    HD-Audio Generic
    USB Stream Output
bob@bodaudacity:~$

asound.conf is empty...?
 
Last edited:
Drone7: What do camilladsp logs say? Have you disabled your output device in pulseaudio?
Hmmm can't post the log as I get a forum error that the message is too long !!?! :) strange as I thought that was what code tags were for. ??
Posted as attachment.
Camilladsp appears to start and run, config is verified good, things seem ok then it reports this..

Code:
2022-02-21 00:17:48.717112 DEBUG [src/filedevice.rs:391] Entering stalled state

I've not disabled anything in pulseaudio.
I must be doing something wrong or not doing something but have no idea what :)
 

Attachments

  • camillaLog.txt
    10.9 KB · Views: 49
Can you also post your camilladsp.yml file please? Also logs seem to indicate the playback device is plughw:0,0 which seems to be your loopback device from you aplay post above. Maybe try plughw:2,0 instead as I am guessing this is the analog output from your soundcard (as per you aplay output above).
 
I tried with plughw:2,0 as you suggested but no output and still camilladsp gui reports as offline.
Here is the amended .yml
Code:
# This configuration for Henrik Enquist's CamillaDSP was created based on
# parametric equalizer correction data from Jaako Pasanen's AutoEq project
# AutoEq (https://github.com/jaakkopasanen/AutoEq)
# CamillaDSP (https://github.com/HEnquist/camilladsp)

devices:
  samplerate: 44100
  chunksize: 4096
  queuelimit: 1
  capture:
    type: File
    channels: 2
    filename: "/dev/stdin"
    format: S16LE
  playback:
    type: Alsa
    channels: 2
    device: "plughw:2,0"
    format: S16LE
mixers:
  XF_OUT:
    channels:
      in: 4
      out: 2
    mapping:
      - dest: 0
        sources:
          - channel: 1
            gain: 0.0
            inverted: false
            mute: false
          - channel: 3
            gain: 0.0
            inverted: false
            mute: false
        mute: false
      - dest: 1
        sources:
          - channel: 2
            gain: 0.0
            inverted: false
            mute: false
          - channel: 0
            gain: 0.0
            inverted: false
            mute: false
        mute: false
  XF_IN:
    channels:
      in: 2
      out: 4
    mapping:
      - dest: 0
        sources:
          - channel: 0
            gain: -8.0
            inverted: false
            mute: false
        mute: false
      - dest: 1
        sources:
          - channel: 0
            gain: -2.0
            inverted: false
            mute: false
        mute: false
      - dest: 2
        sources:
          - channel: 1
            gain: -2.0
            inverted: false
            mute: false
        mute: false
      - dest: 3
        sources:
          - channel: 1
            gain: -8.0
            inverted: false
            mute: false
        mute: false
filters:
  01_Preamp_Gain:
    type: Gain
    parameters:
      gain: -7.1
      inverted: false
      mute: false
  Correction_Eq_Band_0:
    type: Biquad
    parameters:
      type: Peaking
      freq: 29.0
      q: 1.21
      gain: 7.0
  Correction_Eq_Band_1:
    type: Biquad
    parameters:
      type: Peaking
      freq: 1226.0
      q: 1.6
      gain: 6.3
  Correction_Eq_Band_2:
    type: Biquad
    parameters:
      type: Peaking
      freq: 3443.0
      q: 1.47
      gain: 8.1
  Correction_Eq_Band_3:
    type: Biquad
    parameters:
      type: Peaking
      freq: 6397.0
      q: 1.04
      gain: -8.2
  Correction_Eq_Band_4:
    type: Biquad
    parameters:
      type: Peaking
      freq: 17940.0
      q: 0.39
      gain: 6.8
  Correction_Eq_Band_5:
    type: Biquad
    parameters:
      type: Peaking
      freq: 57.0
      q: 1.14
      gain: 5.5
  Correction_Eq_Band_6:
    type: Biquad
    parameters:
      type: Peaking
      freq: 137.0
      q: 0.42
      gain: -6.7
  Correction_Eq_Band_7:
    type: Biquad
    parameters:
      type: Peaking
      freq: 751.0
      q: 2.0
      gain: 2.6
  Correction_Eq_Band_8:
    type: Biquad
    parameters:
      type: Peaking
      freq: 5582.0
      q: 0.91
      gain: 0.9
  Correction_Eq_Band_9:
    type: Biquad
    parameters:
      type: Peaking
      freq: 5670.0
      q: 0.94
      gain: -0.9
  XF_Cross_Lowpass:
    type: Biquad
    parameters:
      type: Lowpass
      freq: 700.0
      q: 0.5
  XF_Direct_HighShelf:
    type: Biquad
    parameters:
      type: HighshelfFO
      freq: 950.0
      gain: 2.0
pipeline:
  - type: Mixer
    name: XF_IN
  - type: Filter
    channel: 0
    names:
      - XF_Cross_Lowpass
  - type: Filter
    channel: 1
    names:
      - XF_Direct_HighShelf
  - type: Filter
    channel: 2
    names:
      - XF_Direct_HighShelf
  - type: Filter
    channel: 3
    names:
      - XF_Cross_Lowpass
  - type: Mixer
    name: XF_OUT
  - type: Filter
    channel: 0
    names:
      - 01_Preamp_Gain
      - Correction_Eq_Band_0
      - Correction_Eq_Band_1
      - Correction_Eq_Band_2
      - Correction_Eq_Band_3
      - Correction_Eq_Band_4
      - Correction_Eq_Band_5
      - Correction_Eq_Band_6
      - Correction_Eq_Band_7
      - Correction_Eq_Band_8
      - Correction_Eq_Band_9
  - type: Filter
    channel: 1
    names:
      - 01_Preamp_Gain
      - Correction_Eq_Band_0
      - Correction_Eq_Band_1
      - Correction_Eq_Band_2
      - Correction_Eq_Band_3
      - Correction_Eq_Band_4
      - Correction_Eq_Band_5
      - Correction_Eq_Band_6
      - Correction_Eq_Band_7
      - Correction_Eq_Band_8
      - Correction_Eq_Band_9