Page 1 of 1

Feedback Suppression

Posted: Fri Jul 14, 2023 8:10 pm
by bertankursun2
Hi I am trying to integrate feedback suppression (afc) into my config file which is basically doing dynamic compression. I need assistance to better understand what I need do because certain parts in the "example_afc_live.cfg" are not clear to me.

1) This example is implemented with 1-channel input/output. If I use it with 2-channel system, would both channels run adaptive algorithms independently?

2) My signal processing chain is as follows:

Code: Select all

mha.plugin_name = mhachain
mha.mhachain.algos = [addsndfile overlapadd]
...
mha.mhachain.overlapadd.plugin_name = mhachain
mha.mhachain.overlapadd.mhachain.algos = [fftfilterbank dc combinechannels ]
Should I add the algos for afc before the overlapadd?
This is that part in "example_afc_live.cfg" :

Code: Select all


mha.algos = [downsample ...
	 	adaptive_feedback_canceller:nlms ...
		save_wave:vU ...
		ac2wave:restore_E ...
	 	analysispath ...
   		route:out ...  
    		acmon:afc_mon ...
    		upsample
]
Then should I order them as follows?

Code: Select all

mha.plugin_name = mhachain
mha.mhachain.algos = [addsndfile ...
		downsample ...
	 	adaptive_feedback_canceller:nlms ...
		save_wave:vU ...
		ac2wave:restore_E ...
	 	analysispath ...
   		route:out ...  
    		acmon:afc_mon ...
    		upsample ...
    		overlapadd]
    		
mha.mhachain.overlapadd.plugin_name = mhachain
mha.mhachain.overlapadd.mhachain.algos = [fftfilterbank dc combinechannels ]
3) Could you please give me any tips to measure the delay in samples on PHL? I have measured the time delay using another microphone next to the PHL, by playing a pulse in the room(for 96 kHz, fragsize = 256, wnd.len = 512 it was approximately 25 ms); however it can not be accurate enough to get it in samples. It would be necessary for this part:

Code: Select all

# configure adaptive_feedback_canceller:NLMS
# The configuration variable "delay_w" compensates for the transducer delays in samples. Therefore
# it must be adapted to the sound hardware used. For this, the user is expected to measure the
# the delay caused by the transducers and the sound card in samples. For this purpose, the
# jack_iodelay tool can be used. In that case, the "extra_loopback_latency" of the sound hardware
# used should be measured. The user can refer to the jack documentation about how to use
# jack_iodelay:
# 1. Measure the round trip latency using jack_iodelay
# 2. Consider the "extra_loopback_latency" given by jack_iodelay
# 2. Add "fragsize" of the configuration to this latency
# 3. Add the length of the anti-aliasing filter in taps to this sum
# 4. Set the configuration variable "delay_w" to this sum.
# While calculating the total delay, the downsampling step should be considered as well.
# As an example, the current configuration and hence jack runs at 48 kHz. However this plugin
# (adaptive_feedback_canceller:nlms) operates at 16 kHz. Consequently, the total measured latency should
# be scaled accordingly before setting the configuration variable "delay_w".
mha.nlms.rho = 0.005            # convergence coefficient
mha.nlms.c = 1e-6               # stabilization parameter
mha.nlms.ntaps = 47             # number of taps in filter
mha.nlms.name_lpc = lpc         # Name of the lpc coefficients variable
mha.nlms.lpc_order = 20
mha.nlms.name_e = vE            # Name of error signal E, here estimated using LPC
mha.nlms.delay_w = 124
mha.nlms.delay_d = 161          # Length of the LPC buffer plus one (160 + 1)
mha.nlms.afc_delay = 96    # Delay applied to the signal in the forward path
mha.nlms.n_no_update = 256
mha.nlms.name_f = vWfull
mha.nlms.gains = 3              # Gain applied to the signal in the forward path
4) There is this part at the end of the code which I couldn't understand exactly what it is doing?

Code: Select all

mha.afc_mon.dispmode = matrix   # correct dimensions in MATLAB

Re: Feedback Suppression

Posted: Thu Jul 20, 2023 7:25 am
by tobiasherzke
I do not know the afc algorithm very well. There is a good chance that its implementation is still too CPU-hungry to run on the PHL. We usually use a combination of frequency shifting and coherence filtering to achieve feedback suppression in real-time openMHA setups.

The afc algorithm stores the openMHA output signal that is sent to the speakers, so that it can be filtered with an adaptive filter, and the result from that filter is then subtracted from the microphone input signal. When you combine the afc algorithm with other algorithms, you need to make sure that the output signal storage part is executed after all your other algorithm, and that the input signal subtraction part is executed before any of your other algorithms. The adaptive filter adapts over time to the feedback path. In order to do this, it needs to know the time delay between output and input in samples.

1) It should, but I'm not sure. In your place, I would try to get it working with a single channel at first, and when it works, extend to two channels.

2) See the introduction to my post.

3) The quoted comments advise to use jackiodelay. Another method may be to write and use a custom plugin that replaces the output with overall silence except for occasional clicks, then measure the delay between playing the clicks and detecting them in the input. I think jackiodelay is already part of the mahalia image for PHL.

4) acmon does not modify the signal, it only publishes internal metadata in order to read with external tools.

In my estimation, getting the afc algorithm to run on the PHL would require some serious engineering effort with regard to signal processing optimization. You would also need a good understanding on how adaptive filters work and can be used to suppress feedback. You are welcome to go that route and to share your experience, but it will probably require some major effort on your part.