Bug 83557 - module-echo-cancel: should reduce noise even if nothing is being played
Summary: module-echo-cancel: should reduce noise even if nothing is being played
Status: RESOLVED FIXED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: modules (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-06 11:48 UTC by Alexander E. Patrakov
Modified: 2015-12-15 11:42 UTC (History)
5 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander E. Patrakov 2014-09-06 11:48:43 UTC
module-echo-cancel, surprisingly, not only does echo cancellation, but also other useful effects, like automatic gain control and noise reduction. However, these effects are only applied when something is being played through the echo-cancelled sink. I think this is wrong: these effects should be always applied, because they are useful for voice-recorder applications.

To demonstrate the bug:

1. Load the module:

pacmd load-module module-echo-cancel

In my case, it attaches to the analog output of my onboard soundcard and to my webcam's microphone.

2. Copy (for monitoring purposes) the output of the echo canceller to the headphones, in a way that the echo canceller does not see this loopback:

pacat --record --device alsa_input.usb-046d_0821_39BD2FC0-00-U0x46d0x821.analog-stereo.echo-cancel | pacat --playback --device alsa_output.pci-0000_00_1b.0.analog-stereo

At this point, you should hear room noise and microphone hiss. The same hiss would be recorded if you use parec to record the sound into a wav file.

Microphone hiss is exactly this bug.

3. Now open a new terminal and play silence through the echo canceller:

pacat --playback --device alsa_output.pci-0000_00_1b.0.analog-stereo.echo-cancel /dev/zero

Result: no more microphone hiss! I want this without the need to create a dummy stream.
Comment 1 Peter Meerwald 2014-09-08 13:45:40 UTC
this is with the speex or webrtc EC implementation?
Comment 2 Alexander E. Patrakov 2014-09-08 13:51:07 UTC
I have tested with webrtc, but I believe that it applies to both. See the code:

http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/echo-cancel/module-echo-cancel.c#n882

It causes the samples to be copied when nothing is being played, and it applies to all engines.
Comment 3 Raymond 2014-09-08 16:22:03 UTC
seem  bug of your USB web can Mic capture volume control 


state.U0x46d0x821 {
	control.1 {
		comment.access 'read write'
		comment.type BOOLEAN
		comment.count 1
		iface MIXER
		name 'Mic Capture Switch'
		value true
	}
	control.2 {
		comment.access 'read write'
		comment.type INTEGER
		comment.count 1
		comment.range '0 - 52'
		comment.dbmin -7100
		comment.dbmax -1900
		iface MIXER
		name 'Mic Capture Volume'
		value 47
	}
}
Comment 4 Alexander E. Patrakov 2014-09-08 16:24:05 UTC
Raymond, what you are telling me about is a different bug (if a bug at all). The reported bug is hardware-independent, and I know the sounce line that causes it. If you want to discuss the mixer bug, please contact me via e-mail.
Comment 5 Arun Raghavan 2014-09-08 16:33:01 UTC
Noise suppression and AGC are done in the webrtc backend. I would like to be able to separate those out into a different filter so we can use them for non-voip use-cases. I'm not too pleased about the idea of making yet another virtual sink/source for the purpose, but at the moment, that'd be the way to go.
Comment 6 Arun Raghavan 2015-12-15 11:42:22 UTC
Pushed a fix for this:

commit 12b5e7c87365e4dbbc4c5fdd8a3579099e5902b5
Author: Arun Raghavan <git@arunraghavan.net>
Date:   Wed Nov 18 08:26:47 2015 +0530

    echo-cancel: Don't skip canceller when sink is inactive
    
    This forces the canceller engine to be invoked even if playback is not
    currently active. We need to do this for cases where the engine provides
    additional processing that is independent of playback, such as noise
    suppression and AGC.
    
    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=83557


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.