# Detecting a three-tone signal in real-time

I'm new to digital signal processing, and I've been looking into FFT, filtering, Matlab etc. What I'd like is to build a program which will detect when a certain BEEP is transmitted through a trunked voice channel (it signifies an impending critical message) being received via SDR. Through FFT I have ascertained it consists of three frequencies (500Hz, 600Hz and 700Hz). In essence -- somewhat like a phone call with DTMF -- I'd like to monitor audio for the presence of this beeeeep tone and have the software recognize when this is occurring.

My concern is that voice transmissions will cause these three frequencies to peak, making it difficult to determine whether it is due to the alert beep or somebody speaking.

I believe this might be accomplished through some means of measuring the length of the beeps, however this may be a misunderstanding through my inexperience in the field.

I'd appreciate any advice, and if my question isn't directly answerable, please push me in the right direction.

Edit: Here is a temporal frequency analysis of the series from WavePad

• If the transmitter is following a standard, or if you can somehow ascertain that the tones will be present for a fixed amount of time, then you can use that as one of the criteria for detection.

• Another criteria might be having three tones with the same (or very close) energy for some amount of time. Voice is very dynamic; it's very unlikely to have those three particular tones have the same energy.

• You can also look at some other frequencies (for example 400 and 800 Hz) and verify that the signal has no energy there.

If needed to improve detection, you can use calculate all of these signal features at the same time, weigh them, and make a final decision based on the weights.

• Hi, MBaz. You make three thought-provoking points. Especially #2. However, I wonder how the program would measure these criteria consistently - running on a timed loop perhaps? The beeps certainly follow a standard - I have taken a few samples of the series, and it come in sets of five _BEEP_s, with 0.5 seconds beeping, 0.5 seconds silence. For the real-time aspect, what might be the best language / library combination? – Ryan Apr 16 at 20:04
• What you need is "stream" programming, where a program takes a bunch of samples, processes them, produces an output, and moves on to the next bunch of samples. The samples would come from the SDR. Your program would filter the signal, look at the energy in the frequencies of interest, and keep a count of the number of times the signals meet your detection criteria. Matlab is capable of doing this (either simulink or their "DSP objects". – MBaz Apr 16 at 23:46

Is that the FFT of your beep signal or of the beep mixed in with voice? Have you windowed the data? What does the FFT look like if you use a larger frequency spacing in your FFT (fewer data points)? That should result in a smoother spectrum, which will be easier to handle for the purposes of real-time processing.

You could also check the amount of energy in a larger frequency band using your current FFT, say 25 Hz (5% of center frequency at 500 Hz, 487.5 Hz to 512.5 Hz), and if that value compared against the adjacent bands exceeds a specified dB limit, flag the signal as a beep.

Another check you could do is compare the 25 Hz frequency bins against the previous time segment's. This will inform you whether a beep has been injected.

i wouldn't bother with an FFT-based method. just use three bandpass filters (BPF) tuned to the three frequencies with a Q (or bandwidth) that reflects how tightly the three tones will conform to "(500Hz, 600Hz and 700Hz)". On the outputs of each BPF, square each signal, and LPF the squared signals. assuming the passband gain of the BPFs (and of the LPFs) are 1 (or 0 dB), the sum of the 3 LPF outputs is the energy of the inband components.

square and LPF the original unfiltered input and run that squared signal through a 4th LPF. If the energies of the 3 BPF outputs are roughly equal (to a specified precision) and if they add to be the energy of the unfiltered input (to within a specified precision), then that is a positive detection of the three tones.

The approach I'm familiar with has been used for quite some time in broadcast situations. You mentioned your concern with voice signal "peaking" the frequencies of interest. From that statement, I am assuming that you can transmit your signal in-between periods of voice activity.

Here is the method:

On the generation side:

1. arrange for the signal to play for twice as long as the analysis.

On the analysis side:

1. Setup non-overlapped FFTs of a length that is 1/2 of the stimulus. This ensures that one of your FFTs will eventually contain an entire signal.
2. On each FFT, compute the power sum of the tone bins (including adjacent bins as a result of windowing), the power sum of the non-tone bins, and ratio the result to provide a SNR.
3. If the ratio is above some threshold, then you have detected your signal. You can determine your threshold using your prior knowledge of the noise floor and transmitted tone levels.

A couple of things you can do to improve:

1. Adjust the phases of the generated signal to reduce the crest factor.
2. Choose the 3 signal frequencies and/or the FFT length so that the frequencies fall in the centers of the FFT bins. If your generator and analyzer are synchronous, this would allow you to avoid windowing for FFT altogether.