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

---
devices:
samplerate: 44100
buffersize: 1024
target_level: 512
adjust_period: 10
capture:
type: Alsa
channels: 2
device: "hw:Loopback,1"
format: S16LE
playback:
type: Alsa
channels: 2
device: "hw:1,0"
format: S32LE

filters:
lowpass_fir:
type: Conv
parameters:
type: File
filename: lowpass.txt
highpass_fir:
type: Conv
parameters:
type: File
filename: highpass.txt

mixers:
mono:
channels:
in: 2
out: 2
mapping:
- dest: 0
sources:
- channel: 0
gain: -6
inverted: false
- channel: 1
gain: -6
inverted: false
- dest: 1
sources:
- channel: 0
gain: -6
inverted: false
- channel: 1
gain: -6
inverted: false

pipeline:
- type: Mixer
name: mono
- type: Filter
channel: 0
dest: 0
names:
- lowpass_fir
- type: Filter
channel: 1
names:
- highpass_fir
 
It works, but doesn't sound right. No dynamics so to speak.
Sorry for this unusual configuration.
It's actually pretty similar to a stereo crossover, so not very unusual. Yu have an extra "dest: 0" in the pipeline section but that should not matter as is should just be ignored. Do you get any error messages about clipping? Can you post the output figures of the show_config script?
 
It's actually pretty similar to a stereo crossover, so not very unusual. Yu have an extra "dest: 0" in the pipeline section but that should not matter as is should just be ignored. Do you get any error messages about clipping? Can you post the output figures of the show_config script?

Removed "dest: 0".
Sofware installed to show show_config script.

Man, to get this displaying..allready glad i got this far.:D
 
So far so good :)

Hmm... don't understand whats wrong here :

pi@SuperBPI:~/Cfilters $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
Subdevices: 6/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: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/7
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

pi@SuperBPI:~/Cfilters $ cat /home/pi/.asoundrc
# Loopback device 0
pcm.squeeze {
type hw
card "Loopback"
device 0
format S32_LE
channels 2
}

# Loopback device 1
pcm.camilla_in {
type hw
card "Loopback"
device 1
format S32_LE
channels 2
}

pcm.sound_out {
type hw
card 1
device 0
}

ctl.sound_out {
type hw
card 1
}

Highpass.yml :
---
devices:
samplerate: 44100
buffersize: 1024
capture:
type: Alsa
channels: 2
device: "camilla_in"
format: S32LE
playback:
type: Alsa
channels: 2
device: "sound_out"
format: S32LE

filters:
highpass_test:
type: Biquad
parameters:
type: Highpass
freq: 3000
q: 0.5

pipeline:
- type: Filter
channel: 0
names:
- highpass_test
- type: Filter
channel: 1
names:
- highpass_test

Squeezelite is running fine (ps aux) but no sound ofcause :
squeezelite -n CamillaDAC -o squeeze -a 160 4 1 -b 10000 20000 -C 15 -z

When i start camilladsp i got :
pi@SuperBPI:~/Cfilters $ camilladsp highpass.yml
build filters, waiting to start processing loop
Playback error: ALSA function 'snd_pcm_hw_params_set_format' failed with error 'EINVAL: Invalid argument'

Where did i go wrong ?

Jesper.
 
Last edited:
Can you run and paste the output of:
Code:
arecord -D sound_out --dump-hw-params some_wav_file.wav
This should print all formats and sample rates supported by the card. I'm guessing it simply doesn't support 32-bit format.

You could also just try with S16LE and S24LE.
Yup... Henrik :)

Looks like sound_out and hw:1,0 does not work...
The hw:0,0 which is loopback are working.
I will proberly have my DAC tomorrow, and i will test again with that instead of the internal bcm sound of the RPI. - I think this will work as i see no errors in my config files!

pi@SuperBPI:~/Cfilters $ arecord -D sound_out --dump-hw-params *wav
arecord: main:828: audio open error: No such file or directory

pi@SuperBPI:~/Cfilters $ arecord -D hw:1,0 --dump-hw-params *wav
arecord: main:828: audio open error: No such file or directory

pi@SuperBPI:~/Cfilters $ arecord -D hw:0,0 --dump-hw-params *wav
Recording WAVE 'file_example_WAV_1MG.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device "hw:0,0":
--------------------
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S16_LE S16_BE S32_LE S32_BE FLOAT_LE FLOAT_BE
SUBFORMAT: STD
SAMPLE_BITS: [16 32]
FRAME_BITS: [16 1024]
CHANNELS: [1 32]
RATE: [8000 192000]
PERIOD_TIME: (5 65536000]
PERIOD_SIZE: [1 524288]
PERIOD_BYTES: [64 1048576]
PERIODS: [1 1024]
BUFFER_TIME: (5 131072000]
BUFFER_SIZE: [1 1048576]
BUFFER_BYTES: [64 2097152]
TICK_TIME: ALL
--------------------
arecord: set_params:1339: Sample format non available
Available formats:
- S16_LE
- S16_BE
- S32_LE
- S32_BE
- FLOAT_LE
- FLOAT_BE

squeeze alias is working too :

pi@SuperBPI:~/Cfilters $ arecord -D squeeze --dump-hw-params *wav
Recording WAVE 'file_example_WAV_1MG.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
HW Params of device "squeeze":
--------------------
ACCESS: MMAP_INTERLEAVED RW_INTERLEAVED
FORMAT: S32_LE
SUBFORMAT: STD
SAMPLE_BITS: 32
FRAME_BITS: 64
CHANNELS: 2
RATE: [8000 192000]
PERIOD_TIME: (41 16384000]
PERIOD_SIZE: [8 131072]
PERIOD_BYTES: [64 1048576]
PERIODS: [1 1024]
BUFFER_TIME: (41 32768000]
BUFFER_SIZE: [8 262144]
BUFFER_BYTES: [64 2097152]
TICK_TIME: ALL
--------------------
arecord: set_params:1339: Sample format non available
Available formats:
- S32_LE

I think i understand a lot more now, thanks!
 
I'll call it a night after numerous attemps.

pi@raspberrypi:~/camilladsp-develop $ python3 show_config.py /home/pi/simpleconfig.yml
Traceback (most recent call last):
File "show_config.py", line 8, in <module>
from matplotlib import pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
 
I'll call it a night after numerous attemps.

pi@raspberrypi:~/camilladsp-develop $ python3 show_config.py /home/pi/simpleconfig.yml
Traceback (most recent call last):
File "show_config.py", line 8, in <module>
from matplotlib import pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
Looks like you are missing matplotlib. Install it with:
Code:
sudo apt-get install python3-matplotlib
 
Bumped to this paper by TI: http://www.ti.com/lit/ug/tidu035/tidu035.pdf

Actually, I don't know how it performs but, any change to prepare DSP version of this using your tools?
Sure you can build the same filters with a bunch of Biquads.

For the tweeter you need to chain two Highpass filters for the 4:th order highpass, and then maybe replace the allpass with a simple delay. For the woofer you need a High- or LowShelf, and two chained Lowpass filters.
 
Looks like you are missing matplotlib. Install it with:
Code:
sudo apt-get install python3-matplotlib

That and a fresh raspbian install did it.

Config is right, it was the fir filter that was wrong I think.
Tried it with your IIR filter, great sound! :)
I created the Fir filters in Rephase. In Brutefir I used .bin filters and those worked.
Probably the culprit is I need mono filters. Right?

Output Rate Control. Works very good, no glitches.

Prepare playback
Current buffer level 752, set capture rate to 100.027214%
Current buffer level 849, set capture rate to 100.03821%
Current buffer level 734, set capture rate to 100.02516%
Current buffer level 514, set capture rate to 100.00023%
Current buffer level 451, set capture rate to 99.99309%
Current buffer level 456, set capture rate to 99.99365%
Current buffer level 488, set capture rate to 99.99728%
Current buffer level 508, set capture rate to 99.99955%
Current buffer level 520, set capture rate to 100.00091%
Current buffer level 520, set capture rate to 100.00091%
Current buffer level 513, set capture rate to 100.00012%
Current buffer level 517, set capture rate to 100.00057%
Current buffer level 514, set capture rate to 100.00023%
Current buffer level 513, set capture rate to 100.00012%
Current buffer level 511, set capture rate to 99.999886%
Current buffer level 515, set capture rate to 100.00034%
Current buffer level 514, set capture rate to 100.00023%
Current buffer level 515, set capture rate to 100.00034%
Current buffer level 511, set capture rate to 99.999886%
Current buffer level 512, set capture rate to 100%
Current buffer level 512, set capture rate to 100%
 
That and a fresh raspbian install did it.

Config is right, it was the fir filter that was wrong I think.
Tried it with your IIR filter, great sound! :)
I created the Fir filters in Rephase. In Brutefir I used .bin filters and those worked.
Probably the culprit is I need mono filters. Right?

Output Rate Control. Works very good, no glitches.

Prepare playback
Current buffer level 752, set capture rate to 100.027214%
Current buffer level 849, set capture rate to 100.03821%
Current buffer level 734, set capture rate to 100.02516%
Current buffer level 514, set capture rate to 100.00023%
Current buffer level 451, set capture rate to 99.99309%
Current buffer level 456, set capture rate to 99.99365%
Current buffer level 488, set capture rate to 99.99728%
Current buffer level 508, set capture rate to 99.99955%
Current buffer level 520, set capture rate to 100.00091%
Current buffer level 520, set capture rate to 100.00091%
Current buffer level 513, set capture rate to 100.00012%
Current buffer level 517, set capture rate to 100.00057%
Current buffer level 514, set capture rate to 100.00023%
Current buffer level 513, set capture rate to 100.00012%
Current buffer level 511, set capture rate to 99.999886%
Current buffer level 515, set capture rate to 100.00034%
Current buffer level 514, set capture rate to 100.00023%
Current buffer level 515, set capture rate to 100.00034%
Current buffer level 511, set capture rate to 99.999886%
Current buffer level 512, set capture rate to 100%
Current buffer level 512, set capture rate to 100%
Ah nice to see the rate control working!
What does the plot script show for your Rephase filters? What format are they in?
There is a new version that can handle raw files in a bunch of formats, just check out the "rawfiles" branch.
Mono filters should not cause any trouble at all. The cofficients file should anyway only contain coefficients for one channel.
 
Congrats for the rate control. Just a question of not understanding - looking at the source the printed capture rate value is that being passed to the rate control parameter Adjust rate of loopback capture device * HEnquist/camilladsp@653c929 * GitHub

Now if the CPU clock differs from the soundcard clock, why should the adjustment value converge to 100%, being the original value. Or does the adjustment "kick in" again after a while when the buffer fill deviates from 512? I thought the value would converge e.g. to 100.002 to account for the long-term clock difference. Thanks for the explanation.
 
Ah nice to see the rate control working!
What does the plot script show for your Rephase filters? What format are they in?
There is a new version that can handle raw files in a bunch of formats, just check out the "rawfiles" branch.
Mono filters should not cause any trouble at all. The cofficients file should anyway only contain coefficients for one channel.

32 bits floats lines.
Will check out the new version.

Still strange to me why it sounded dynamicless and strange yesterday.
Could a stereo filter and downmixing cause it?
 
Congrats for the rate control. Just a question of not understanding - looking at the source the printed capture rate value is that being passed to the rate control parameter Adjust rate of loopback capture device * HEnquist/camilladsp@653c929 * GitHub

Now if the CPU clock differs from the soundcard clock, why should the adjustment value converge to 100%, being the original value. Or does the adjustment "kick in" again after a while when the buffer fill deviates from 512? I thought the value would converge e.g. to 100.002 to account for the long-term clock difference. Thanks for the explanation.
It keeps regulating the speed. It's a dumb P controller, so no I or D. If the ideal rate is 100.002%, it won't settle exactly at the target level. If there is a need I could add the I to make it converge better. I don't expect it to be needed though, it probably doesn't matter if it settles at 520 samples instead of 512.
 
32 bits floats lines.
Will check out the new version.

Still strange to me why it sounded dynamicless and strange yesterday.
Could a stereo filter and downmixing cause it?
The downmixing should not cause strange sound or loss of dynamics. There must be something strange with your filters. Can you post the plots from the script? Preferrably from the new version that has some improvements.