Linux: MIDI timing worse than seq24

I’m not 100% convinced that this is a Renoise defect, but I’ll post in the form of a bug report as it’s easier.

What I’m seeing is some lines come through on time, others come in a hundredth of a second early. In contrast, seq24 has a delay of up to 4 milliseconds. This is on Linux with neither of the apps running with root privileges.

I’m using a python 2 script to print the timings:

#!/usr/bin/env python

from __future__ import division
import alsaseq, time

bpm = 125
linesperbeat = 4
clientname = 'miditest'

def awaitnoteon():
 while True:
 e = alsaseq.input()
 if e[0] == alsaseq.SND_SEQ_EVENT_NOTEON:
 break

def main():
 linespersecond = linesperbeat * bpm / 60
 alsaseq.client(clientname, 1, 0, False)
 awaitnoteon()
 mark = time.time()
 while True:
 awaitnoteon()
 actualseconds = time.time() - mark
 lineindex = int(round(actualseconds * linespersecond))
 expectedseconds = lineindex / linespersecond
 print "%2s %9.6f" % (lineindex, actualseconds - expectedseconds)

if ' __main__' == __name__ :
 main()

Here is the seq24 result, with bpm=125 and one note per column:

1 0.002271
2 0.000719
3 0.003481
4 0.001512
5 0.003753
6 0.002033
7 0.000266
8 0.002677
9 0.000912
10 0.003651
11 0.002331
12 0.001707
13 0.000662
14 0.003542
15 0.002152
16 0.000838

And the Renoise result, with bpm=125 and one note per line:

1 -0.009790
2 0.000198
3 -0.009446
4 -0.009866
5 0.000654
6 -0.009107
7 0.001015
8 0.000465
9 -0.009483
10 0.000082
11 -0.009995
12 -0.010408
13 0.000561
14 -0.010518
15 0.000671
16 0.000163

Interestingly there appears to be a pattern repeating every 8 lines. Another way to look at the result is to consider the “mark” line as 5ms late and then every subsequent line is 5ms before/after where it should be.