Ableton / link

Ableton Link
Other
1.09k stars 149 forks source link

forceBeatAtTime notification #63

Closed samkuhn closed 5 years ago

samkuhn commented 5 years ago

Hi Guys, We're currently trying to integrate with the cpp library and have a legitimate need for forceBeatAtTime (we are purely controlling visuals through link and sometimes a re-sync is necessary to keep in time with external music).

What I don't understand is how to use the API to listen for forceBeatAtTime called by other hosts.

Neither the tempo or stop/start callbacks seem to fire in this case.. How does an app get notified that a forceBeatAtTime has occurred from another host in the session?

Thanks,

Sam

samkuhn commented 5 years ago

Sorry my mistake I realised I'm just looking for phase changes and can just poll phase at time and calculate using the last value received from the tempo callback.

fgo-ableton commented 5 years ago

Hey Sam,

Great you figured it out!

In general you should not use the tempo provided in the tempo callback to calculate the phase of the visuals you are rendering. This tempo value is just meant to be shown to the user, as the common tempo of all peers. Effectively the peers might have to run a little slower or faster than this, due to the clock drift of the different computers. To accommodate for this you should solely use information provided by the SessionState. ie. phaseAtTime or beatAtTime to steer your rendering process.

Hope that helps, Florian