libpd / abl_link

Ableton Link integration for Pure Data on desktop and Android.
Other
80 stars 15 forks source link

Allow to dynamically adjust latency compensation #3

Closed Ant1r closed 7 years ago

Ant1r commented 7 years ago

For now latency compensation is the same for every instances, because only one timeline is shared. As only the first instance will initialize this timeline, I used a common static "advance" variable to allow any instance to change effectively the latency compensation.

nettoyeurny commented 7 years ago

Thanks, Antoine!

I have to admit I'm a little bit conflicted about this change. On the one hand, we clearly need something like this to work around current limitations of the internal API of Pd. On the other hand, Link is supposed to work without configuration, and a public latency parameter is a departure from that ideal.

The current compromise I have in mind is that I'll make this change, but I'll deliberately leave it undocumented and implement it in a way that's easy to remove once there's a better solution. Also, I prefer the name "offset" to "advance".

I tentatively pushed my take on this to a new branch: https://github.com/libpd/abl_link/tree/offset Please let me know what you think.

Ant1r commented 7 years ago

Ok no problem, anyway I think there could be another way, which would be to disable latency correction from abl_link and implement it on the application side. Would you prefer that ? I could try on the app I work on (NinjaJamm).

nettoyeurny commented 7 years ago

Interesting! Could you elaborate on your idea? How would you implement latency compensation on the application side?

Ant1r commented 7 years ago

For example by adding an offset to the phase then wrapping back to [0;n[ ; then if we want the beats, we just have to detect the crossing of integer boundaries for the new phase. I could add an example of such mechanism in an example patch. Also I could provide the patch I implemented in NinjaJamm for generating a seamless audio ramp from abl_link's phase. I'll propose such patches soon.

nettoyeurny commented 7 years ago

I see. I think this kind of patch would basically amount to an admission that the current external doesn't work well enough. I'll go ahead and merge the offset branch, then.