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:
print(np.max(abs(amplitude)))
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
else:
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
else:
is_good = False
curr_ctcss = 'CSQ & CTCSS Fail; Squelch Count: %s; CTCSS: %s'%(sqelch_count,freq)
if freq > 255:
break
if is_good == False and total_count == 0 and sqelch_count == 0:
is_good == True```