Latency in stable-2211

I don’t know if this issue is specific to stable-2211, but it’s the version I’m running now at least. I think it’s been the same for a long time, but I’ve never made the effort to look into it.

My setup is a master keyboard feeding the Zynthian, a Blofeld and an Access Virus KC, all via DIN MIDI. When playing the Zynthian, I get the feeling that there’s a bit too much latency, it feels like there is a slight delay which I don’t notice with the other two (hardware) synths. Thinking it might just be my imagination, I simultaneously recorded the audio of all three into my DAW, and noted that the Blofeld vs. Zynthian has a whopping 23 ms of delay (which coincides with my impression that there is a slight flam when playing percussive sounds); in comparison, the Blofeld vs. the Virus turned out to be about 4 ms. I tried ZynAdd SubFX and Pianoteq on the Zynthian, both with the same results.

I’m using the standard sample rate (44.1 kHz) and buffer size (-b 256 -n 2) settings on the Zynthian. The 23 ms I noted is suspiciously close to four times the buffer length (4 * 256/44100).

For comparison, I started up ZynAddSubFX on a freestanding PC with JACK, set to the same latency parameters as Zynthian. I didn’t actually measure the latency, but experimenting with different settings make me feel like the latency on this platform is more what I’d expect given the settings. A setting of -b 512 -n 2 (i.e. twice the buffer size as the Zynthian) gives me the same “23 ms flam” feel as the Zynthian at -b 256 -n 2.

While I could of course file a bug report, I thought I’d bring it up to discussion here first, in case there is some known issue, or there’s some for me not too obvious thing that I’ve overlooked.

Are the synths all hooked up in one ‘daisy chain’? And are you using midi ‘out’ or ‘through’ ports to build it?

I’m wondering if that could be (or contribute to) the delay. You could re-order the synths to eliminate that possibility.

No daisy chain. The master keyboard feeds a MIDI patchbay (Yamaha MJC-8) to which the instruments are connected.

(Incidentally, a classic ‘midi thru’ port on a MIDI device does not add any appreciable latency, there is a small delay through the hardware but it is in the nanosecond range. There can be signal degradation though which can cause issues. A software ‘midi thru’ will add at least one MIDI byte worth of latency (320 microseconds) and probably more depending on the actual device, but that’s not what I’m using here. The MJC-8 routes the MIDI signals in hardware and thus is equivalent to a classic ‘midi thru box’).

Is this an official kit? Can you bung up a screenshot of the webconf with the deets?

@ricard you are correct in expecting 11.6ms latency for a soundcard configured with 2 buffers, each with 256 frames and clocked at 44100 frames per second. This is the theoretical minimum latency introduced by the computing process of transferring audio through the system. Jack performs concurrent processing on client’s buffers so we expect to see this latency from source to output, e.g. synth engine to audio outlet. There are other things that can add latency but they tend to be less than 1ms in total so we can ignore those for now.

Of course the synth needs to be triggered and that could be the cause of the extra latency, e.g. the incoming MIDI needs to be processed by the same jack chain hence there is the possibility that it could take 11.6ms for the MIDI to hit the engine before the engine starts to create any audio.

In your experiment with zynaddsubfx on another platform, were you using jack or alsa MIDI? Also, the mechanism by which we get MIDI from the physical 5-pin DIN is via a couple of processes which may also introduce some latency. It would be useful to know what the latency is via a USB connected controller. I don’t have the time or resources to test this at the moment but we should certainly figure out what is doubling the latency.

1 Like

On the other platform (basically a touchscreen laptop running Debian Linux, about 10 years old, so similar computing power wise similar to the Zynthian) I’m using ALSA MIDI, arriving from my master keyboard via a Roland MIDI interface.

@Baggypants It’s a standard v4.4 original Zynthian. The only change I’ve made to the default configuration is configuring the four soft keys, plus I’m running the latest ZynAddSubFX built from github (same as on the PC). I’ll post a screen shot of the relevant parts of the webconf when I get a chance.

I’ll try out a couple of other synth engines and see if they all have the same latency. I’ll also try with a keyboard with USB.

1 Like

So I got out a Blofeld Keyboard which has both DIN and USB MIDI. Comparing DIN and USB MIDI, I found that USB MIDI was slightly faster, in the order of 1 ms.

I also compared a couple of other synth engines besides Zyn. First of all I should note that this time I was comparing the build-in synth engine in the Blokeys against Zynthian, so the difference in latency was slightly larger compared to my previous test, being 26 ms for Zyn over DIN MIDI, and 25 ms over USB MIDI.

OB-Xd was slightly faster, at 24 ms over DIN MIDI and 23 over USB MIDI. Dexed was even faster, at 20 ms over DIN MIDI vs 18 over DIN MIDI (the fact that the diff was 2 rather than 1 here I’m attributing to rounding errors).

So Zyn seems to be the worst of the lot, but the latency is still fairly consistently long across all the synth engines that I tried. Even with Dexed, one can hear clear flamming when playing.