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?

Same problem here!
Midi notes during recording:


Midi notes after stopping recording:

It does not matter if using ALSA or JACK backend.

I’ve tested it with Ardour versions 5.12.0 and 6.6.0. Same effect with both versions.

I tried both workarounds suggested by user @Arne_Brasseur . Using a Midi Bus works better. Using a separate Klick-Track has no effect.

Thank you for you help!
BR Johann