I have a program running in python. It samples the demodulated FM output from an SDR. When there is no transmission, the input to the program is completely static.

How can I go about squelching the audio in a way like CSQ on a radio?

Here is what I have so far:

                    if tx_chan == 100:
                    if debug == True:
                        print('%s:%s '%(tx_chan,sqelch_count))
                    #Figure out if a chunk is recordable
                    if CTCSS != 'CSQ':
                        CTCSS = int(float(CTCSS))
                        for peak in peakutils.indexes(abs(np.fft.rfft(amplitude)),thres=0.2):
                            freq = (np.fft.rfftfreq(len(amplitude))*26666.66)[peak]
                            if int(freq) in range(CTCSS-2,CTCSS+2):
                                is_good = True
                                curr_ctcss = freq
                                if sqelch_count == 0 and HighCount > 10:
                                    is_good = True
                                    curr_ctcss = 'CSQ Overide; Squelch Count: %s'%sqelch_count
                                if sqelch_count == 0:
                                    is_good = True
                                    curr_ctcss = 'CSQ Overide; Squelch Count: %s'%sqelch_count
                                    is_good = False
                                    curr_ctcss = 'CSQ & CTCSS Fail; Squelch Count: %s; CTCSS: %s'%(sqelch_count,freq)
                            if freq > 255:
                        if is_good == False and total_count == 0 and sqelch_count == 0:
                            is_good == True```

You'd avoid having this problem by detecting whether FM is present before demodulating it.

The reason is simple: FM demodulation throws away a lot of the info that's still in the RF signal – most prominently, the actual received power – and that info is what you'd want to use to squelch.

That can (unless there's other types of transmissions than audio FM going on on the same channels) simply be done via power detection. There's other, elegant, methods working on the radio signal, but many of them depend on the way you demodulate FM.

If you're really stuck with doing it on the audio side: The output of FM-demodulating radio noise only doesn't have the same statistical properties as audio. Sadly, it mostly depends on the type of demodulation you do, again, but what should work relatively OK would be something like estimating the variance of your signal in multiple subbands. If you've got a similar variance all over the bands, that would be unusual for speech. Music, however, might still be caught with that, so be a bit careful.

TL;DR: Do the presence detection on the radio signal, not the demodulated audio.


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.