ramdor / Thetis

The main working repo for changes to Thetis for the Apache Labs line of radios. Find us here : https://discord.gg/6fHCRKnDc9
https://discord.gg/6fHCRKnDc9
GNU General Public License v2.0
54 stars 14 forks source link

Voice Squelch [FEATURE] #113

Closed w-u-2-o closed 1 year ago

w-u-2-o commented 1 year ago

From WU2O:

This voice squelch software was developed by Dr. Warren Pratt, NR0V. I helped a little by analyzing a hardware version of the algorithm in order to provide data for Warren's efforts. Please contact myself and/or Warren as required.

The intent of the voice squelch algorithm is to provide further improvement to the listening experience over and above the already powerful NR2 noise reduction algorithm. NR2 was also developed by Warren and it continues to be the only example of spectral estimation noise reduction to be found anywhere in amateur radio.

The squelch algorithm discriminates human speech from noise in a two step process. First the algorithm does a band-limited frequency-to-voltage (F-to-V) conversion. The resulting voltage varies according to the primary frequency content of the input signal. The time varying output of the F-to-V conversion is then subjected to a peak-to-average ratio (PAPR) measurement. When the PAPR exceeds an adjustable threshold the squelch is unmuted. There are also the usual squelch-related time constants involved in determining how long the PAPR threshold must remain exceeded before unmute, and how long it must remain below threshold before muting.

With the use of NR2 noise reduction and proper adjustment of AGC gain, and on a band with a stable noise floor, signals with as little as 6dB (1 S unit) of SNR can by reliably processed by the voice squelch. The resulting elimination of noise, even between words on an SSB voice transmission, can substantially reduce listening fatigue. The excellent sensitivity of the voice squelch algorithm allows for the detection of all but the smallest breaking stations when in a "rag chew" type QSO.

This algorithm can't overcome static crashes or an unstable noise floor, nor can it filter out ionosondes and other interfering signals. But on a band with a reasonably stable noise floor it works very, very well.

From Warren, NR0V:

Link to the source files:

https://www.dropbox.com/s/u7wd1of0opm6pct/2023-03-30%20WIP%20-%20ssql.zip?dl=0

There are six .c and .h files which are drop-ins for WDSP. I also provided one .cs file which has the method defs that need to be dropped into the file dsp.cs to hook up the new available controls to the console. So you’re aware of what these wdsp files are:

comm.h is just a header that accumulates all the other header files so wdsp can find things. So, in comm.h, there’s now an entry for ssql.h. ssql.h – basically defines the data structures for the F_to_V converter and the Squelch code. ssql.c – this is where the work gets done … it contains source for the F_to_V converter and the squelch. This is a very regular form for wdsp where I put functions to ‘create’, ‘destroy’, ‘flush’, “x”ecute, set buffers, set sample_rate, etc. There are seven or so functions that are required for each wdsp module. RXA.h – header file identifying a pointer to the new squelch function, as well as all other functions, used by the standard receiver, ‘RXA’. RXA.c – contains master functions that call each of the seven of so standard functions for a wdsp module. utilities.c – file of utilities, mostly used for test and debug. I made one change there to help with the squelch testing.

I guess you got by now that WDSP has a very regular structure (there are of course some small exceptions when necessary). Each module is pretty much handled the same way and includes the same set of functions. This is what makes it fairly easy for me to put in or take out new functions like the Voice Squelch.

At the end of the file ssql.c, under the heading of ‘RXA Properties’, are the four functions I’ve provided that can be called by the console to set various parameters in the Voice Squelch. I can provide more; however, these are the ones I think you may want.

‘…Run’ – supply a 1 (or bool true) to turn it ON and a 0 to turn it OFF. ‘…Threshold’ = it looks like a value of 0.16 corresponds to the one and a half divisions that you thought worked well. I noted that in the comment. ‘…TauMute’ – You liked the minimum I believe … that was 0.1 in the controls I had given you. ‘…TauUnMute’ – Again 0.1 was the minimum in the controls.

There’s a ‘channel’ number assigned to each receiver (or transmitter) in WDSP. So, supplying the appropriate ‘channel’ tells WDSP to set the Voice Squelch parameter for that particular receiver. This means that there could be one set of controls that sets up Voice Squelch for ALL receivers and sub-receivers (there would be calls to each channel), or, separate controls for each receiver and sub-receiver. Those are all UI choices.

There are a few bits and pieces called by the source code that are not in these files. Visual Studio can of course find those for you … just tell it to go to the definition. I’ll mention a couple or so: In the function xssql(…), you’ll see xcbl(…) which is the dc blocking capacitor at the input. This is in the file cblock.c. You’ll also see the low pass filter xdbqlp(…) which is in iir.c. Etc.

I could have combined some loops and probably saved a couple cycles. However, the way it’s written it’s easy and simple to work on and test.

From WU2O--suggested UI:

Place voice squelch mute and unmute time constant controls on Setup > DSP > Audio (or perhaps it's own separate tab--whatever is most convenient). Adjustments to these will be rare, if they are necessary at all. Defaults should be minimum value for both, 0.1 as specified by Warren above.

Change main console UI SQL button to be tri-mode: off, SQL (existing AM squelch), VSQL (voice squelch, or maybe VSQ if four letters do not fit). Squelch slider value to reflect the appropriate SQL or VSQL adjustment. SQL meter bar is a don't care in VSQL mode. Default in a new database can be 0.16 as specified by Warren above.

ramdor commented 1 year ago

implemented WDSP 1.21 and the vsql feature. Enabled using the now tri-state sql button on Thetis front end 2.9.0.8. Closing.