Decides how many single frames to drop or repeat in a block to bring the playback back to its time, in small steps.
More...
|
|
| DriftController (long deadBandMicros, int correctionIntervalFrames) |
| |
|
void | reset () |
| |
|
void | addMeasurement (long driftMicros) |
| | A new measurement (call it only for a new position of the output).
|
| |
|
boolean | isReady () |
| | True when there are enough measurements to act on.
|
| |
|
long | smoothedMicros () |
| | The median of the measurements; 0 when there are none.
|
| |
| int | plan (int blockFrames, int sampleRate) |
| |
|
void | applied (long correctionMicros) |
| | Tells the controller that correctionMicros of drift were removed (positive: playback was moved earlier).
|
| |
Decides how many single frames to drop or repeat in a block to bring the playback back to its time, in small steps.
The drift is presentation time of the next frame - the time it should be presented: positive means late (frames are dropped), negative early (frames are repeated). Measurements arrive only when the platform reports a new position and are noisy, so the controller keeps the last {@value WINDOW} and acts on their median. A correction shifts all of them at once (what was corrected is no longer drift), so the controller does not overshoot while the median catches up. Corrections start above the dead band and stop below half of it (hysteresis), and are limited to one frame per correctionIntervalFrames frames played, so the audio is never stretched noticeably. Pure.