Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
wiki:jack_latency_tests [2010/12/02 12:55] – lgarrido | wiki:jack_latency_tests [2012/05/30 15:00] – ZKwnnrjfKpqQkAYjkTd 94.23.1.28 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== JACK Latency tests ====== | + | It' |
- | + | ||
- | Yet to be interpreted results on measuring [[http:// | + | |
- | + | ||
- | <note warning> | + | |
- | + | ||
- | ===== Demystifying latency ===== | + | |
- | + | ||
- | Latency is one of those buzzwords which are often misunderstood by the layman or are indiscriminately bandied around as incontrovertible proof of the evident advantages of one' | + | |
- | + | ||
- | I once watched this guy in an audio forum talk about how he got less latency if he launched jackd from the command-line, | + | |
- | + | ||
- | So, leaving aside buzzwords, hype and urban legends, what is actually latency? [[http:// | + | |
- | + | ||
- | In the audio world, latency is the time elapsed between an action that produces sound and the actual perception of that sound by a listener. | + | |
- | + | ||
- | A very clear case of audio latency is the time it takes to hear the sound of thunder after you watch lightning from a distant storm (actually visual perception has latency too, since light doesn' | + | |
- | + | ||
- | ===== Latency sources ===== | + | |
- | + | ||
- | There are many factors that contribute to the total latency of a given system. Some of the more relevant are: | + | |
- | + | ||
- | * **Sound propagation through the air**: since it is a mechanical perturbation in a fluid, sound travels at comparatively slow [[http:// | + | |
- | * Your acoustic guitar or piano has a latency of about 1-2 ms, due to the propagation of the sound between your instrument and your ear . | + | |
- | * At a large concert venue if you are far away from the stage the sound will travel faster through the path " | + | |
- | * **Digital-to-Analog and Analog-to-Digital conversion**: | + | |
- | * **Digital Signal Processing**: | + | |
- | * **Computer I/O Architecture**: | + | |
- | + | ||
- | ===== Does latency really, really matter? ===== | + | |
- | + | ||
- | Less than most people think, in our opinion. There are only a few use-cases where is important for latency to be very low, because they require very quick response from the computer. Some examples that come quickly to mind are: | + | |
- | + | ||
- | * Playing virtual instruments. A large delay between the pressing of the keys and the sound the instrument produces will throw-off the timing of most instrumentalists (save if they are church organists, whom we believe are awesome latency-compensation organic systems.) | + | |
- | * Software audio monitoring. If a singer is hearing her own voice through two different paths, her head bones and headphones, large latencies can be disturbing. | + | |
- | * Live-effects. Precise synchronization may be important if you trigger manually sound effects like delays. | + | |
- | * Live-mixing (case example needed). | + | |
- | + | ||
- | In most other cases (such as playback, recording, overdubbing, | + | |
- | + | ||
- | In the end, it is not that much the size, but how well you use it. | + | |
- | + | ||
- | ===== The smaller the better? ===== | + | |
- | TODO | + | |
- | ===== Capture latency and playback latency ===== | + | |
- | TODO | + | |
- | ===== Measuring roundtrip latency with jack_delay ===== | + | |
- | TODO | + | |
- | ===== Adjusting latency ===== | + | |
- | TODO | + | |
- | + | ||
- | The [[http:// | + | |
- | + | ||
- | Low-latency is not always a feature you want to have. It comes with a couple of drawbacks: the most prominent is increased power-consumption because the CPS needs to process many small chunks of audio-data, it is constantly active and can not enter power-saving mode. Furthermore, | + | |
- | + | ||
- | Stable low-latency (≤10ms) on GNU/Linux can usually only be achieved by running [[https:// | + | |
- | + | ||
- | ===== JACK Latency enigma ===== | + | |
- | + | ||
- | JACK does report the port-latencies (run '' | + | |
- | The total latency depends on many factors: the bus (PCI, 1394, USB, Chipset), layers in between (DMA, IRQ) and of course the audio-interface itself. | + | |
- | + | ||
- | On a modern computer systems all these factors plus their configuration (PCI latency, bus speed, CPU/bus freq scaling, data-packet-framing, | + | |
- | + | ||
- | ==== Latency measurements ==== | + | |
- | + | ||
- | Fons Adriaensen has written a utility to measure the total round-trip latency called '' | + | |
- | + | ||
- | Even though the complete path of the digital audio-signal that adds latency is complicated, | + | |
- | + | ||
- | The diagrams below show the the total // | + | |
- | + | ||
- | The tests were done on Debian/ | + | |
- | + | ||
- | {{: | + | |
- | {{: | + | |
- | + | ||
- | ==== Interpretation and Analysis ==== | + | |
- | + | ||
- | Let's have a closer look: | + | |
- | The diagrams below show the difference between the // | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | {{: | + | |
- | {{: | + | |
- | + | ||
- | The small //residue// of additional // | + | |
- | However the results for USB-device is unexpected. | + | |
- | + | ||
- | There are two things that the authors of this article do not understand (and may be bugs in JACK): | + | |
- | - It seems that for USB devices JACK // | + | |
- | - The latency reported by JACK is inconsistent. | + | |
- | + | ||
- | Looking closer at these two issues: | + | |
- | + | ||
- | **(1)** plotting the // | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | **(2)** understanding the inconsistencies of reported port-latency will require digging into the source-code of JACK. Trying to reproduce this behaviour with jack-1 might also shed some light on the issue. It may also simply be a misinterpretation of the reported values. The information collected here is a first step: to make the issue clear to the authors. | + | |
- | + | ||
- | using '' | + | |
- | ALSA: use 2 periods for capture | + | |
- | ALSA: use 2 periods for playback | + | |
- | + | ||
- | and '' | + | |
- | ALSA: use 3 periods for capture | + | |
- | ALSA: use 3 periods for playback | + | |
- | + | ||
- | while jack_lsp -l (or [[http:// | + | |
- | | + | |
- | port latency = 1024 frames | + | |
- | | + | |
- | port latency = 2048 frames | + | |
- | + | ||
- | + | ||
- | "3 periods for capture" | + | |
- | + | ||
- | Alas, total latency measurement can not tell which it is. | + | |
- | + | ||
- | ===== References ===== | + | |
- | + | ||
- | * [[http:// | + | |
- | * [[http:// | + | |
- | * [[http:// | + | |
- | + | ||
- | ===== Raw data ===== | + | |
- | + | ||
- | + | ||
- | < | + | |
- | #UA-25, Linux 2.6.33.7-rt29 i386, jackdmp 1.9.6 | + | |
- | #JACK-cfg, measured lat [frames], measured lat [ms], nominal latency for record [frames], nominal latency for playback [frames], periods per cycle | + | |
- | #JACK-cfg: frames per period * periods per cycle / sample-rate / S: --sync | + | |
- | # | + | |
- | # values of ' | + | |
- | # | + | |
- | 4096*3/ | + | |
- | 4096*3/ | + | |
- | 4096*2/ | + | |
- | 4096*2/ | + | |
- | 2048*3/ | + | |
- | 2048*3/ | + | |
- | 2048*2/ | + | |
- | 2048*2/ | + | |
- | 1024*3/ | + | |
- | 1024*3/ | + | |
- | 1024*2/ | + | |
- | 1024*2/ | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | 64*3/ | + | |
- | 64*3/ | + | |
- | 64*2/ | + | |
- | 64*2/ | + | |
- | 32*3/ | + | |
- | 32*3/ | + | |
- | 32*2/ | + | |
- | 32*2/ | + | |
- | 16*3/ | + | |
- | 16*3/ | + | |
- | 16*2/ | + | |
- | 16*2/ | + | |
- | </ | + | |
- | + | ||
- | < | + | |
- | #HDA 1458:a002, Linux 2.6.33.7-rt29 amd64, jackdmp 1.9.6 | + | |
- | #JACK-cfg, measured lat [frames], measured lat [ms], nominal latency for record [frames], nominal latency for playback [frames], periods per cycle | + | |
- | #JACK-cfg: frames per period * periods per cycle / sample-rate / S: --sync | + | |
- | # | + | |
- | # values of ' | + | |
- | # | + | |
- | #2048*2 -> ALSA: cannot configure playback channel | + | |
- | #1024*3 -> ALSA: cannot configure playback channel | + | |
- | # | + | |
- | 4096*3/ | + | |
- | 4096*3/ | + | |
- | 4096*2/ | + | |
- | 4096*2/ | + | |
- | 2048*3/ | + | |
- | 2048*3/ | + | |
- | 2048*2/ | + | |
- | 2048*2/ | + | |
- | 1024*3/ | + | |
- | 1024*3/ | + | |
- | 1024*2/ | + | |
- | 1024*2/ | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | 64*3/ | + | |
- | 64*3/ | + | |
- | 64*2/ | + | |
- | 64*2/ | + | |
- | 32*3/ | + | |
- | 32*3/ | + | |
- | 32*2/ | + | |
- | 32*2/ | + | |
- | 16*3/ | + | |
- | 16*3/ | + | |
- | 16*2/ | + | |
- | 16*2/ | + | |
- | </ | + | |
- | + | ||
- | ===== Acknowledgments ===== | + | |
- | + | ||
- | Many thanks to Paul Davis and Stephane Letz for JACK and Fons Adriaensen for jack_delay. | + | |
- | + | ||
- | This article was written by Robin Gareus and Luis Garrido and may be redistributed in terms of the GFDL. | + |