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

OK, so not, but what I wanted exists - good. Can you describe the use for the Difference equation? The math is above me... :-/
//
I got several requests for it and it was easy to add. I don't actually know what they are using it for. Most things are easier to do with one or several biquads.

Sorry! The external playback had been paused earlier by mistake, so the second scenario involving the built-in speakers as playback device actually works as intended, however the original scenario still does not.
Ok! So it seems something locks up when recording and playing back on the same device. I'll try than on my old macbook to see if I can make it happen in catalina on intel.
If you want to play a little, could you try the feedback example of the cpal library?
cpal/feedback.rs at master * RustAudio/cpal * GitHub
Cpal is the library I'm using to provide both CoreAudio and Wasapi support.
 
OK, I might have an idea as to why we have an issue when the capture and playback device is in fact the same device. The following paragraph is taken from the official CoreAudio docs:
If you need to connect to an input device, or a hardware device other than the default output device, you need to use the AUHAL. Although designated as an output device, you can configure the AUHAL to accept input as well by setting the kAudioOutputUnitProperty_EnableIO property on the input (described in more detail in Technical Note TN2091: Device Input Using the HAL Output Audio Unit).
<snip>
An AUHAL instance can connect to only one device at a time, so you can enable both input and output only if the device can accept both. For example, the built-in audio for PowerPC-based Macintosh computers is configured as a single device that can both accept input audio data (through the Mic in) and output audio (through the speaker).
I suspect that the CamillaDSP code (or one of its libraries) isn't handling this special case, although I haven't been able to verify it by going through the code.
 
Last edited:
OK, so not, but what I wanted exists - good. Can you describe the use for the Difference equation? The math is above me... :-/

//

Difference Equation

The difference equation is a formula for computing an output sample at time based on past and present input samples and past output samples in the time domain.

  • Only past and present input samples: FIR filter
  • Both past and present input samples and past output samples: IIR filter

and

LTI system theory describes linear time-invariant (LTI) filters of all types. LTI filters can be completely described by their frequency response and phase response, the specification of which uniquely defines their impulse response, and vice versa.

and

The input-output characteristics of discrete-time LTI system are completely described by its impulse response

and

b(i) is the value of the impulse response at the i'th instant for N-order FIR filter. If the filter is a direct form FIR filter then b(i) is also a coefficient of the FIR filter.


So that is the relationship without maths between FIR,filter coeficients, inpulse-, frequency- and phase responce
 
Last edited:
You can use it to make a higher order filter, like a third or fourth order one, as a single filter. A biquad is by definition second order.
There are some optimization routines (in Matlab and others) that can fit a target response with an iir filter of arbitrary order (where higher orders give a better fit).
 
Just tried on my macbook, with both playback and capture on the internal sound card. Works fine. I'll see if I can find some usb-device to try on as well.
Update on that, if I run with Blackhole or SoundFlower as both capture and playback device, it gets stuck. But the cpal feedback example works fine with both of them so it should be possible to get this to work.
 
I think I solved it.. It seems like when both playback and capture are on the same device, then CoreAudio runs the callbacks for both in the same thread. So if the playback callback function gets delayed waiting for data, then the capture callback never gets called to provide the new data we need, and we are completely stuck... Nice work Apple...

I have a hacky version that works now, need to clean up a bit and then I'll make a new beta release.
 

TNT

Member
Joined 2003
Paid Member
I struggled a bit to set up my Apple Mac Mini and an RME Digiface USB (opto), but now I seem to have ended up where I want so I thought I'd share my configuration...

I use 3 DACs connected via opto, 1 each for the L&R mains and one for my subs (stereo) so I need to output 6 channels over 3 opto Toslink.

- I needed to setup the RME as a 8 channel system in OSX Audio Midi (might be OK with 6 actually!)
- In Camilla if you have a mixer using 6 channels, 8 is not ok to set in the Playback in the GUI:Devices tab. needed to also be 6 or Server Error. Maybe a little creature... :)

Below som screenshots of the used pipeline etc:
 

Attachments

  • OSX Audio_Midi.jpg
    OSX Audio_Midi.jpg
    232.1 KB · Views: 212
  • Mixer for 6 ch.jpg
    Mixer for 6 ch.jpg
    225.9 KB · Views: 207
  • rme setup 6ch in.jpg
    rme setup 6ch in.jpg
    384.2 KB · Views: 195
  • MyPipe.jpg
    MyPipe.jpg
    142.4 KB · Views: 223
Last edited:
I think I solved it.. It seems like when both playback and capture are on the same device, then CoreAudio runs the callbacks for both in the same thread. So if the playback callback function gets delayed waiting for data, then the capture callback never gets called to provide the new data we need, and we are completely stuck... Nice work Apple...

I have a hacky version that works now, need to clean up a bit and then I'll make a new beta release.
Awesome! I received the final bits of hardware I need for my active crossover today. Now I just need to stop refreshing this thread every five minutes to see if you've pushed out the beta release :D
 
I thank you for your effort but due to my limited math ability, I was not further illuminated I'm afraid. My bad. :)

Can you say one practical audio use-case please?

//

In ch5 in this:
https://www.diyaudio.com/forums/attachments/pc-based/916197d1611834653-camilladsp-cross-platform-iir-fir-engine-crossovers-correction-etc-mypipe-jpg
SubEQ,LP90 and LP90 could be made as one IIR (or FIR) filter.

But most people like the second order filters (biquads) that is inherited from analog filters, EQs and such

The most oversimplified comparation:
biquad form: Y=(X+a)(X+b)
difference form: Y=X^2 + (a+b)X + ab

Biquads then is Y1Y2Y3
difference X^6+iX^5+jX^4+kX^3 and so on

So Biquads if you like EQ of frequency responce and difference if you like tweeking the time response. Both results can sound and measure exactly the same
 
Awesome! I received the final bits of hardware I need for my active crossover today. Now I just need to stop refreshing this thread every five minutes to see if you've pushed out the beta release :D
Here it is!
Release v0.5.0-beta4 * HEnquist/camilladsp * GitHub


Changes since beta 3
New features:

  • Add debug feature for extra logging.
Bugfixes:

  • Don't block playback for CoreAudio/Wasapi if there is no data in time.
  • Validate silence_threshold and silence_timeout fields.
 
You mentioned silence_threshold and silence_timeout. I have values -90 and 5 (or 3 or 10). If I stop or pause player, camilla logs immediately

Jan 28 21:41:02.012 DEBG Resuming processing, module: camillalib::countertimer
Jan 28 21:41:02.019 WARN Prepare playback after buffer underrun, module: camillalib::alsadevice
Jan 28 21:41:02.383 TRCE Measured sample rate is 44227.928020298365 Hz, module: camillalib::alsadevice
Jan 28 21:41:03.405 TRCE Measured sample rate is 44185.994504519826 Hz, module: camillalib::alsadevice
Jan 28 21:41:04.427 TRCE Measured sample rate is 44185.065794917115 Hz, module: camillalib::alsadevice
Jan 28 21:41:05.449 TRCE Measured sample rate is 44187.53825294756 Hz, module: camillalib::alsadevice
Jan 28 21:41:06.470 TRCE Measured sample rate is 44228.570340689585 Hz, module: camillalib::alsadevice
Jan 28 21:41:07.313 DEBG Current buffer level: 14234.942028985508, corrected capture rate: 100.05598958333333%, module: camillalib::audiodevice
Jan 28 21:41:07.313 DEBG Playback buffer level: 14234.942028985508, signal rms: [-57.099934, -53.17141, -70.630974, -71.11831, -1000.0, -1000.0, -70.68629, -70.77243], module: camillalib::alsadevice
Jan 28 21:41:07.313 DEBG SetSpeed message received, module: camilladsp
Jan 28 21:41:07.492 TRCE Measured sample rate is 44187.615733741935 Hz, module: camillalib::alsadevice
Jan 28 21:41:08.513 TRCE Measured sample rate is 44228.70397795616 Hz, module: camillalib::alsadevice
Jan 28 21:41:09.534 TRCE Measured sample rate is 44228.85195455561 Hz, module: camillalib::alsadevice
Jan 28 21:41:10.555 TRCE Measured sample rate is 44230.19682775493 Hz, module: camillalib::alsadevice
Jan 28 21:41:11.576 TRCE Measured sample rate is 44229.99984648101 Hz, module: camillalib::alsadevice
Jan 28 21:41:12.597 TRCE Measured sample rate is 44230.17642381038 Hz, module: camillalib::alsadevice
Jan 28 21:41:13.619 TRCE Measured sample rate is 44186.21638719719 Hz, module: camillalib::alsadevice
Jan 28 21:41:14.640 TRCE Measured sample rate is 44229.02640013818 Hz, module: camillalib::alsadevice
Jan 28 21:41:15.661 TRCE Measured sample rate is 44230.239801729425 Hz, module: camillalib::alsadevice
Jan 28 21:41:16.682 TRCE Measured sample rate is 44228.725204046896 Hz, module: camillalib::alsadevice
Jan 28 21:41:17.385 DEBG Current buffer level: 15081.42372881356, corrected capture rate: 100.03393229166666%, module: camillalib::audiodevice
Jan 28 21:41:17.385 DEBG Playback buffer level: 15081.42372881356, signal rms: [-33.954437, -34.42286, -56.661762, -56.79401, -1000.0, -1000.0, -56.996952, -56.116158], module: camillalib::alsadevice
Jan 28 21:41:17.385 DEBG SetSpeed message received, module: camilladsp
Jan 28 21:41:17.703 TRCE Measured sample rate is 44229.6213657637 Hz, module: camillalib::alsadevice
Jan 28 21:41:18.771 TRCE Measured sample rate is 42282.671925840295 Hz, module: camillalib::alsadevice
Jan 28 21:41:19.792 TRCE Measured sample rate is 44229.23428977999 Hz, module: camillalib::alsadevice
Jan 28 21:41:20.813 TRCE Measured sample rate is 44231.00065417982 Hz, module: camillalib::alsadevice
Jan 28 21:41:21.835 TRCE Measured sample rate is 44186.05905433622 Hz, module: camillalib::alsadevice
Jan 28 21:41:22.670 DEBG Pausing processing, module: camillalib::countertimer
Jan 28 21:41:22.670 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:22.763 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:22.856 TRCE Measured sample rate is 44228.40278625618 Hz, module: camillalib::alsadevice
Jan 28 21:41:22.856 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:22.949 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:22.995 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.088 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.181 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.274 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.367 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.460 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.506 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.599 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.692 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.785 TRCE Pausing processing, module: camillalib::countertimer
Jan 28 21:41:23.877 TRCE Measured sample rate is 44227.218157968055 Hz, module: camillalib::alsadevice
...


Should not it wait for the time in silence_threshold?
 
Thanks - I chew on that ;)

I start to understand that it seems one can do more then the standard analog filters now with biquads.

//

With FIR and difference you can do more, with digital biquads you can do it cheaper than high tolerance capacitors and operational amplifiers;)

"An active RC circuit realizing a biquadratic transfer function is called a biquad. A singleamplifier biquad (SAB) is a biquad using one amplifier."
 
Last edited: