ahlstromcj / sequencer64

A major reboot of Seq24. Current release 0.97.0 (2021-05-13), native JACK MIDI, Song recording, playlists, and a Windows/Qt version. For fresher code, see the Seq66 project. Note that trigger and mute-group-in-MIDI-file formats have evolved! Back up your work!
GNU Affero General Public License v3.0
235 stars 29 forks source link

Jack midi less precise than alsa midi #73

Open Animtim opened 7 years ago

Animtim commented 7 years ago

TLDR: jack midi is less precise than alsa midi here, not precise enough to play with it. As long as it happens, we really need to keep the alsa option :) (also, if you need, I'm ready to test changes to fix this issue)

I tested on two different computers with different distros, and I always notice small "timing drops" (I'm not sure how to call that) when using jack midi. There is no xrun, but just playing a regular kick with a high bpm, it's easy to notice the time between kicks is not perfectly regular. Using alsa midi, it always works as expected. Also I tested with different audio sources (from ardour5 to standalone ones), and always notice this issue, so it must come from seq64.

Maybe I miss something in my system setup to improve jack midi, but if so I don't know what (I already have all tweaks from realtimeconfigquickscan and an rt kernel on one of the systems, tested with nohz on or off... I'm out of idea).

ahlstromcj commented 7 years ago

I'll check it out. Sounds like the input part of the process callback might delaying the output part.

Do you have a small MIDI file that demos the issue?

Chris

-------- Animtim 03:57 Mon 24 Apr --------

TLDR: jack midi is less precise than alsa midi here, not precise enough to play with it. As long as it happens, we really need to keep the alsa option :) (also, if you need, I'm ready to test changes to fix this issue)

I tested on two different computers with different distros, and I always notice small "timing drops" (I'm not sure how to call that) when using jack midi. There is no xrun, but just playing a regular kick with a high bpm, it's easy to notice the time between kicks is not perfectly regular. Using alsa midi, it always works as expected. Also I tested with different audio sources (from ardour5 to standalone ones), and always notice this issue, so it must come from seq64.

Maybe I miss something in my system setup to improve jack midi, but if so I don't know what (I already have all tweaks from realtimeconfigquickscan and an rt kernel on one of the systems, tested with nohz on or off... I'm out of idea).

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/ahlstromcj/sequencer64/issues/73

-- Q: Why did the astrophysicist order three hamburgers? A: Because he was hungry.

Animtim commented 7 years ago

Here is a little demo file. Play pattern q or 1 sent to a midi track in ardour5 with zynaddsubfx Drumskit1 preset. Also I'm not using jack transport.

TimeTest.zip

With jack midi, I can notice a subtle timing shift when the pattern loops. With alsa midi, it doesn't seem to happen.

Animtim commented 7 years ago

Note: the difference is maybe even easier to hear when using a drumkit soundfont, which has more predictable sounds (using Calf Fluidsynth here, on an ardour track..).

Animtim commented 7 years ago

Oh, I just noticed this timing issue is highly depending on jack buffer size. I initially had it set to 1024 (and 3 periods). Issue is subtle but can be heard. Then I tested with 256, and couldn't really hear the issue (but then I have occasional xruns, very few but still). Then I tested with 2048, and the issue gets really worse, really easy to hear it.

ahlstromcj commented 7 years ago

That's great information, thanks!

ahlstromcj commented 6 years ago

I set the JACK frame size (in qjackctl) to 2048 and heard the issue clearly. I then reduce the periods/buffer from 5 to 2, and that basically eliminated the issue. Still researching this topic with an eye to seeing if this issue is something a client can minimize.

ahlstromcj commented 6 years ago

Another way to reduce the artifact is to double the sampling rate from 48000 to 96000. What is ideal? Inquiring minds want to know!

chaocrator commented 6 years ago

it also depends of MIDI driver used — ALSA-sequencer or ALSA-rawMIDI. check your configuration (somewhere in qjackctl or cadence settings). in general, using of ALSA-sequencer driver with jack MIDI should be avoided.

Animtim commented 6 years ago

Hi, Actually I always had Midi driver set to None in my jack settings.

The issue with using ALSA Raw-midi there, is that then my usb controller doesn't appear anymore in the patchbay, neither with ALSA midi bridge nor as jack native ports.

(for info, when using Midi driver: none, the alsa midi bridge works. And when using Midi driver: ALSA sequencer, I have native jack port for the controller and alsa midi bridge also works for it...)