# Latency question

**URL:** <https://discourse.zynthian.org/t/latency-question/8815>\
**Category:** Using Zynthian\
**Created:** [November 29, 2023, 3:33am UTC](https://discourse.zynthian.org/t/latency-question/8815 "2023-11-29T03:33:23Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [November 30, 2023, 11:23am UTC](https://discourse.zynthian.org/t/latency-question/8815/21 "2023-11-30T11:23:56Z")

</div>

I hope I understand your question and give a sensible answer… Thank you

Yamaha Arius ydp-144 → usb → Zynthian Perfect  
Yamaha Arius → usb MacBook → usb Focusrite Scarlett 2i4 → Midi-5 → Zynthian Midi IN… latency

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [November 30, 2023, 11:29am UTC](https://discourse.zynthian.org/t/latency-question/8815/22 "2023-11-30T11:29:19Z")

</div>

Okay - that looks quite like the mac/foucsrite adding latency. MIDI-5 should not add any more latency than a direct USB connection.

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [November 30, 2023, 11:35am UTC](https://discourse.zynthian.org/t/latency-question/8815/23 "2023-11-30T11:35:27Z")

</div>

Thanks Riban, today I’ll do the same thing with the iMac and the Focusrite 18i18 and then I’ll tell you how it went… 😉

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [November 30, 2023, 2:52pm UTC](https://discourse.zynthian.org/t/latency-question/8815/24 "2023-11-30T14:52:30Z")

</div>

I suspect zynthian’s usb-gaget have high latency

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [November 30, 2023, 3:00pm UTC](https://discourse.zynthian.org/t/latency-question/8815/25 "2023-11-30T15:00:39Z")

</div>

This workflow does not use usb-gadget. MIDI is coming in on DIN-5 which uses ttyMIDI. ttyMIDI isn’t perfect but I don’t think the latency is worse than USB MIDI.

---

<div class="post-metadata">

**Author:** ![seanwayland](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/seanwayland/32/9716_2.png) [@seanwayland](https://discourse.zynthian.org/u/seanwayland)\
**Post date:** [November 30, 2023, 6:58pm UTC](https://discourse.zynthian.org/t/latency-question/8815/26 "2023-11-30T18:58:20Z")

</div>

Since I was able to match the Nord Stage which I think runs at 96khz using the midi din I wonder how much more it can be optimised.  
I did read this

[https://bugs.launchpad.net/bugs/822129](https://bugs.launchpad.net/bugs/822129)

Sean

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [November 30, 2023, 9:10pm UTC](https://discourse.zynthian.org/t/latency-question/8815/27 "2023-11-30T21:10:52Z")

</div>

AFAIK, no ftdi chips are used in the rbpi.

Regards

---

<div class="post-metadata">

**Author:** ![seanwayland](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/seanwayland/32/9716_2.png) [@seanwayland](https://discourse.zynthian.org/u/seanwayland)\
**Post date:** [December 1, 2023, 12:10am UTC](https://discourse.zynthian.org/t/latency-question/8815/28 "2023-12-01T00:10:30Z")

</div>

So much fun to be able to log in to a synth and also to be able to look at the source.  
It’s working fine as it as and I doubt it’s going to do much probably just break the machine but in this file

> <https://github.com/zynthian/zynthian-ui/blob/773276450d4184080f00e148f22ef042e3b029db/zynlibs/zynmixer/mixer.c>

I wondered if shrinking the size of the tinyosc buffer or restraining the number of max channels would make some negligble difference. I see a pretty largish usleep in eventThreadFn but don’t quite understand why that needs to be so long but I am just glancing at the code.  
Looking at TOP in linux I did see Xorg pretty high up the priority list and usage of CPU time.  
For fun I killed that process and crashed the machine. I hoped it might keep running without the screen.  
That might be an interesting feature to disable the screen and wake it up with a button .  
It’s probably making zero difference to the latency but I did see a bluetooth process running perhaps that’s a requirement but could potentially be disabled.  
I am happy with the latency just kind of fascinated by such a cool open source box.

---

<div class="post-metadata">

**Author:** ![riban](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/riban/32/2331_2.png) [@riban](https://discourse.zynthian.org/u/riban)\
**Post date:** [December 1, 2023, 6:09am UTC](https://discourse.zynthian.org/t/latency-question/8815/29 "2023-12-01T06:09:43Z")

</div>

The sleep in the mixer is for control - not audio processing. It avoids a tight loop which consumes CPU rapidly. We only need to react to level, mute, solo, etc. control at a relatively low rate (milliseconds). The audio processing has its own thread of operation and runs at the audio samplerate.

Zyngui is a monolithic process that runs the UI and backend. It depends on X for its GUI so stopping that is not currently possible. We do sleep the display for power saving but do not stop the GUI. We are working on separating the UI from the core which would allow a truely headless device to run. This in itself does not change latency but may reduce the CPU load allowing configuration to provide more CPU to audio process.

Bluetooth service is also being worked on right now in dev. In stable and current testing branches it is not used although the service is still running. The development we are now doing will allow control of the bluetooth service. I am yet to test the imact of stopping the service (it is a small daemon) but will do so and if advantageous, allow it to be disabled from the UI.

---

<div class="post-metadata">

**Author:** ![tunagenes](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/tunagenes/32/7279_2.png) [@tunagenes](https://discourse.zynthian.org/u/tunagenes)\
**Post date:** [December 2, 2023, 2:56am UTC](https://discourse.zynthian.org/t/latency-question/8815/30 "2023-12-02T02:56:37Z")

</div>

Speaking of latency, I know that this isn’t precisely the same thing as the audio latency that is the main topic here, but I’ve run across another project, MiSTer, a “Retro gaming” emulator that also has issues with latency.

Here’s a little snippet from their website:  
Controllers: MiSTer supports low-latency USB controllers and can essentially be a “zero lag” solution. I strongly recommend referencing the MiSTerAddons latency database to see which controllers work best, but here’s some cheap USB-based ones that are great… Snip

MiSTer As a Test Tool:  
The MiSTer hardware can also be used as a tool for many different uses. My favorite so far, is using it to test the latency of 3rd part controllers. Porkchop Express has been maintaining a database of latency results – And once again, MiSTer is the tool, not the test subject. These latency numbers would apply regardless of where it’s used (although some 3rd part / clone consoles / properly emulated systems/compilations can add their own lag on top of this): [RPubs - MiSTer FPGA Input Latency](https://rpubs.com/misteraddons/inputlatency)

And the link to an article about the project:

> **[MiSTer FPGA Hardware](https://www.retrorgb.com/mister.html)**
>
> The MiSTer is an open-source project that emulates consoles, computers and arcade boards via FPGA - This is different from software emulation, as there's potential for performance exactly like the original.  While software emulation has the...

I’m looking at MiSTer for examples of connecting an FPGA, akin to the FAST-FAUST project, not to play Stampede on an Atari 2600, I swear!

---

<div class="post-metadata">

**Author:** ![seanwayland](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/seanwayland/32/9716_2.png) [@seanwayland](https://discourse.zynthian.org/u/seanwayland)\
**Post date:** [December 2, 2023, 3:54am UTC](https://discourse.zynthian.org/t/latency-question/8815/31 "2023-12-02T03:54:24Z")

</div>

thanks for the response very interesting !

---

<div class="post-metadata">

**Author:** ![Lanfranco](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/lanfranco/32/8094_2.png) [@Lanfranco](https://discourse.zynthian.org/u/Lanfranco)\
**Post date:** [December 3, 2023, 6:30am UTC](https://discourse.zynthian.org/t/latency-question/8815/32 "2023-12-03T06:30:02Z")

</div>

I apologize to @Riban for the latency issue… I solved it by reinstalling MixBus on the MacBook (in fact, from tests carried out, I didn’t have any problems on the iMac). Now everything works perfectly… Thank you.

---

<div class="post-metadata">

**Author:** ![tunagenes](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/tunagenes/32/7279_2.png) [@tunagenes](https://discourse.zynthian.org/u/tunagenes)\
**Post date:** [December 6, 2023, 5:39am UTC](https://discourse.zynthian.org/t/latency-question/8815/33 "2023-12-06T05:39:14Z")

</div>

I’m replying to myself here… a further thought: In some ways Zynthian is like a game emulator, but for Synths-Sounds instead of Games-Screens&Sounds. Particularly in the case of ‘engines’ like Dexed that emulate specific hardware.

[Previous page](https://discourse.zynthian.org/t/latency-question/8815.md?page=1)
