LinkClock latency: Should subtract hardware block size?

Today, I was verifying the behavior of LinkClock vs Max and found that we may need to change our recommendation:

  • Current: LinkClock.new.latency_(s.latency).
  • Probably better: LinkClock.new.latency_(s.latency - audioDriverLatency).

I say probably better because, at least in Linux, LinkClock timing seems to vary somewhat depending on NTP behavior. I’ve seen problems with that when launching SC shortly after waking from sleep. If sclang is started a relatively long time after waking (not sure how long, I guess 10-30 minutes should be enough) then the behavior is consistent.

If I run Max’s [link.beat] and Pd’s [abl_link~] external together, they are in good sync.

If I add LinkClock.new.latency_(s.latency) to that, it’s late.

Reducing the clock latency (but not server latency) by roughly the audio driver’s period sounds much better.

Can anyone else confirm? If so, I’ll update the docs.

BTW it would be nice if sclang had access to the actual hardware buffer duration, maybe by querying the server. AFAIK in Mac and Windows you can request a hardware buffer size (but I’m not sure you have a guarantee of getting that exact buffer size). In Linux, audio hardware configuration is JACK’s responsibility; SC has no control over it. So s.options.hardwareBufferSize is not a sufficient interface for this. (/status.reply includes “nominal” and “actual” sample rates, but not buffer size.)

hjh

AFAIK in Mac and Windows you can request a hardware buffer size (but I’m not sure you have a guarantee of getting that exact buffer size).

That’s right. And yes, you may not get the buffer size you want

I agree that there should be a way for the Client to get the actual hardware buffer size from the Server. I’m not sure if /status.reply is the right place because it is sent continuously, but the hardware buffer size does not change after the Server has booted. I mean, it would certainly work, it just doesn’t feel right. IMO we should rather have a dedicated message for this. Also, is there any other (static) information that could be transmitted alongside?