-
Notifications
You must be signed in to change notification settings - Fork 5
Synchronization
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:
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.
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.
We define the processing time is ms and the resampling speed factor:
static SnapTimeSyncFixed synch(123, 1.0);
client.begin(synch);
Since begin will use a reference to synch, we can't use a local variable. So either use a global variable or a static one.
We define the processing time is ms and how often the value is updated. The resampling speed factor is dynamically calculated by the system:
static SnapTimeSyncDynamic synch(123, 10);
client.begin(synch);
The resampling speed is adusted after every 10th update.