Latency is the time between BpmDj generating the sound and the sound actually coming out of the speakers.

Latency exists because intermediate buffers in OS (and sound card) must be filled up before they can be send to the speakers.

Latency is important because at the moment you want a sound modification using the XY-pad, that modification will be immediately executed on the audio stream being rendered. Of course, the sound generator was already further in the future than what came out of the speakers

That practically means that if you hear the beat and tap, then the filter will be applied halfway that beat. That is of course totally unwanted, and, although BpmDj always requests the lowest possible latency, latencies still vary wildly between android devices. From 15 msecs to 800 msecs.

We could blame android and the rest of the world for the lack of a real time OS, and the lack of super low latency drivers, the reality is that any multitasking OS with a garbage collected interpreted language will have problems offering what we might want.

I wrote 'might want' because latency can also exist due to external devices, such as effect boxes, or a mixing desk, or filters in the P.A. system introduce a delay.

Bottom line of all this is that BpmDj itself cannot know the exact latency; and that even if there were a super low latency solution it might not work in a realistic DJ setup.

Therefore we make it possible to 1) ask BpmDj for a specific latency, so that dropouts are minimal and 2) tell BpmDj what the actual latency is.

Setting the latency

To set and calibrate the latency, select Audio|Latency calibration from the menu

The dialog is split in two parts. The first section on 'Hardware' deals with latencies in the sound device. The first line 'Reported' tells you the latency according to the sound driver. Generally this is wrong. Some sound cards use one buffer and split it in smaller sections, which leads to an actual latency lower than the required one. Other sound cards, use multiple buffers, which lead to latencies that are substantially larger than what is requested. Then again other sound drivers resample the sound and cannot report a sensible latency.

The second line, labeled 'Wanted' allows you to type in the required latency of the sound device. When you set this value, BpmDj will ask the sound card for that specific latency. To obtain the smallest possible latency, type 0. Although, this is not advised because it often leads to dropouts, without actually improving the user interface experience. A latency of 300msecs is generally much nicer to work with.

Once you modified the requested latency, it might be useful to then actually measure the latency yourself. Very often the measured latency is totally different from what the sound device reports. See next section.

Latency Calibration

The second section, titled 'Measured' should start playing a metronome once you press 'reset'. If you now 'tap' at every high pitched tone (not the 3 in between), BpmDj will record the delay between it generating that tone and you hearing it. After about 8 taps you will see a variance of your tapping and by about 30 taps you should have a robust estimate of the actual latency. Press OK, to apply the latency. Press 'Reset' to try again (for instance if you tapped every beat instead of every bar).

How latency affects the XY-Pad

Once BpmDj has an estimate on the latency it will place all XY-pad events back in time. However, the real time modifications will still be out-of-place

Recording - if you use the XY-pad, the modifications you apply directly (by touching it and moving your finger), are applied directly to the output stream, but given the present latency will only come out after a while. E.g: you hear the beat at which point you want the LPF applied and you tap the pad, that filter will tend to be only heard halfway the beat.

Replay - when you replay the part you just recorded you will notice that the events have been placed back in time and that the LPF will fall at the moment you actually wanted it. Namely at the start of the beat.

Because recording and replay happen in time shifted universes, there will be some after-shadows. If you record something under great latency and then lift your finger from the XY-pad, you will see the events that you placed back in time come through the pipeline, which will generate a repetition of the movement you just made.