Skip to content
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

Add latency tools #86

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

mildsunrise
Copy link
Contributor

@mildsunrise mildsunrise commented May 5, 2024

These PR adds two tools that I've found basic enough, to debug latency problems in the graph:

  • jack_lset: Corrects the latency reported by a (possibly buggy, or oblivious) client.

    It opens one or more input-output port pairs which pipe audio unchanged, but report a different latency at the other end.

    By default, the client adds the specified offset to the source latency, but it can also be made to replace the value entirely with the provided one (-A, --absolute).

    For cases where the input range has a width (min != max), the -j, --join option allows flattening it out into a single value. This uses the midpoint by default, but can be controlled (-l, --coefficient defaults to 0.5, setting it to 0 weights fully towards min, etc.).

  • jack_lsync: Delays each input-output pair as appropriate so that the latencies are aligned on the other end.

    This can be used to avoid unwanted de-syncs when a client in the pipeline introduces a delay that isn't introduced in another pathway, or for playback / recording across multiple devices.

    More precisely, the client looks at the input latencies across each port and chooses the maximum, which is called the "alignment latency". It then sets each delay line to the subtraction of the alignment latency minus that port's latency. It will dynamically adapt to changes in the latencies (due to e.g. reconnections), but it comes with a special mode (-k, --keep) that will never decrease the alignment latency, only increase it. The current implementation mutes the inputs while the delay lines are being resized, and it is careful to only do that if the delays have actually changed.

    The tool ultimately needs to pick a single value for the delay lines, so if min != max, it will flatten the range into a single value. Just like lset, it will use the midpoint by default but the -l, --coefficient option allows changing this.

Each instance of either of these tools can be made to operate either on playback latencies (-P, --playback) or capture latencies (-C, --capture). The amount of audio port pairs is variable (-a, --audio-ports), and so is the server and client name, as usual.

This PR is mainly to see if there would be interest in shipping these tools. They have been very valuable to me (and other people who have written emails thanking me).

(I actually wrote them 6 years ago on the tools repo, but didn't get to open the PR.)

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