I am listening for a very definite pop in a real time audio signal. So far I have managed to get the audio signal in at a sampling rate of 44100.0 Hz and 2048 frames per second. I have visualized the waveform and computed and visualized the FFT. I am currently looking for distinct features to recognize this pop sound (it is the sound of a ping pong ball on the table).

I found a few papers which suggested features such as the zero crossing rate of a percussive sound like this http://www.csl.sony.fr/downloads/papers/2000/gouyon-dafx2000.pdf. However I am struggling a bit to identify the percussive envelop within the signal. I would like to identify a peak in a certain frequency range within my FFT as well, then combine the existence of an envelope with a peak in the correct range to determine whether a sound was heard.

I have two questions, how would I identify an envelope in the time domain, or how would I approach this problem. Further, how could I identify a peak in the frequency domain when I have a very fine mesh FFT (lots of bins and noise). I also have a lot of pink noise as this is a real time audio recording, so I have louder frequencies toward the bottom end than the top end, but I haven't managed to get those frequencies out of my FFT (I don't need to worry about converting back to the time domain).

  1. Identify envelopes beside natural noise
  2. Identify FFT peaks beside natural noise
  3. Any experience with noticing percussive transients?



One of the simplest methods to optimally (minimising the error energy while restricted to LTI filters) detect the existance of a known signal inside another is to use a matched filter. A matched filter will have its impulse response equal to the signal being searched in time-reversed form. This resulting filter equivalently computes the correlation of the known signal with the measured signal. And the peaks of this correlator yields the position of the best possible matches.

Let the searched signal be $s[n]$ with $s= \{-2,-1,0,0,1,2\}$ with $s[0]=-2$ and $s[5]=2$ and length of signal is $L=6$.

Assume that this signal is embedded into various locations of another longer and uncorrelated signal x[n] with its length M > N. Then the resulting combined (by adding sifted versions of the test signal s[n] into x[n] at various locations) signal is called as y[n] of length M.

Now to optimally find the index of the locations into where the signal s[n] was added, we can use an LTI filter with impulse respose h[n] which is the time reversed version of s[n] as: $$h[n] = s[-n]$$

(you can refer to Simon Haykin Communication Systems Theory for a simple and accessible derivation of this optimal filter which is called as the matched filter. Note that the impulse response h[n] of this optimal filter is the same (except time reversal) as the signal being searched, therefore it's called as "matched": optimal detector's impulse response matches the signal being searched)

Following the example of $s[n] = \{-2,-1,0,0,1,2\}$ then $h[n] = \{2,1,0,0,-1,-2\}$ Now however $h[-5]=2$ and $h[0]=-2$. This is an non-causal signal. In practice (using computer system) it is wiser to shift it right, enough to make it causal. It is just a convenience and will not effect the operation performance. Then we will have the following same impulse response $h[n]= \{2,1,0,0,-1,-2\}$ with $h[0]=2$ and $h[5]=-2$ for mathematical convenience.

Now the output of the LTI filter is $$z[n] = h[n]*y[n]$$ This is the convolution operator, which enables the computation of the output of the any discrete time LTI filter and is expressed as $$z[n] = \sum_{k=0}^{k=M-1} {h[n-k]x[k]}$$ The dummy index k ranges within the intersection of the valid signal ranges which is k=0 to k=M-1 for this particular example. Also the output index n will also range from 0 to M-1, which is by convention...

So the output sequence z[n] is expected to inlcude some peaks, these peak locations after being thresholded indicates a possible detection of signal s[n] inside y[n]. (practically the exact location will be L samples back)

What if the signal s[n] is not only shifted but also scaled? Then the peak value will be reduced as much as the scaling. Hence the threshold must be selected very carefully. Or you must find a way to estimate the scaling a priorily.

  • $\begingroup$ Could you explain just what a matched filter does? From what I understand, in discrete form, we convolute every audio section with the sample (filter) and look for the maximum impulse response. So in DSP what does that maximum impulse response correlate to? Is it amplitude? $\endgroup$
    – shane
    Jul 7 '15 at 15:01
  • $\begingroup$ The maximum of the matched filter will give you the sample position of the known signal inside the long mixture. In mathematical theory, matched filter will compute the inner product of the known signal vector and a window from the long mixture which is obtained by shifting the window one sample by one. From the properties of inner product we know that it will be a maximum only for operating on itself. Provided that the remaning long sequence orthgogonal (or weakly correlated) to the test signal... $\endgroup$
    – Fat32
    Jul 7 '15 at 21:34
  • $\begingroup$ To create a matched filter, do I go about this by just recording an audio sample of my sound, then computing a vector inner product for every starting sample? I assume then I set a threshold for recognition. How does this filter combat other sounds and noise? $\endgroup$
    – shane
    Jul 7 '15 at 22:53
  • $\begingroup$ yes but note the difference: if you use a "filter", its impulse response h[n] is the time reversed signal x[L-1-n], where L is the signal length. The inner product is a mathematical representation of the effect of this filter on the input signal... The other signals must be uncorrelated (or weakly correkated) with the searched signal, otherwise it will fail. $\endgroup$
    – Fat32
    Jul 7 '15 at 23:15
  • $\begingroup$ I'm relatively new to filtering in signal processing, from what I understand the impulse response is the output of the filter with the given input, so I am essentially multiplying all of the samples from the input by the samples in the filter, and adding them as you would an inner product, so wouldn't the filter give me a straight number when run on any given portion of my input? Then I look for the maximum or areas over a certain threshold. What is meant by the impulse response is the time reversed signal, and is x the input signal or the filter sample? $\endgroup$
    – shane
    Jul 8 '15 at 1:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.