YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.multiroom.engine.DriftController Class Reference

Decides how many single frames to drop or repeat in a block to bring the playback back to its time, in small steps. More...

Collaboration diagram for de.yaacc.multiroom.engine.DriftController:
Collaboration graph

Public Member Functions

 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).
 

Static Public Attributes

static final int WINDOW = 7
 

Detailed Description

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.

Member Function Documentation

◆ plan()

int de.yaacc.multiroom.engine.DriftController.plan ( int blockFrames,
int sampleRate )
Parameters
blockFramesthe frames about to be played
sampleRateframes per second
Returns
frames to drop (positive) or repeat (negative) in this block; 0 for none
Here is the call graph for this function:

The documentation for this class was generated from the following file: