I re-ran some tests today using the latest PatchBox OS, which features a real-time kernel (4.19.71-rt24-v7l+) and other audio related optimizations. The results were not at all what I was expecting.
First, here is a comparison of device latencies using PatchBox versus Raspbian (kernel 4.19.118-v7l+):
|Raspbian||HiFiBerry ADC DAC+ Pro||48k||128||51.100 frames (1.0ms)|
|PatchBox||HiFiBerry ADC DAC+ Pro||48k||128||50-51 frames (1.0ms)|
|Raspbian||HiFiBerry ADC DAC+ Pro||48k||256||50.416 frames (1.0ms)|
|PatchBox||HiFiBerry ADC DAC+ Pro||48k||256||50-51 frames (1.0ms)|
|Raspbian||HiFiBerry ADC DAC+ Pro||96k||128||50.393 frames (1.0ms)|
|PatchBox||HiFiBerry ADC DAC+ Pro||96k||128||51-52 frames (1.0ms)|
|Raspbian||HiFiBerry ADC DAC+ Pro||96k||256||50.459 frames (1.0ms)|
|PatchBox||HiFiBerry ADC DAC+ Pro||96k||256||51-52 frames (1.0ms)|
|Raspbian||Sabrent USB||48k||128||451-453 frames (9.4ms)|
|PatchBox||Sabrent USB||48k||128||385-392 frames (8.1ms)|
|Raspbian||Sabrent USB||48k||256||498-500 frames (10.4ms)|
|PatchBox||Sabrent USB||48k||256||530-533 frames (11.1ms)|
My first observation is that there appears to be no material difference with latency when using the stock Raspbian kernel versus PatchBox’s real-time kernel with the HiFiBerry: all the measurements are consistently very low at about 51 frames.
Second, and this seems really weird: I got extremely consistent measurements for both the HiFiBerry and Sabrent on Raspbian, but a much wider range of measurements when using PatchBox.
Third, the Sabrent USB device results are inconsistent. The real-time kernel showed a modest advantage for 48k/128 but was worse for 48k/256. This performance degradation also manifests in the full round-trip test results below:
|HiFiBerry DAC+ ADC Pro||48k||128||1700-2300 frames (-6ms)|
|HiFiBerry DAC+ ADC Pro||48k||256||3122-3890 frames (-)|
|HiFiBerry DAC+ ADC Pro||96k||128||2483-2995 frames (+3ms)|
|HiFiBerry DAC+ ADC Pro||96k||256||4147-4403 frames (+2ms)|
|Sabrent USB||48k||128||2300-2900 frames (+2ms)|
|Sabrent USB||48k||256||3861-4117 frames (+4ms)|
With the exception of the HiFiBerry at 48k, using the real-time kernel in PatchBox OS increased latency, compared to the latest kernel provided by Raspbian.
All this makes me wonder what may have changed in the Linux kernel between 4.19.71 and 4.19.118? Perhaps there were material enhancements and/or patches made that include significant improvements for audio on Raspberry Pi?
Or, perhaps a real-time kernel is only beneficial when your workloads are taxing the CPU? JackTrip only generates a load of about 20% of a core. The model 4 Pi has four cores. Perhaps the overhead of a real-time kernel makes it a poor choice for this particular use case.