Skip to content

Synchronization

Phil Schatzmann edited this page Nov 16, 2023 · 18 revisions

Synchronization is important so that the all audio is played at the same time. I am currently not sure what the best solution would be, so I am providing a a quite flexible approach where you could even provide your own custom implementation.

The following logic is currently in place:

Startup Synchronization

The server is indicating with what delay each chunk should be played. The issue is that the processing time depends on the selected codec and output device, so the best to deal with this is to let the user define this processing time in the sketch.

Clock Synchronization

By comparing the time differences between the server and the client we can determine if both clocks have the same speed and adjust the playback speed if there are some small differences.

Available Synchronization Implementations

SnapTimeSyncFixed

We define the processing time is ms and the resampling speed factor:

static SnapTimeSyncFixed synch(123, 1.0);
client.begin(synch);
Clone this wiki locally