Probably sufficient for most uses, especially at higher sample rates. If Fs=96kHz, the phase error is only 1° at 20kHz for a delay of 1.5 samples.It's quite tempting to use order = 2.
Note that a Thiran allpass is only stable for delay > N-1, where N is the filter order. I'd suggest a range of [N-0.9, N+0.1].Some plots, phase delay at 44.1 kHz, with fraction set to some evenly spaced values from close to 0 to just over 1
If you start the gui like this:How would I go about to do this?
then just don't start it, or stop it with ctrl-C if it's already running.3) Then start the gui :
cd /Users/au/camilladsp/gui
conda run -n camillagui python main.py
And then when starting camilladsp:
give it the verbose flag, -v or -vv, and also give it a config file on the command line. You don't need -w, the websocket port -p, and --statefile.4) ~/camilladsp/bin/camilladsp -w -p 1234 --statefile /Users/au/camilladsp/statefile.yml
Something like this:
~/camilladsp/bin/camilladsp -vv path/to/your.config.yml
So you don't have any glitches in the sound?It works, but for some reason my log file is getting demolished with lines like these:
The warning message means that reading was interrupted, and it's going to try again to read the rest. I have never seen it happen this often, it's usually a rare event. Can't say why it happens here (maybe @phofman has some idea?), but if it doesn't cause any glitches then the message should probably be on debug level instead of warn. For now you could set the log level to "error" to silence warnings: --loglevel error
Just in case it's useful to you, here's the C code for arbitrary-order filters using the ladder structure outlined in the paper I linked previously:
A biquad is faster than the above for N=2, of course, so this is only very useful if you want to support higher orders. The ladder structure is superior numerically, but that's hardly relevant in this case since you use double precision floats for biquads.
C:
/*
* Thiran fractional delay filters based on:
* Koshita, et al., "A Simple Ladder Realization of Maximally Flat Allpass
* Fractional Delay Filters," IEEE Transactions on Circuits and Systems II:
* Express Briefs, vol. 61, no. 3, pp. 203-207, March 2014
* DOI:10.1109/TCSII.2013.2296131
*/
struct thiran_ap_state {
int n;
struct {
double c0, c1, c2;
double m0, m1;
} fb[];
};
/* process one sample */
double thiran_ap_run(struct thiran_ap_state *state, double s)
{
double u = s;
for (int k = 0; k < state->n; ++k) {
u = u*state->fb[k].c0 + state->fb[k].m0;
u *= state->fb[k].c1;
state->fb[k].m1 = u;
}
double y = 0.0;
for (int k = state->n-1; k >= 0; --k) {
y += 2.0*state->fb[k].m1;
state->fb[k].m0 += y*state->fb[k].c2;
}
return s+y;
}
/* n is the filter order; delay is the target delay in samples */
struct thiran_ap_state * thiran_ap_new(int n, double delay)
{
if (n < 1 || delay <= n-1) /* unstable if delay <= n-1 */
return NULL;
struct thiran_ap_state * state = calloc(1, sizeof(struct thiran_ap_state) + n*sizeof(state->fb[0]));
if (!state) return NULL;
state->n = n;
for (int k = 0; k < n; ++k) {
state->fb[k].c0 = delay - k;
state->fb[k].c1 = -1.0 / (delay + (k+1));
state->fb[k].c2 = 2*k + 1;
}
return state;
}
Thanks, missed that little detail.Note that a Thiran allpass is only stable for delay > N-1, where N is the filter order
I'm experimenting with the Matlab code from here: https://ccrma.stanford.edu/~jos/pasp/Thiran_Allpass_Interpolation_Matlab.html translated to Python. It fails when delay = N. I added a hack to treat delay = N separately, but can there be trouble if delay is very close to N?I'd suggest a range of [N-0.9, N+0.1].
Nothing audible, and from the log spam you'd expect glitches galore.So you don't have any glitches in the sound?
Yeah that's what I've been doing, but would be nice to know what's happening so I can address it. May not cause issues now but my setup is only going to get more complex so who knows in the future.HenrikEnquist said:The warning message means that reading was interrupted, and it's going to try again to read the rest. I have never seen it happen this often, it's usually a rare event. Can't say why it happens here (maybe @phofman has some idea?), but if it doesn't cause any glitches then the message should probably be on debug level instead of warn. For now you could set the log level to "error" to silence warnings: --loglevel error
I can answer this myself, delay = N is not a problem.I'm experimenting with the Matlab code from here: https://ccrma.stanford.edu/~jos/pasp/Thiran_Allpass_Interpolation_Matlab.html translated to Python. It fails when delay = N. I added a hack to treat delay = N separately, but can there be trouble if delay is very close to N?
So the strategy then will be something like:
delay <0.1 sample --> ignore, set to zero
delay >0.1 and <=1.1 --> use first order allpass
delay >1.1 and <=2.1 --> use second order allpass
delay > 2.1 --> use second order allpass + delay line
And with a possible future improvement to add higher order allpass filters.
That should work well. As you've already realized, a0 should always be 1 but the algorithm computes it anyway, resulting in a division by zero when delay = N.
I'm trying to get the camilladsp-controller going now that the venv python binary is installed in /opt/venv/bin/python3.If you follow the instructions in the tutorial the venv python binary is installed in /home/username/camilladsp/.venv/bin/python3. If you look at the oled, flirc and camillagui services you will see they all run python from this location. For the controller you need to do the same, so running it will look something like "/home/michael1/camilladsp/.venv/bin/python3 /home/michael1/camilladsp/camilladsp-controller/controller.py -p 1234 -s "/home/michael1/camilladsp/configs/ultralitemk5_gadget_44c_44p.yml" -r 44100".
I have:
1. Install pyalsa :
sudo apt install python3-pyalsa
2. Re-install venv with the new system package pyalsa :
sudo python -m venv --system-site-packages /opt/venv
3. Install camilladsp-controller :
git clone https://github.com/HEnquist/camilladsp-controller ~/camilladsp/camilladsp-controller
4.run
/opt/venv/bin/python3 /home/camilla/camilladsp/camilladsp-controller/controller.py -d hw:UAC2Gadget -p 1234 -a /home/camilla/camilladsp/configs/Gin_96k_M4_out_96000.yml
Traceback (most recent call last):
File "/home/camilla/camilladsp/camilladsp-controller/controller.py", line 3, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
so I tried to install pyyaml
camilla@RPi5b94:~ $ source /opt/venv/bin/activate
(venv) camilla@RPi5b94:~ $ sudo pip3 install pyyaml
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
For more information visit http://rptl.io/venv
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Which do I try, apt install or --break-system-packages ?
This calls the system pip. You want pip from the venv. The easiest way is to activate the venv as you did, and then run pip as a module:sudo pip3 install pyyaml
python -m pip install pyyaml
I'm trying to get the camilladsp-controller going now that the venv python binary is installed in /opt/venv/bin/python3.
I have:
1. Install pyalsa :
sudo apt install python3-pyalsa
2. Re-install venv with the new system package pyalsa :
sudo python -m venv --system-site-packages /opt/venv
3. Install camilladsp-controller :
git clone https://github.com/HEnquist/camilladsp-controller ~/camilladsp/camilladsp-controller
4.run
/opt/venv/bin/python3 /home/camilla/camilladsp/camilladsp-controller/controller.py -d hw:UAC2Gadget -p 1234 -a /home/camilla/camilladsp/configs/Gin_96k_M4_out_96000.yml
Traceback (most recent call last):
File "/home/camilla/camilladsp/camilladsp-controller/controller.py", line 3, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
so I tried to install pyyaml
camilla@RPi5b94:~ $ source /opt/venv/bin/activate
(venv) camilla@RPi5b94:~ $ sudo pip3 install pyyaml
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
For more information visit http://rptl.io/venv
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Which do I try, apt install or --break-system-packages ?
IMO it is because you haven't installed pycamilladsp (or I should say installing pycamilladsp will install the necessary dependencies). If you run the instructions below from the tutorial (see FLIRC and OLED sections) and install python3-alsa, you should be good to go.
Code:
sudo apt install git python3-dev python3-aiohttp
sudo python -m venv --system-site-packages /opt/venv
source /opt/venv/bin/activate
pip3 install git+https://github.com/HEnquist/pycamilladsp.git
deactivate
Michael
Henrik, thank you, "python -m pip install pyyaml" got me past the yaml error, then it couldn't find pycamilladsp. Thank you Michael, I obviously had not installed pycamilladsp and offer the feeble excuse that I intended to install flirc later.
However, camilladsp-controller highlighted some different behavior depending on the version of win 11 that REW is running on, CamillaDSP running on a RPi5 in Gadget Mode, REW connected via usb and configured to output at 96k, then in the REW config screen, check level function to confirm signal to speakers, then perform a measurement, check level then measure.
Here is output from the controller when fed from win 11 version 23h2 -
Now here is the output from win 11 version 24h2 on a different pc with the same version of REW
With win 11 24h2 REW can output to the RPi in Gadget mode without the camilladsp-controller running provided sample rates are set correctly, thus simplifying REW measurements. However, as Windows 11 changes it's internals with every update it is strongly advised to use the controller.
However, camilladsp-controller highlighted some different behavior depending on the version of win 11 that REW is running on, CamillaDSP running on a RPi5 in Gadget Mode, REW connected via usb and configured to output at 96k, then in the REW config screen, check level function to confirm signal to speakers, then perform a measurement, check level then measure.
Here is output from the controller when fed from win 11 version 23h2 -
Code:
$ /opt/venv/bin/python3 /home/camilla/camilladsp/camilladsp-controller/controller.py -d hw:UAC2Gadget -p 1234 -a /home/camilla/camilladsp/configs/Gin_96k_M4_out_96000.yml
Found control 'Capture Rate' with index 4
Getting new config for rate: None, format: None, channels: None
Using new config from Adapt provider
CamillaDSP stopped because the capture format changed
Getting new config for rate: 96000, format: None, channels: None
Config has a resampler, change 'capture_samplerate' to 96000
No need for a 1:1 sync resampler, removing
Using new config from Adapt provider
Stopping CamillaDSP
Starting CamillaDSP with new config
Started
CamillaDSP stopped because the capture format changed
Getting new config for rate: 48000, format: None, channels: None
Config has a resampler, change 'capture_samplerate' to 48000
Using new config from Adapt provider
Stopping CamillaDSP
Starting CamillaDSP with new config
Started
CamillaDSP stopped because the capture format changed
Getting new config for rate: 96000, format: None, channels: None
Config has a resampler, change 'capture_samplerate' to 96000
No need for a 1:1 sync resampler, removing
Using new config from Adapt provider
Stopping CamillaDSP
Starting CamillaDSP with new config
Started
CamillaDSP stopped because the capture format changed
Getting new config for rate: 48000, format: None, channels: None
Config has a resampler, change 'capture_samplerate' to 48000
Using new config from Adapt provider
Stopping CamillaDSP
Starting CamillaDSP with new config
Started
Now here is the output from win 11 version 24h2 on a different pc with the same version of REW
Code:
$ /opt/venv/bin/python3 /home/camilla/camilladsp/camilladsp-controller/controller.py -d hw:UAC2Gadget -p 1234 -a /home/camilla/camilladsp/configs/Gin_96k_M4_out_96000.yml
Found control 'Capture Rate' with index 4
Getting new config for rate: None, format: None, channels: None
Using new config from Adapt provider
With win 11 24h2 REW can output to the RPi in Gadget mode without the camilladsp-controller running provided sample rates are set correctly, thus simplifying REW measurements. However, as Windows 11 changes it's internals with every update it is strongly advised to use the controller.
"With win 11 24h2 REW can output to the RPi in Gadget mode without the camilladsp-controller running provided sample rates are set correctly, thus simplifying REW measurements. However, as Windows 11 changes it's internals with every update it is strongly advised to use the controller."
Further testing with a Motu UltraLite Mk.5 proved me wrong. REW would kick a 44.1k or 48k signal after a level check sending CamillaDSP inactive.
So, camillaDSP-controller must always be used with REW.
Further testing with a Motu UltraLite Mk.5 proved me wrong. REW would kick a 44.1k or 48k signal after a level check sending CamillaDSP inactive.
So, camillaDSP-controller must always be used with REW.
At the moment I'm workng on improving the conversions between float and the chosen sample format, now using my new "audioadapter" crate. Might be of interest to @phofman since we have talked about this before 🙂
I get some quite nice speed improvements, these are benchmarks for converting back and forth between 64 bit float and 32-bit integer, for a stereo chunk with either 64 or 4096 frames:
I get some quite nice speed improvements, these are benchmarks for converting back and forth between 64 bit float and 32-bit integer, for a stereo chunk with either 64 or 4096 frames:
to_chunk_small time: [233.50 ns 236.19 ns 239.41 ns]
change: [-86.139% -85.374% -84.540%] (p = 0.00 < 0.05)
Performance has improved.
to_chunk_large time: [16.970 µs 17.659 µs 18.374 µs]
change: [-81.850% -80.595% -79.321%] (p = 0.00 < 0.05)
Performance has improved.
to_bytes_small time: [272.40 ns 278.95 ns 285.47 ns]
change: [-76.856% -75.630% -74.294%] (p = 0.00 < 0.05)
Performance has improved.
to_bytes_large time: [12.599 µs 12.884 µs 13.175 µs]
change: [-83.183% -82.140% -81.103%] (p = 0.00 < 0.05)
Performance has improved.
If I enable Rate Adjust I se the number ticking up +0.001 every 10-20 seconds but then also returns to 0 and even goes negative. What is this an indication of and should I have it activated?
//
//
Please read the section on enable_rate_adjust in https://github.com/HEnquist/camilladsp/ for explanation what that feature does. If you have no rate-adjustable capture device nor async resampler, CDSP has no use for the value (e.g. for OSX https://github.com/HEnquist/camilla...17182b63d051/src/coreaudiodevice.rs#L841-L857 )Should I have it activated?
Rate adjust uses a complicated algorithm involving averaging to estimate capture/playback rate ratio and cannot yield perfectly stable values, even for synchronous clocks.
Got the DIGIGRAM PCIe card installed yesterday. What an ordeal!
When I finally got it recognized DANTE Controller could not get it to go above 24/48.
The folks at DIGIGRAM are trying to help me but this product was not exactly READY to be sold for use in Linux.
(camilladsp is installed into UBUNTU desktop as suggested by mdsimon)
One thing to wrestle with something like camilladsp which is free to get started with (I promise, Mr. Enquist when I get it working a donation will be forthcoming) and can remain free if your conscience allows it. At least, there are instructions from mdsimon and Mr. Enquist that even a linux dummy like me could finally make my way through.
It was my experience in getting camilladsp installed that gave me the insights to get the card installed.
I think DIGIGRAM will figure out my problem and I will be able to use this,
Of course, it would be simplicity to get it to work on a WINDOWS machine but I doubt I could ever get camilladsp installed on WINDOWS!
If only mdsimon had a tutorial on how to do that!
Having become used to xilica's gui it will be a completely different experience with camilladsp. Being able to import filters from REW will be a great help but being able to see everything on one screen is a nice aspect of xilica's controller.
This will be an interesting experience. camilladsp offers so many more possibilities than xilica.
Again, my thanks to Mr. Enquist with the warning I will surely have further questions,
When I finally got it recognized DANTE Controller could not get it to go above 24/48.
The folks at DIGIGRAM are trying to help me but this product was not exactly READY to be sold for use in Linux.
(camilladsp is installed into UBUNTU desktop as suggested by mdsimon)
One thing to wrestle with something like camilladsp which is free to get started with (I promise, Mr. Enquist when I get it working a donation will be forthcoming) and can remain free if your conscience allows it. At least, there are instructions from mdsimon and Mr. Enquist that even a linux dummy like me could finally make my way through.
It was my experience in getting camilladsp installed that gave me the insights to get the card installed.
I think DIGIGRAM will figure out my problem and I will be able to use this,
Of course, it would be simplicity to get it to work on a WINDOWS machine but I doubt I could ever get camilladsp installed on WINDOWS!
If only mdsimon had a tutorial on how to do that!
Having become used to xilica's gui it will be a completely different experience with camilladsp. Being able to import filters from REW will be a great help but being able to see everything on one screen is a nice aspect of xilica's controller.
This will be an interesting experience. camilladsp offers so many more possibilities than xilica.
Again, my thanks to Mr. Enquist with the warning I will surely have further questions,
For the compact view of GUI I think that if the corresponding config elements is not set, the controls should not show. I realise one loses the "advertising" effect but it is a waste of space when not activated. At least on a phone.
The Volume slider is nice and have great resolution in that it supports decimal dB setting. But it's also a bit flimsy at times for what I would like to do. Would it be possible to add a + and - button for changing say 1 dB steps?
//
The Volume slider is nice and have great resolution in that it supports decimal dB setting. But it's also a bit flimsy at times for what I would like to do. Would it be possible to add a + and - button for changing say 1 dB steps?
//
How do one create a mixer structure like this: (se one line as a stereo pair channels)
Read the manual as well as tried in CDSP... the first mixer (left) would need to be 2to4 but then the output to from this mixer need to go to two different mixers - I dot get how to create that... but probably one have to do this in an other way...?
//
Read the manual as well as tried in CDSP... the first mixer (left) would need to be 2to4 but then the output to from this mixer need to go to two different mixers - I dot get how to create that... but probably one have to do this in an other way...?
//
- Home
- Source & Line
- PC Based
- CamillaDSP - Cross-platform IIR and FIR engine for crossovers, room correction etc