Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom_audio_filters #3

Open
MrBungle42 opened this issue Feb 16, 2017 · 5 comments
Open

custom_audio_filters #3

MrBungle42 opened this issue Feb 16, 2017 · 5 comments
Assignees
Labels
enhancement pinned Pinned - Keeps stale issues from being auto closed

Comments

@MrBungle42
Copy link
Contributor

MrBungle42 commented Feb 16, 2017

Add custom audio filters
Implement feature for usbradio to:

  • rxlpf: Receiver Audio Low Pass Filter
  • rxhpf: Receiver Audio High Pass Filter
  • txlpf: Transmitter Audio Low Pass Filter
  • txhpf: Transmitter Audio High Pass Filter
@MrBungle42 MrBungle42 self-assigned this Feb 16, 2017
@MrBungle42
Copy link
Contributor Author

MrBungle42 commented Feb 16, 2017

Merged feature/custom_audio_filters into develop. Ready for QA

@tsawyer
Copy link
Contributor

tsawyer commented Feb 23, 2017

This feature would be misused by attempting to correct improper pre and/or de emphasis settings or radio connections. I don't believe this feature is needed on any properly installed system. However, I invite MrBungle42 to provide a use case for this feature.

@N4IRS
Copy link
Contributor

N4IRS commented Feb 23, 2017

The filter controls only allow a user to widen the filters not narrow them, I do not see how it would be misused. The defaults retain the normal filter limits. The additional settings increase the high and low range.

@w3kkc
Copy link

w3kkc commented Jan 28, 2019

These audio filters are a feature pioneered by Jeff DePolo, WN3A in 2011. In February 2017, Mike, N4IRR ported the filters from XIPAR to ASL 1.01 and merged into ASL 1.01. For proper operation on the Raspberry Pi and other platforms, Mike added a few fixes. This feature is a set of selectable audio filters for amateur radio applications. The default transmit and receive filters were designed around commercial standards. However, because amateur radio operators have the resources to use wider bandwidths, especially on UHF, they may prefer other filter types in order to provide higher audio quality. Over the years there have been other fixes for the usbradio channel driver minimizing the distortions. The results below proves the distortions are considerably lower than what a typical radio/repeater will add into the audio chain (.8% for the application vs. 3 to 5% or more for the radio). Contrary to what you may have read elsewhere, the dynamic range of this application, when properly deployed, is far beyond the capabilities of wide-band FM radio.

The following settings can be optionally used in a USB radio interface context in "/etc/asterisk/usbradio.conf". If these keyword and value pairs are not present, their values default to zero (0). These alternate filters should be used with care. Note that additional computing power and radio adjustments may be necessary depending on your application. They have been extensively tested and work fine even with the Raspberry Pi3. Unlike other distributions, we encourage the use of the usbradio channel driver (chan_usbradio), or what we commonly call "Full DSP" in AllStarLink 1.01. This feature will also work in simpleusb, if that's what you prefer.

This feature is immediately available in new AllStarLink installations and updates.

Receiver Audio Low Pass Filter Options:
rxlpf=0; 3.0 kHz cutoff. Default value for reduced noise and increased intelligibility.
rxlpf=1; 3.3 kHz cutoff for increased high end, sibilance, and brightness.
rxlpf=2; 3.5 kHz cutoff for even more high end, sibilance, and brightness.

Receiver Audio High Pass Filter Options:
rxhpf=0; 300 Hz cutoff. Default value to reduce sub-audible signals for retransmission, and also in the receiver speaker.
rxhpf=1; 250 Hz cutoff for additional received and retransmitted bass response. We recommend using this filter with a CTCSS tone no higher than 186.2 Hz.

Transmitter Audio Low Pass Filter Options:
txlpf=0; 3.0 kHz cutoff. Default value.
txlpf=1; 3.3 kHz cutoff for increased high end, sibilance and brightness.

Transmitter Audio High Pass Filter Options:
txhpf=0; 300 Hz cutoff. Default value to reduce interference between voice and sub-audible signaling tones and codes.
txhpf=1; 250 Hz cutoff for increased bass response in transmitted audio.
txhpf=2; 120 Hz cutoff for special applications requiring additional bass response in transmitted audio. Not recommended due to the increased possibility of voice energy interfering with sub-audible signaling, but should work okay with very low CTCSS frequencies.

Key points and specifications:
1, All filter combinations yield aliasing distortion/folding at or below -40 dBr. Note that all testing was done with the usbradio channel driver using discriminator (flat) Rx audio, and with Tx audio preemphasis in software. The measurements that follow include the low-pass filter inside the DMK URI (older CM119A) in the transmit audio path, which is down about 3 dB at 3.5 kHz. The frequency response is better with a modified fob or radio adapters with wider frequency response.

  1. The variations in amplitude response within the passband as you switch filters are fairly minor. A perfectionist would re-calibrate both rx and tx levels after switching filters in the conf files, but if you're not at the site with a service monitor, but you shouldn't be afraid to switch filters without recalibrating as the variation is less than 0.3 dB @ 1 kHz worst-case among all filter combinations. Yeah, the filters were designed for unity gain, but there's a little ripple in the passband, plus the ulaw effects, so nothing's perfect, but it's close enough to perfect to not worry about.

  2. THD did not appreciably change as filters were varied, it tends to hover around 0.8% from 300 Hz to wherever the LPF's start to kick in. At low amplitudes (either due to low audio levels or filter skirt attenuation), obviously distortion, as a ratioed value, appears to rise due to quantization noise, but that's unavoidable in our little 8 bit ulaw corner of the world. IMD was likewise acceptable across the range.

The developers recommend the following settings:
Start off with all of the filters (rxlpf, rxhpf, txlpf, txhpf) set to 1. This will make a marked improvement in frequency response, both as far as local repeat audio goes as well as through the network. With the default (zero) filters, frequency response is pretty restricted.

Here's a brief synopsis of what the frequency response from Rx to Tx is like with the DEFAULT (zero) filters that everybody is currently using:

< -40 dB @ 210 Hz and below
-20 dB @ 250 Hz
-13.3 dB @ 275 Hz
-7.9 dB @ 300 Hz
-1.4 dB @ 350 Hz
1.1 dB @ 400 Hz
0.2 dB @ 500 Hz
0.5 dB @ 600 Hz

  • +1.5 dB @ 425 Hz
  • +1.0 dB @ 675
    0.7 dB @ 700 Hz
    0.2 dB @ 800 Hz
    0.6 dB @ 900 Hz
    0 dB @ 1 kHz
    -0.1 dB @ 1.2 kHz
    -0.4 dB @ 1.4 kHz
    -0.6 dB @ 1.6 kHz
    -0.6 dB @ 1.8 kHz
    -0.3 dB @ 2.0 kHz
    0.1 dB @ 2.2 kHz
    -0.2 dB @ 2.4 kHz
    -1.4 dB @ 2.6 kHz
    -4.1 dB @ 2.8 kHz
    -9.0 dB @ 3.0 kHz
    -16.3 dB @ 3.2 kHz
    -26 dB @ 3.4 kHz
    < -40 dB @ 3.6 kHz and above

So, you can see that the low-end suffers quite a bit, as it's almost 8 dB down at 300 Hz. It also has overshoots in excess of 1 dB centered at 425 and 675 Hz. The high end falls off quite sharply as well.

By switching to all 1's for the filters, here's what the response is like:

< -40 dB @ 180 and below
-37 dB @ 186.2 Hz
-16.5 dB @ 220 Hz
-9.2 dB @ 240 Hz
-4.5 dB @ 260 Hz
-2.0 dB @ 275 Hz
-1.6 dB @ 280 Hz
-1.0 dB @ 286 Hz
-0.1 dB @ 300 Hz
+0.5 dB @ 330 Hz
0 dB @ 1 kHz
-0.5 dB @ 2.4 kHz
-1.0 dB @ 2.77 kHz
-2.0 dB @ 3.0 kHz
-6.9 dB @ 3.2 kHz
-15.2 dB @ 3.4 kHz
-29 dB @ 3.6 kHz
< -40 dB @ 3.7 kHz and above

Notice the improvement at the low end and high end. The frequency response is flat to within ± 1 dB from 286 Hz to 2.77 kHz. Regardless of what low-pass filtering you have (or don't have) in your transmitter, nor what your channel spacing is (15 kHz versus 20/25), you should have no problems as far as excessive occupied bandwidth using all 1's for the filters. HOWEVER (and here's a big however), the CM108, even when not being sent data by the channel driver, has about 350 uV RMS of residual wideband noise, with energy primarily falling at harmonics of the sample rate (48 kHz). 350 uV is about 71 dB below the maximum output level of the CM108 best-case, but the ratio may be much worse than that depending on how low you have txvoice set (i.e. it may only end up being 30 or 40 dB down if your Tx has a sensitive input and you have txvoice set accordingly low). As such, we strongly DO NOT recommend feeding a CM108/119 output directly to the modulator without low-pass filtering in the exciter, or optionally in the radio adapter. The LPF doesn't need to be anywhere near as aggressive as it would be in a stock radio of course, but it should sufficiently attenuate everything in the ultrasonic range. As always, you should proof your contraptions with a spectrum analyzer before sticking them on a mountaintop!

Deviations from all filters being set to 1 follow:
If you are using a PL tone higher ABOVE 186.2 Hz and you do NOT have an external PL filter in the repeater receiver, then leave rxhpf at 0. Otherwise, you will start putting receive audio onto the network with insufficient PL filtering (we like to see 40 dB of PL rejection, but -37 dB at 186.2 is close enough).

If you do have an external PL reject filter in the receiver, you should be able to use rxhpf=1 no matter what tone you're using.

Some receiver discriminators have a little more high-end rolloff than others. At your option, and after adequate testing, going to rxlpf=2 shouldn't cause any problems either locally or on the network. But, the difference between rxlpf=1 and rxlpf=2 is pretty minor, and really only improves the response over a fairly narrow range at the very high end, which most people aren't going to notice.

In summary, we believe if you switch all of the filters to 1 you'll be very happy with the improvement in quality and no further tweaking will be necessary. Our goal was to make the "1" filters - plug and play. The improvement will obviously be greatest when both the repeater you're on as well as the repeater of the user(s) you're talking to have the updated filter code, and have taken advantage of these filters.

@stale
Copy link

stale bot commented Apr 30, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 30, 2020
@KG7QIN KG7QIN added stale Stale item that can be auto closed and removed wontfix labels Apr 30, 2020
@stale stale bot removed the stale Stale item that can be auto closed label Apr 30, 2020
@KG7QIN KG7QIN added pinned Pinned - Keeps stale issues from being auto closed stale Stale item that can be auto closed labels Apr 30, 2020
@stale stale bot removed the stale Stale item that can be auto closed label Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pinned Pinned - Keeps stale issues from being auto closed
Projects
None yet
Development

No branches or pull requests

5 participants