Skip to content

Feature to unlink noise suppression for multi-channel inputs#95

Merged
strohel merged 12 commits into
mainfrom
fix-multichannel-gain
Apr 15, 2026
Merged

Feature to unlink noise suppression for multi-channel inputs#95
strohel merged 12 commits into
mainfrom
fix-multichannel-gain

Conversation

@jacksongoode
Copy link
Copy Markdown
Contributor

@jacksongoode jacksongoode commented Apr 10, 2026

This alters a behavior that would have otherwise caused a quiet/noisy channel to apply noise suppression to a signal channel - current theory being this behavior preserves the stereo image. It adds a new feature experimental-unlink-ns that patches the problematic filter aggregation & cross-channel application.

If the intention in a multi-channel input is to capture, as an example, a stereo image from two mics, this feature might cause distortion in the representation as each channel will have its own noise filter applied.

However for non-linked microphones, dynamic gain levels can disrupt the performance of NS on a mic, therefore we make the offender (the Wiener filter aggregation) act on each channel individually.

The fix points to https://gitlab.freedesktop.org/jacksongoode/webrtc-audio-processing/-/commit/29ac3aab4df478b3f06698578c3a66f2ed2ac41e

@jacksongoode jacksongoode changed the title Un-link NS filter aggregation for multi-channel inputs Feature to unlink noise suppression for multi-channel inputs Apr 10, 2026
@jacksongoode jacksongoode force-pushed the fix-multichannel-gain branch from ee360b4 to b9e7f24 Compare April 10, 2026 10:02
@jacksongoode jacksongoode requested a review from strohel April 10, 2026 10:02
@jacksongoode jacksongoode force-pushed the fix-multichannel-gain branch from b9e7f24 to e57006b Compare April 10, 2026 10:02
@jacksongoode jacksongoode force-pushed the fix-multichannel-gain branch from 4ea4cc5 to 2ae53cb Compare April 10, 2026 15:11
@jacksongoode jacksongoode marked this pull request as ready for review April 10, 2026 15:15
@jacksongoode
Copy link
Copy Markdown
Contributor Author

jacksongoode commented Apr 10, 2026

@strohel All ready for a look! And I think when this gets merged I'd be happy to cut 2.0.4 (unless you think this counts as a feature for a 2.1.0).

Copy link
Copy Markdown
Member

@strohel strohel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks very good, just a bunch of small technical details.

I also see that we haven't been documenting our feature flags properly in README.md - let's do it for this one (feel free to also document other missing flag there, up to you).

Comment thread webrtc-audio-processing-sys/build.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread resources/hello.wav
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread webrtc-audio-processing-sys/build.rs Outdated
Comment thread webrtc-audio-processing-sys/Cargo.toml
@jacksongoode jacksongoode force-pushed the fix-multichannel-gain branch 4 times, most recently from da6c993 to 5c9a58b Compare April 13, 2026 16:25
@jacksongoode jacksongoode force-pushed the fix-multichannel-gain branch from d501ab0 to 78d5363 Compare April 13, 2026 16:51
@jacksongoode jacksongoode requested a review from strohel April 14, 2026 01:04
@jacksongoode
Copy link
Copy Markdown
Contributor Author

@strohel I believe all your questions have been addressed, PTAL.

Copy link
Copy Markdown
Member

@strohel strohel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked deeper and found some deeper problems (kinda), but should be quick to fix. 🙏

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread webrtc-audio-processing-sys/build.rs Outdated
@jacksongoode jacksongoode force-pushed the fix-multichannel-gain branch from 0305c7f to 600343e Compare April 15, 2026 02:28
@jacksongoode jacksongoode requested a review from strohel April 15, 2026 02:46
@jacksongoode
Copy link
Copy Markdown
Contributor Author

jacksongoode commented Apr 15, 2026

Changes made to properly measure the RMS, patch with the dry reverse check, properly normalize i16 range, and better comments were added, asserts updated. @strohel have another look when time permits.

Copy link
Copy Markdown
Member

@strohel strohel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I'll go ahead and cut a path release with this.

@strohel strohel merged commit 2c58da2 into main Apr 15, 2026
10 checks passed
@strohel strohel deleted the fix-multichannel-gain branch April 15, 2026 10:46
@strohel
Copy link
Copy Markdown
Member

strohel commented Apr 15, 2026

@jacksongoode ah one think I've realized post-merge:

if you enable the feature, build, disable the feature and build again, it stays enabled:

strohel@thicky ~/work/webrtc-audio-processing $ gs
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
strohel@thicky ~/work/webrtc-audio-processing $ cargo test --features experimental-unlink-ns
   Compiling webrtc-audio-processing-config v2.0.3 (/home/strohel/work/webrtc-audio-processing/webrtc-audio-processing-config)
   Compiling webrtc-audio-processing-sys v2.0.3 (/home/strohel/work/webrtc-audio-processing/webrtc-audio-processing-sys)
   Compiling webrtc-audio-processing v2.0.3 (/home/strohel/work/webrtc-audio-processing)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 19.87s
     Running unittests src/lib.rs (target/debug/deps/webrtc_audio_processing-0f40afab18ddacbd)

running 12 tests
test tests::test_create_drop ... ok
test tests::test_process_signatures ... ok
test tests::test_zero_channels ... ok
test tests::test_full_aec_with_linear_aec_output_misconfiguration ... ok
test tests::test_nominal ... ok
test tests::test_tweak_processor_params ... ok
test tests::test_aec3_configuration_behavior ... ok
test tests::test_echo_cancellation_effectiveness ... ok
test tests::test_aec3_configuration_impact ... ok
test tests::test_unlink_ns_processing ... ok
test tests::test_stream_delay ... ok
test tests::test_nominal_threaded ... ok

test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.05s

     Running unittests src/lib.rs (target/debug/deps/webrtc_audio_processing_config-b5be71de2515ab82)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running unittests src/lib.rs (target/debug/deps/webrtc_audio_processing_sys-d444efa9de7d4db5)

running 5 tests
test tests::test_create_delete ... ok
test tests::test_empty_stats ... ok
test tests::test_config ... ok
test tests::test_process ... ok
test tests::test_some_stats ... ok

test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests webrtc_audio_processing

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests webrtc_audio_processing_config

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests webrtc_audio_processing_sys

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

strohel@thicky ~/work/webrtc-audio-processing $ gs
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)
        modified:   webrtc-audio-processing-sys/webrtc-audio-processing (modified content)

no changes added to commit (use "git add" and/or "git commit -a")
strohel@thicky ~/work/webrtc-audio-processing $ gd
strohel@thicky ~/work/webrtc-audio-processing $ cargo test --features bundled
   Compiling webrtc-audio-processing-sys v2.0.3 (/home/strohel/work/webrtc-audio-processing/webrtc-audio-processing-sys)
   Compiling webrtc-audio-processing v2.0.3 (/home/strohel/work/webrtc-audio-processing)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 19.90s
     Running unittests src/lib.rs (target/debug/deps/webrtc_audio_processing-a2141e506ff1c077)

running 12 tests
test tests::test_create_drop ... ok
test tests::test_process_signatures ... ok
test tests::test_zero_channels ... ok
test tests::test_full_aec_with_linear_aec_output_misconfiguration ... ok
test tests::test_nominal ... ok
test tests::test_tweak_processor_params ... ok
test tests::test_aec3_configuration_behavior ... ok
test tests::test_echo_cancellation_effectiveness ... ok
test tests::test_aec3_configuration_impact ... ok
test tests::test_unlink_ns_processing ... FAILED
test tests::test_stream_delay ... ok
test tests::test_nominal_threaded ... ok

failures:

---- tests::test_unlink_ns_processing stdout ----

thread 'tests::test_unlink_ns_processing' (3783544) panicked at src/lib.rs:1132:13:
Expected ~-33.7dB without patch, got -22.866814
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    tests::test_unlink_ns_processing

test result: FAILED. 11 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.05s

error: test failed, to rerun pass `-p webrtc-audio-processing --lib`

Not a blocker for tagging, though it is suboptimal. At this point I think we should copy the source and only patch the copy.

@jacksongoode
Copy link
Copy Markdown
Contributor Author

if you enable the feature, build, disable the feature and build again, it stays enabled:

Yeah, that's expected. It's again a case of the caching behavior. I suppose you mean copy the source to patch outside of the standard build cache location?

@strohel
Copy link
Copy Markdown
Member

strohel commented Apr 15, 2026

Right, though I wouldn't call it "caching". We modify the file in-place inside the git submodule.

Another problem I see is that we leave .rej files around if you build with the feature for the second time (cargo build --features experimental-unlink-ns; touch webrtc-audio-processing-sys/build.rs; cargo build --features experimental-unlink-ns).

meson has source directory and build directory. Currently we use /webrtc-audio-processing-sys/webrtc-audio-processing (the git submodule) as source directory directly. (and we patch it there, in-place).

The build directory is under OUT_DIR (target/debug/deps/webrtc_audio_processing_sys-d444efa9de7d4db5/).

I got nerd sniped and working on a PR.

strohel added a commit that referenced this pull request Apr 15, 2026
strohel added a commit that referenced this pull request Apr 16, 2026
…patching (#96)

* Copy C++ webrtc-audio-processing sources before building/patching

Resolves the problems described in #95 (comment)

* Portable Linux <-> Mac cp invocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants