Skip to content

Add jack_position_t::tick_double, and flags around it #770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 5, 2021

Conversation

falkTX
Copy link
Member

@falkTX falkTX commented Jul 5, 2021

This PR adds tick_double to jack_position_t and JackTickDouble as a validation flag for it.
Since older versions of JACK do not expose this variable, the macro JACK_TICK_DOUBLE is provided, which can be used as build-time detection.

Example code for transport-listening clients:

double tick;
#ifdef JACK_TICK_DOUBLE
if (pos.valid & JackTickDouble)
    tick = pos.tick_double;
else
#endif
    tick = pos.tick;

Rationale:
When using JACK transport to sync between clients with precise timing requirements (such as MIDI sequencers) rounding errors would accumulate and eventually make the separate clients out of sync.
This was observed in Carla and mod-host, which use audio plugins as JACK clients. Some MIDI plugins could miss notes due to rounding errors. This change has been deployed in MOD Devices for a couple of releases already and it is known to work (that is, it corrects the situation).
Since the transport API has padding members available for use and it has been unchanged for several years (so there won't be a need to add more fields in the short or middle term), let's just go for it.

@falkTX falkTX merged commit 814629b into develop Jul 5, 2021
@falkTX falkTX deleted the tranport-tick-double branch July 5, 2021 19:25
@falkTX
Copy link
Member Author

falkTX commented Jul 14, 2021

To add some extra notes here:

There was discussion on IRC about this potentially be unnecessary, that clients can just use bar_start_tick to store the non-integer part of the tick.
While the idea could work in theory, supporting it turns out to be non-trivial and from all applications that I have tested none implemented this part correctly.
Some applications do not set bar_start_tick at all, even though they can be run as transport master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant