arduino-snapclient
Public Member Functions | Protected Attributes | List of all members
SnapTimeSync Class Referenceabstract

Abstract (Common) Time Synchronization Logic which consists of the startup synchronization and the local to server clock synchronization which adjusts the sampling rate. More...

#include <SnapTimeSync.h>

Inheritance diagram for SnapTimeSync:
SnapTimeSyncDynamic SnapTimeSyncDynamicSinceStart SnapTimeSyncFixed

Public Member Functions

 SnapTimeSync (int processingLag=CONFIG_PROCESSING_TIME_MS, int interval=10)
 
void begin (int rate)
 Starts the processing.
 
virtual float getFactor ()=0
 
int getStartDelay ()
 
bool isSync ()
 Returns true if a synchronization (update of the sampling rate) is needed.
 
void setInterval (int interval)
 
void setMessageBufferDelay (int ms)
 Defines the message buffer lag.
 
void setProcessingLag (int lag)
 
virtual void updateActualDelay (int delay)
 Records the actual playback delay (currently not used)
 
virtual void updateServerTime (uint32_t serverMillis)=0
 Records the actual server time in millisecondes.
 

Protected Attributes

bool active = false
 
int interval = 10
 
uint16_t message_buffer_delay_ms = 0
 
uint16_t processing_lag = 0
 
const char * TAG = "SnapTimeSync"
 
uint64_t update_count = 0
 

Detailed Description

Abstract (Common) Time Synchronization Logic which consists of the startup synchronization and the local to server clock synchronization which adjusts the sampling rate.

Author
Phil Schatzmann
Version
0.1
Date
2023-10-28

Member Function Documentation

◆ getFactor()

virtual float getFactor ( )
pure virtual

Calculate the resampling factor: with a positive delay we play too fast and need to slow down

Implemented in SnapTimeSyncFixed, SnapTimeSyncDynamicSinceStart, and SnapTimeSyncDynamic.

◆ getStartDelay()

int getStartDelay ( )
inline

Provides the effective delay to be used (Message buffer lag - decoding/playback time)

◆ setInterval()

void setInterval ( int  interval)
inline

Defines the interval that is used to adjust the sample rate: 10 means every 10 updates.

◆ setProcessingLag()

void setProcessingLag ( int  lag)
inline

Defines the lag which is substracted from the message_buffer_delay_ms. It conists of the delay added by the decoder and your selected output device


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