midi out drift/jitter anyone?

Multi-platform modular music creation studio
Post Reply
User avatar
leondustar
Posts: 138
Joined: Tue Feb 28, 2017 12:40 am
Contact:

midi out drift/jitter anyone?

Post by leondustar »

For some reason my sunvox midi out is drifting on my desktop ubuntu 20.04.
It seems that my android phone seems to perform better when sending midi out over usb midi (I would have expected the opposite).
First I thought it was only external midi out, but I've been able to witness the same with virtual midi (in the box).

The testing setup I ended up with:

Image

Basically 2 multisynths: midiout is sending notes to puredata, and midiin is receiving those midi-notes from puredata (which simply echo's back the notes).
Puredata is running on the same machine (so it's virtual midi).

Image

Here you can see an audio-capture, which (in the top) shows midi-notes which made the roundtrip to/from puredata, and in the bottom exactly the same notes going immediately to a sunvox sampler.
It's not terribly bad, but it is enough to notice..again, interesting fact is that my moto g4 android phone has tighter miditiming compared to my beefy laptop.

What I tried to resolve the issue (but didn't help):

* installing lowlatency kernel (http://tedfelix.com/linux/linux-midi.html)
* ran this quick scan (which doesn't score too bad to explain the jitter): https://github.com/raboof/realtimeconfigquickscan

Image

Ps. probably a bug in the realtimeconfigquickscan, but I am running a PREEMPT kernel:

Code: Select all

$ uname -a
Linux ls540 5.11.0-41-lowlatency #45-Ubuntu SMP PREEMPT Fri Nov 5 13:55:43 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
What I didn't do: install JACK (as jack runs on top of ALSA, and is mostly focused on lowlatency audio, I want to rule out any other obstacles higher on the stack)

Anyone experienced this? Ideas? Tips?
I have dualboot, so I should check whether windows has the same jitter.
User avatar
NightRadio
Site Admin
Posts: 3941
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: midi out drift/jitter anyone?

Post by NightRadio »

1. I just found a bug in the ALSA MIDI OUT code :) So the SunVox 2.0 will give more accurate timings.
2. JACK should sound much better since there is a more accurate sync by default.
User avatar
leondustar
Posts: 138
Joined: Tue Feb 28, 2017 12:40 am
Contact:

Re: midi out drift/jitter anyone?

Post by leondustar »

thanks for the reply!
Great news!
Let me know if I can betatest something (and does the same bug apply to pixicode)?

Image

As you can see in the diagram, JACK would just use ALSA-midi too, so even if JACK would send perfect midi, i would expect the same end result.
ps. sorry for not being clear, I'm not so much concerned with sync between ALSA-midi & ALSA-audio (which JACK seems to do very well).
I'm concerned with the timing-difference/drifting between even-placed midi out notes in general (the sunvox sampler-signal was just a reference).

Basicaly, the usecase is: just outputting a steady 4/4 beat over midi (basically virtual and external midi-to-midi jitter),
Let me know if I'm forgetting something here.
User avatar
leondustar
Posts: 138
Joined: Tue Feb 28, 2017 12:40 am
Contact:

Re: midi out drift/jitter anyone?

Post by leondustar »

UPDATE: I have great news, the issue is solved.

First of all, thanks for solving the alsa midi-out bug.
(Meanwhile I switched from ubuntu to nixos).
Interestingly enough, I still experienced a little bit of drift with alsa midi-out on sunvox v2.1.1c.

BUT..when I changed the audio driver to SDL, midi-out became rocksolid 8)
Not only is it rocksolid now, there's ZERO noticable latency between audio and midi (when I press the start-button on a hardware groovebox) :Yahoo!:

With ALSA the audio-buffersize was always directly linked to the midi latency.
Perhaps SDL has audio/midi decoupled from eachother?

Not sure why this is, anyways I have the hybrid dream-setup I've always wanted.
Also, with the new midi effects (program change) patterns on hardware grooveboxes can be changed.
Thank you nightradio for all the efforts.
Post Reply