I'm trying to detect tones in an phone audio signal (Busy and Ring to be exact). I used a Goertzel algorithm to detect one frquency in the signal. I dont need to search for multiple frquencies, it's only the one I want or not (1/0) (it's before the call starts)
On another side I wrote a pattern detector (on for 300ms, off for 100ms, on for 300ms, off for 100ms for example). I get a percentage of similitude to my pattern than I decide if I found it or not.
I worked with sample from one tone database web site but it seems to give generated signal : too much clean compared to the real sound you can get from a phone.
My goertzel filter gives something like this in reality: When I run this on one sample I got something like this:
https://i.stack.imgur.com/rZdgZ.png
How to convert this results so I can get 1 when the frequency is detected and 0 if not.
So far, I tried this:
- clean signal = (goertzel > 20000) : works but i'm afraid this value can change with differents signal or different hardware.
- I computed 2 goertzel : g1 = goertzel(frq) and g2 = goertzel(frq-100) then result = (g1 > g2): This is not always working. very often g1=g2 and "100" may not always work.
- g1 = goertzel(frqn) g1 = goertzel(frqn/2) and result = g1 > g2. It's fine for detecting the frequence but not the silence
- in addition I would prefer to avoid to run 2 times the filter.
What do you suggest ?
Thanks
Edit
I think I managed to get what I want. In real time:
- I compute the average of the last 20 goertzel magnitudes.
- I update the max of this average
The signal was found if avg > (max/2)
On the screenshot below the result is in gray
https://i.stack.imgur.com/L432s.jpg
Edit 2
source code: