Re: New FreeBSD port ALSA to JACK MIDI, a2jmidid
Date: Sun, 27 Feb 2022 17:45:40 UTC
Ok, finally got around to measure and compare MIDI latency. The setup was: jack_midi_latency_test -> JACK -> jack_umidi -> USB -> MIDI out -> loop cable -> MIDI in -> USB -> jack_umidi -> JACK -> jack_midi_latency_test ... and the same with alsa-seq-server and a2jmidid instead of jack_umidi. Findings: - JACK processes MIDI in the same cycles (period) as audio. - The smaller the JACK period setting, the lower the latency. - Latency correction values set by JACK OSS backend are ignored. - alsa-seq-server and a2jmidid add noticeable latency vs. jack_umidi. For example a period of 384@48kHz (8ms) with jack_umidi reports Reported out-port latency: 0.00-0.00 ms (0-0 frames) Reported in-port latency: 0.00-0.00 ms (0-0 frames) Average latency: 11.93 ms (572.41 frames) Lowest latency: 8.02 ms (385 frames) Highest latency: 16.00 ms (768 frames) Peak MIDI jitter: 7.98 ms (383 frames) Average MIDI jitter: 1.99 ms (95.13 frames) whereas with alsa-seq-server and a2jmidid it is Reported out-port latency: 0.00-0.00 ms (0-0 frames) Reported in-port latency: 0.00-0.00 ms (0-0 frames) Average latency: 18.93 ms (908.83 frames) Lowest latency: 18.04 ms (866 frames) Highest latency: 21.81 ms (1047 frames) Peak MIDI jitter: 3.77 ms (181 frames) Average MIDI jitter: 0.29 ms (13.50 frames) which means it adds 7ms roundtrip latency on average. For 192@48kHz (4ms) we get Reported out-port latency: 0.00-0.00 ms (0-0 frames) Reported in-port latency: 0.00-0.00 ms (0-0 frames) Average latency: 5.97 ms (286.44 frames) Lowest latency: 4.02 ms (193 frames) Highest latency: 8.00 ms (384 frames) Peak MIDI jitter: 3.98 ms (191 frames) Average MIDI jitter: 1.00 ms (47.32 frames) versus Reported out-port latency: 0.00-0.00 ms (0-0 frames) Reported in-port latency: 0.00-0.00 ms (0-0 frames) Average latency: 10.78 ms (517.51 frames) Lowest latency: 10.00 ms (480 frames) Highest latency: 13.46 ms (646 frames) Peak MIDI jitter: 3.46 ms (166 frames) Average MIDI jitter: 0.27 ms (12.53 frames) which is a plus of ~5ms roundtrip latency on average. Please note that using jack_umidi, the latency values are spread uniformly between 1 and 2 periods, whereas alsa-seq-server produces more like a gaussian cut at the lowest latency. Conclusions: - For live playing, jack_umidi and small JACK period are preferable. - We have no way yet to adjust the MIDI latency to audio latency. - "Reported out-port latency" suggests possible latency correction values. - It may still be worth looking into the JACK ALSA MIDI backend for this. @HPS: Any ideas about the latency introduced by alsa-seq-server / CUSE? @Anyone else: What are your MIDI use cases where latency matters? Regards, Florian