A2jmidid, very odd slow MIDI latency

Hi all, I’ve managed to remedy most of the issues I was having with the stability of firewire connection to my Focusrite Saffire Pro 26 I/O - the solution was to install an old KXStudio distro (14.04 x64) on the partition I want to use for music recording. Newer distros that include an alsa that includes the new firewire stack just were not working stably for me, so I went back in time to when ffado and alsa were separate entities - now Saffire connects at boot time and stays connected, and seems rock steady stable.

My only problem now is MIDI - in Cadence I turned on the alsa midi bridge to expose connected MIDI instruments to jack, and while that gives me all my MIDI devices and I can play notes to whichever MIDI instrument I’m using in Ardour, the latency is truly horrible (between 0.25 and 0.4 of a second) and it seems to only play a note like its on a timer about every 1/3 of a second, . Googling about this I found zero suggestions. Does anyone have any idea what might cause this?

Cheers, Chris W, NZ

I have a Saffire Pro 26 on a ROG Strix 399-e Gaming, Ryzen Threadripper, 12 core, 12 threads…

I used to have similar problems when i used alsa. Maybe my setup work for you as it is a Focusrite Firewire sound module, 8 in 6 out.

I followed some of the voodoo explained here
https://wiki.linuxaudio.org/wiki/system_configuration#solve_irq_conflict_by_unbinding_devices.
Some is outdated, some probably unnecessary and not doing anything. Some probably helps. The link show how to compile a custom kernel. How to configure some system timers. Prevent some kernel driver to load etc…

If you use the Firewire driver you can keep pulseaudio around. The link tell how to disable it. With the firewire driver it is possible to track when pulseaudio is playing something on the other soundcard. SoubBlaster Z in my case. Not a very good idea, but possible.

The ext4 tuning option noatime reduces the amount of disk I/O. Also in the link.

If you have a stock kernel it might be compiled with timer frequency 300 Hz, should be 1000 Hz. And there is an option “Use HR-timer as default sequencer timer” that probably is useful.

If you go with the 5.5.x kernels some of the firmware has changed a bit and are renamed. The kernel source and firmware can be downloaded from kernel.org.

OK… Let’s say you have built your own kernel or installed a low latency kernel or an rt-kernel. Done some of the voodoo in the link above…

Then write this in /etc/modprobe.d/blacklist.conf
blacklist snd_dice

blacklist snd_dice stops the alsa driver for the Saffire pro 26 to be loaded and make it possible to start jack with the Firewire driver.

Launch qjackctl. Setup => Driver firewire.
Realtime
Frames 48000
Periods 2
(i go with 48K for the lower latency)

Under tab Options check Execute script after Startup => a2jmidid -e &

Finally launch Ardour

Hi Forsland, the distro I installed for audio work, KXStudio 14.04 x64, already has an RT kernel with all necessary patches, timing (1000Hz), and more setup to create a stable audio recording setup - in general the setup works very very nicely on my 6-core AMD Phenom 2 system with 8GB RAM.

I have discovered something interesting however - ZynAddSubFX is the only software/plugin that has MIDI latency/timing trouble, it seems all other MIDI instrument apps work fine. The version of Zyn installed in KXStudio 14.04 is quite old, so I’ll try to update it to the latest Zyn Fusion and see if that fixes the problem.

Cheers, Chris W, NZ

Interesting. Have you tried jack/ffado on a recent distro instead of ALSA? Is this really a firewire stack regression, or only an issue with the ALSA-firewire driver?

Edit: see also https://linuxmusicians.com/viewtopic.php?t=19429

Hi Robin, I initially tried to get a working FW audio setup in Linux Mint 19.3 x64 Cinnamon, but in either alsa or ffado the connection wouldn’t persist after closing an audio app, plus it was a bit unstable - just trying to connect to the interface could take several attempts and sometimes hard lock the PC. If I used alsa I couldn’t use ffado-mixer as the versions were mismatched, and if I blacklisted alsa modules and used ffado I could use ffado-mixer but the system was still unstable. I also had trouble getting jackd to start when using ffado/firewire. So I went back in time and installed KXStudio 14.04 which came out before the FW stack was introduced into alsa - after a couple of tries getting jack settings sorted the 26 I/O now connects up at boot time and stays connected - since then I’ve not had a firewire stream dropout, or infact a single xrun. Getting my MIDI controllers to talk to ZynAddSubFX without bad latency is now the only issue.

I’m going to stick with KXStudio 14.04 because I’m 99% of the way there to a rock-solid audio recording and production setup, and while new versions of alsa seems to have made decent strides including very low latency (at least on my system) audio with firewire support, not having access to the controls for the Saffire Pro 26 I/O exposed by ffado-mixer, is a deal breaker. I’m a bit surprised that ffado by itself in Linux Mint 19.3 was unstable, but ffado in KXStudio 14.04 has been bullet proof so I’ll stick by it.

Cheers, Chris W, NZ

…and in the good news section… the MIDI latency thing is solved! In the package manager there were a few plugin options for ZynAddSubFX including LV2 and DSSI versions - so I tried a different LV2 version and a Zyn data pack - the LV2 plugin I switched to exhibits none of the wonky MIDI latency I was having trouble with! :slight_smile: :grin:

That is worrying. It is known that the new ALSA/Firewire stack doesn’t yet work reliably for all cards/chipsets, but blacklisting it and using ffado should not have regressed.

Anyway, I’m glad you got it all working.