shichao-an / soundmeter

Simple real-time sound meter
https://soundmeter.shichao.io
BSD 2-Clause "Simplified" License
82 stars 27 forks source link

Question on accuracy #9

Open brooksc opened 8 years ago

brooksc commented 8 years ago

Hi, thanks for creating this -- I have a problem I'm trying to solve and it seems this may be a perfect solution. One question though.

Have you done at work to see how precisely soundmeter can detect two audio peaks, e.g. to what what precision in time?

The problem I'm trying to solve is to measure audio latency as audio travels from one cell phone to another. I've done this so far by using audacity to record and measure the audio peaks and determine the time between them. I'm trying to determine with a precision down to about 50ms as I measure different audio routing options.

I did a quick test (which I realize isn't optimal) and I'm seeing there is about a 650ms between executions. Before I dig into how much I can reduce this, I wanted to see if you had any experience with this.

Here's what I tried so far:

I'm running soundmeter as follows:

soundmeter --trigger +3000 1 --action exec --exec ./measure

Measure is a script that does this:

!/bin/sh

cd /Users/brooksc/grid/latency TIME=$(gdate +%s.%N) LAST=$(cat last) echo $TIME > last echo $TIME - $LAST | bc

So it calculates the time from the last execution to now.

My next step is to capture the timecode in python and avoid the time to execute the external program.

FYI - the shortest delay I've heard between two cell phones is about 500ms. But as I'm trying to measure whether a particular call is 700ms or 850ms between audio peaks -- the accuracy of measuring time between peaks is critical.

Thanks again for creating this!

shichao-an commented 8 years ago

Did you try to tune the configs, such as reducing audio_segment_length to a smaller value?

As in the sample config, the audio_segment_length defaults to 0.5 seconds, which is why the shortest delay you got is 500ms. If you want higher accuracy, you may want to decrease it to a smaller value, e.g. 0.05 (for 50ms). frames_per_buffer and rate might also influence the accuracy, but I don't recommend you to change them unless you really need to do so.