Audio latency calculator

Hi!

I´m new to this with coding...done some c++ before but not much.
I´ve got a thing that i want to do but wonder if its even possible with just a arduino.

So, in a audio system i want to check latency roundtrip on external devices or audio chains. There are vst plugins that does this but i want a portable device.

The arduino generates a click on a output pin, starts a timer. Waiting on it to arrive on a input pin. On arrival stops timer an calculate the latency in mS and print it on a Oled.

Ive tried to modify the code for the ultrasound sensor but with no success.
One of my problem is to generate a transient in a clever way. I wanted to use PulseIn() but it only triggers on HIGH 5v, cant send 5V through an audio system.

Need some guidance

Untitled Diagram.png

You need to connect the output from your audio system to one of the inputs a voltage comparator like an LM339. The other input will connect to a pot that feeds it a voltage between 0 and 5V. Then the output goes to a Arduino input with the pull up resistors enabled. That will give an input when you get a click on the audio.

I wanted to use PulseIn()

Why? That gives a none calibrated output. Use the microsecond timer. Make a note of the time when you generate the pulse and again when you receive one. The difference between the two is your latency.

Get it working just printing the output to the monitor before you think about adding a OLED display.