Making a Latency Calculator

Thestral Sound's icon

Thestral Sound

5月 19 2023 | 10:35 午前

Hello folks, I'm working on a patch that will detect the latency introduced to a signal, by comparing when the original signal starts to when the delayed version starts.

When testing the measurement system, it often only seems to output powers of 2. There are sometimes exceptions, but it's certainly never accurate. It also never outputs less than 512. There was a suggestion that this may all be down to vector size - is that true? And can someone perhaps provide more insight as to what is happening?

Here is how the patch looks:

(various extra number and bang objects to check things are working as expected along the chain)

Graham Wakefield's icon

Graham Wakefield

5月 19 2023 | 4:39 午後

You are getting strange results because you go from the MSP signal domain to the message domain (via snapshot~), and the message domain can't process at audio rate. You need a solution using only MSP objects.

Here's how you could do it in gen~, for example:

Thestral Sound's icon

Thestral Sound

5月 19 2023 | 10:06 午後

Ahah. I knew there are things in Max that run at different speeds, per se, but it didn't occur to me during trying to make this. Definitely still sleeping on gen, but I'm new to Max overall so learning curves are taking me for a ride.

Thanks a bunch for this - going to walk through it to make sure I understand what's going on properly.

Roman Thilenius's icon

Roman Thilenius

5月 19 2023 | 10:55 午後


the most simple way to measure latency is to use your ears and a variable delay, just as you will use to compensate the latency (except for plug-ins)

so you basically only have to patch one numberbox and that´s it.


of course it might fail to give you exactly the right sample number when there is a filter effect in either of the two music signals - but that is true for all other methods, too.

in fact using your ears works quite well compared to using ==~ and such, because those might just stop working when there is any kind of minor change in the signal.

Thestral Sound's icon

Thestral Sound

5月 19 2023 | 11:54 午後

That's actually a fair shout. I was determined to leave the measurement up to the computer, but if I'm going to have to then dial the measured latency into the other channels to bring them in line anyway? Side-by-side adjustment by ear ought to be plenty.

Having said that, I've already build the measurement patch and exported it as a vst, so I'll try both methods and see how the results/workflows compare.