views:

102

answers:

3

I am doing sound latency test. my device will be receiving either a beep signal or a silence signal. How can i differentiate between these signals. Please help me. Thanks in advance..

+3  A: 

Look at around 10 ms worth of samples (e.g. 441 samples at 44.1 kHz) and measure the energy in that buffer. If it's above some threshold it's a signal and if it's below the threshold then it's silence.

To measure energy just sum the squared value of each sample in the buffer and divide by the number of samples.

Paul R
+1, but for a simple scenario like this, I think just computing the max absolute value is robust enough, and will be faster.
Steve
@Steve -- That depends on whether you have any noise - if you're just looking at a pure tone and complete silence, then yes, you can probably use a cruder solution.
Paul R
+1  A: 

It depends. If the digital audio was generated synthetically (like by another function) and you can thus rely on the fact that, in one case, you'll get true digital silence (zeroed samples), then the solution is simply to test for the zeroed samples over the measurement window. Anything other than zero is not silence.

I would guess, though, that you're dealing with real-world audio recorded from, say, a microphone. If this is the case, then measuring the energy in a time window and comparing it to a threshold indeed makes sense. The two parameters that you'll have to determine are:

  1. Threshold energy level
  2. Length of the time window

If the threshold is too low, your false positive rate will be too high; background noise that is not a beep may be interpreted as a beep. Conversely, if your threshold is too high, your system could categorize a beep as noise. Luckily, if you're doing audio with a reasonably low background noise, your performance won't be very sensitive to this threshold.

Longer window lengths will decrease these false positive/negative rates, thus making your system more robust, but system usability may suffer with overly long windows. For instance, automated phone systems classify keypresses to aid menu navigation. If they required the user to hold each key for three seconds at a time, the accuracy would improve but at the expense of almost all usability.

I encourage you to NOT make a decision based solely on the one maximal sample as Paul suggested. Doing this completely undermines the resistance to false positives provided by the length of the sampling window.

seanmac7577
but the asker said that this is simply a sound latency test. From how I understood the question, microphone noise is not an issue.
Steve
To me, "sound latency test" implies that KennyTM will be analyzing time windows in sequence until he finds one where a signal is present. The manner in which he determines presence depends on whether the sample may have noise, so I see these issues as orthogonal. I think we can agree, though, that some more info from KennyTM would help.
seanmac7577
Thanks for all your answers Steve,Paul,Chunks and Seanmac.. All are right answers in my case. Basically now i need only sound latency test now. But in future case, the answer of Seanmac will help me lot because i will use sound from microphone . Thanks once again..
Sijo
A: 

What if they use the loop back method, does noise take into account? For example, If they send a Beep to second device, Loopback & send it back to the sender, send a silence packet and do the same, Can't they measure the latency at the sender level(provided they know the actual network latency).

Chuks