MIDI recording shifted back, what is happening here?

Hey folks, short time lurker first time poster here. I’ve been playing around with Ardour and trying to get to a good creative workflow.

Today I noticed that my MIDI recording is a little off time, in particular the notes are showing up earlier than I would expect them to.

This is me playing along with the click track, playing a single drum sound on the beat. The audio track you see is a microphone recording me banging the key on the MIDI keyboard.

The audio shows up aligned on the beat as expected, I used jack_iodelay to configure the latency compensation and so that seems to work well, but the MIDI signal is shifted back a little.

Does this seem familiar to anyone? Is this latency overcompensation?

Ardour version: Ardour 6.3.0~ds0 “Hybrid” (rev 6.3.0~ds0-0ubuntu0.20.04.1) Intel 64-bit

Audio is coming from a Focusrite Saffire 6 USB, MIDI is a USB midi keyboard (launchkey mini). Jack is running via Cadence with a 512 sample buffer size, 11.6ms latency. Latency in/out compensation are set to 265 each based on jack_iodelay. MIDI is set to ALSA sequencer, connected via a2j.

Thanks a lot!

Update: It seems connecting the midi input to a midi bus first, and then recording the output of the bus fixes the issue.

Update2: seems it’s particular to the click track, I created my own click track by manually putting in some midi notes on a track and if I record along with that it lines up much better.

Does the issue persist if you use Ardour’s ALSA backend instead of JACK?