Commit graph

1320 commits

Author SHA1 Message Date
Alessio Bazzica
3b51cd328e Unify AGC2 experiment field trials into one
In order to experiment with AGC2 and TS at the same time, 3 field
trials are removed and merged into `WebRTC-Audio-GainController2`,
which is existing.

New parameters for the `WebRTC-Audio-GainController2` field trial:
- `switch_to_agc2`: true by default; when true, the gain control
  switches to AGC2 (both for the input volume and for the adaptive
  digital gain);
- `min_input_volume`: minimum input volume enforced by the input
  volume controller when the applied input volume is not zero;
- `disallow_transient_suppressor_usage`: when true, TS is never
  created.

Removed field trials:
- `WebRTC-Audio-Agc2-MinInputVolume`: now a parameter of
  `WebRTC-Audio-GainController2`;
- `WebRTC-ApmTransientSuppressorKillSwitch`: now a parameter of
  `WebRTC-Audio-GainController2`;
- `WebRTC-Audio-TransientSuppressorVadMode`: automatically inferred
  from `WebRTC-Audio-GainController2`.

Bug: webrtc:7494
Change-Id: I452798c0862d71f9adae6d163fe841df05ca44d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287861
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38890}
2022-12-14 16:40:41 +00:00
Hanna Silen
597a2ba41a AGC2: Return the recommended volume from RecommendInputVolume()
In InputVolumeController, rename AnalyzePreProcess() and Process() to
reflect their use and replace the use of the getter
recommended_input_volume() with an optional return value from the
latter one. The added return value carries the recommended input
volume if the call sequence follows the API contract. Make the member
applied_input_volume_ optional. Restrict the use of the getter
recommended_input_volume() for test use. Add a method
capture_output_used() for test use.

In GainController2, store the output of InputVolumeController::Process()
in a new member variable that's updated in Analyze() and Process(). Use
a trivial getter to read the value in APM.

Bug: webrtc:7494
Change-Id: Ifcfb466c4f558be560eb6d2f45410d04adb7e2ad
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287862
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38889}
2022-12-14 13:05:37 +00:00
Hanna Silen
cdee165646 InputVolumeController: Restrict the application of min input volume
Only allow the application of min input volume if the applied input
volume is above zero. To implement this, add a member variable to
store the applied input volume. Rename the related setter to reflect
its new functionality.

Bug: webrtc:7494
Change-Id: Ia70d5cb4dfd972aad9ef2663a81884f3e5cb0758
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287680
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38878}
2022-12-13 09:23:03 +00:00
Alessio Bazzica
a106095333 Fix WebRTC.Audio.Apm.RecommendedInputVolume.OnChangeToMatchTarget tests
- Reset the tested metrics to avoid interactions between tests that
  depend on the execution order
- Address the comment in [1] by adding a function to log the same
  histogram in two different places

[1] https://chromium-review.googlesource.com/c/chromium/src/+/4087426/4/tools/metrics/histograms/metadata/web_rtc/histograms.xml#179

Bug: webrtc:7494
Change-Id: Ia4d339b03c8078eb63626c91579f8a9547f087f7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287681
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38873}
2022-12-12 19:26:01 +00:00
Alessio Bazzica
2bfa767245 Fix APM AGC2 initialization: pass the correct number of channels
Pass the correct number of channels needed by the AGC2 input volume
controller. This change doesn't affect the adaptive digital
controller which reads the number of channel from the passed audio
buffer instance for each processed frame.

Note that the `AdaptiveDigitalGainController::Initialize()` impl
was removed in [1], but that CL didn't remove the declaration (done
in this CL).

[1] https://webrtc-review.googlesource.com/c/src/+/287222/5/modules/audio_processing/agc2/adaptive_digital_gain_controller.cc#105

Bug: webrtc:7494
Change-Id: I07369ab4025a251b25c716cf618e4222fdb60fc8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287320
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38863}
2022-12-09 15:02:20 +00:00
Alessio Bazzica
dfba28e30e AGC2 adaptive digital controller config clean-up
- Remove dry-run option
- Hard-code `adjacent_speech_frames_threshold` and
  `vad_reset_period_ms`
- Expose `initial_gain_db` via field trial

Tested: adaptive digital controller bit-exactness verified

Bug: webrtc:7494
Change-Id: I6166611f91320b6c37de3f8e553c06c2ed95b772
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287222
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38862}
2022-12-09 13:07:34 +00:00
Alessio Bazzica
f72bc5f1e2 AGC2: rename AdaptiveDigitalGainApplier -> AdaptiveDigitalGainController
Bug: webrtc:7494
Change-Id: Id45495d1742f7d2027429c97a3b286468da99b1b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287220
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38857}
2022-12-09 10:31:34 +00:00
Hanna Silen
ca6535593f APM: Add field trial parameters and rename
Add AGC2 digital adaptive config parameters in the field trial
"WebRTC-Audio-InputVolumeControllerExperiment". Rename it as
"WebRTC-Audio-GainController2" to reflect that the override now adjusts
the parameters for both input volume controller and adaptive digital
controller.

Bug: webrtc:7494
Change-Id: Ifbc1b8be76cf23b0b6b74b22b5167a45972cab38
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286880
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38855}
2022-12-08 18:26:05 +00:00
Hanna Silen
6ebf5e3379 InputVolumeController: Rename variables
Rename MonoInputVolumeController member input_volume_ to reflect its
use to store the most recent input volume recommendation.

Rename the remaining variables named as manager in the unit tests.

Bug: webrtc:7494
Change-Id: I31ffdc131c98061ef2b36f98b685c5182b3c6861
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287123
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38854}
2022-12-08 16:37:01 +00:00
Alessio Bazzica
da964d7559 InputVolumeStatsReporter: replace WebRTC.Audio.AgcSetLevel
The `WebRTC.Audio.AgcSetLevel` name is misleading and the histogram
is logged for each channel - but the input volume is one for all the
channels.

Changes:
- `WebRTC.Audio.Apm.RecommendedInputVolume.OnChangeToMatchTarget`
  is the new name
- Now available not only in `AgcManagerDirect` (AGC1), but also in
  `InputVolumeController` (AGC2)
- Logged once and not for each channel
- Also add the following AGC implementation agnostic histograms
  - `WebRTC.Audio.Apm.AppliedInputVolume.OnChange`
  - `WebRTC.Audio.Apm.RecommendedInputVolume.OnChange`
- Fix `SpeechSamplesReader::Feed()` in the unit tests, which did
  not set the applied input volume and apply the recommended one

The histogram definitions are updated in crrev.com/c/4087426.

Bug: webrtc:7494
Change-Id: I03c5dfb08165805215ca2c4bb6509b16de8d68da
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/287081
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38852}
2022-12-08 15:44:43 +00:00
Alessio Bazzica
17e14fdf34 APM AGC2: consolidate GainController2
Now that `InputVolumeController` is finalized, it's time to
consolidate AGC2.

Main changes:
- Remove `AdaptiveDigitalGainController`: it's too simple to justify
  a dedicated class and some components of it are also used by
  `InputVolumeController`
- Remove unwanted temporal dependency: make `InputVolumeController`
  adapt the volume based on the current speech level estimation and
  not on the estimation from the previous frame

Tested: AGC2 adaptive digital bit-exactness verified

Bug: webrtc:7494
Change-Id: I175c2741cafc52be81794219c996a3824c3bbf5e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280560
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38841}
2022-12-07 21:47:45 +00:00
Alessio Bazzica
352f38c7a8 APM: add field trial to disable TransientSuppressor
Regardless of the APM config, the transient suppressor (TS) submodule
won't be created if the `WebRTC-ApmTransientSuppressorKillSwitch`
field trial, disabled by default, is enabled.

Bug: webrtc:13663
Change-Id: Ic1ef9aa57c728296d671d4ef253630c581a86610
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286382
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38839}
2022-12-07 16:30:47 +00:00
Alessio Bazzica
0524319a9d AGC2 NoiseLevelEstimator: DCHECK pointer
Bug: webrtc:7494
Change-Id: Iaac36bade3da4cfa55e8de99cfd3836df75dffa3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286423
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38828}
2022-12-06 15:14:04 +00:00
Hanna Silen
fcbf3724eb InputVolumeController: Remove two unit test helper functions
Remove deprecated unit test helper functions CallPreProcessAudioBuffer()
and CallPreProcForChangingAudio(). Replace the use of these functions
with CallAgcSequence(). Remove a duplicate unit test using one of these
functions. The new calls follow the API contract.

Bug: webrtc:7494
Change-Id: Idc033cb48f4fab1814c4c6e0f23edc4a6a9faa64
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285960
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38826}
2022-12-06 13:23:03 +00:00
Alessio Bazzica
38a6002548 AGC2 SpeechLevelEstimator: make IsConfident() a trivial getter
Bug: webrtc:7494
Change-Id: If2a38801d8fc9dc09838904149262a6d83bbe037
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286421
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38825}
2022-12-06 12:43:51 +00:00
Alessio Bazzica
4366c5469f AGC2: move fixed digital controller before limiter
Currently the fixed digital gain is applied after the input volume
controller and before the adaptive digital one. This CL moves its
application after the adaptive digital controller and before the
limiter.

Reasons:
- This change is safe: no production config where both adaptive and
  fixed digital controllers are jointly used
- More predictable behavior: when the fixed digital controller is
  used after the adaptive digital controller it is easier to describe
  the overall behavior - i.e., the fixed digital combined with the
  limiter can be used for digital compression
- Allow to remove an unwanted temporal dependency: in a follow-up CL
  the input volume controller will use the latest speech level
  estimation instead of that from the previously analyzed frame; this
  CL makes that change easier.

Bug: webrtc:7494
Change-Id: I2e9869081e0eba1e4f30f11ea93a973ca7fea28c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286340
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38813}
2022-12-05 16:21:33 +00:00
Alessio Bazzica
a422e93d7b APM AGC2 InputVolumeController test: rename manager|agc -> controller
Bug: webrtc:7494
Change-Id: Iaa8144c07541042a543e48b2e726e2d4e20edb7c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/286001
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38810}
2022-12-05 10:16:13 +00:00
Alessio Bazzica
8b4a81fb55 APM: Prepare to remove AdaptiveDigitalGainController wrapper
Isolates the build targets for the `AdaptiveDigitalGainController`
dependencies that will be moved into `GainController2`.

`AdaptiveDigitalGainController` will be removed because the wrapper
itself adds little - that's the reason why it has no unit tests.

Bug: webrtc:7494
Change-Id: I2ca41f9255c8faefe4b2cb4ec1f8db536e582f39
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280482
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38799}
2022-12-02 14:47:33 +00:00
Alessio Bazzica
e001474407 InputVolumeController: readability improvements
- use the new naming convention 'input volume'
- fix Yoda-style expressions in the unit tests
- clarify how the gain map values are generated

Bug: webrtc:7494
Change-Id: I4d6ee897a93cdefa6735733b053c57326d01a528
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285467
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38795}
2022-12-02 12:49:04 +00:00
Alessio Bazzica
504bd59422 Expose APM pipeline parameter to select downmixing method
Bug: b/257289030
Change-Id: I03a666a15752d7a1125af2f8d3edae530493618c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285473
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38789}
2022-12-01 15:30:13 +00:00
Henrik Lundin
8754a3c945 Update some audio modules with new OWNERS
Bug: b/260832909
Change-Id: I3d2ebad978988eabf228475c3fc46708e12cf5d2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285780
Auto-Submit: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Christoffer Jansson <jansson@webrtc.org>
Commit-Queue: Christoffer Jansson <jansson@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38788}
2022-12-01 14:55:38 +00:00
Hanna Silen
a6574909e9 APM: Add a field trial for input volume controller
Add a field trial WebRTC-Audio-InputVolumeControllerExperiment and
a mechanism to adjust the config accordingly. Pass the additional
input volume controller config to GainController2.

Bug: webrtc:7494
Change-Id: I3dd624df1f4774cb533417747627995e1f60aa68
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/284101
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38780}
2022-11-30 17:26:45 +00:00
Christoffer Jansson
b00f88179e Remove xooglers from WATCHLISTS and OWNERS
Bug: b/260832909
Change-Id: I683c714da35c21c23404d4b1c6500da28d680ed5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285470
Commit-Queue: Christoffer Jansson <jansson@google.com>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38777}
2022-11-30 15:33:25 +00:00
Hanna Silen
d4dbe4527d AudioProcessingImpl: Add the use of AGC2 InputVolumeController
The integration relies on GainController2 methods Process() and
GetRecommendedInputVolume() to internally take into account whether
the input volume controller is enabled in the ctor or not. These
methods are called for every frame processed if GainController2 is
enabled. Analyze() is called if the input volume controller is
enabled.

The functionality can be enabled from the APM config and is not
enabled by default. If multiple input volume controllers are enabled,
an error is logged.

Tested: Bitexact on a large number of aecdumps if not enabled
Bug: webrtc:7494
Change-Id: I9105483be34eb95fab3c46afbbd368802e956fad
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282720
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38776}
2022-11-30 15:32:23 +00:00
Alessio Bazzica
03bccbe62d AGC2 Input Volume Controller: min input volume field trial update
Always enforce the minimum input volume, not only if overridden.
The only exception is when the applied input volume is zero: in that
case zero is still recommended.

This CL also adapts the unit tests and replaces "mic level" with
the "input volume".

Bug: webrtc:7494
Change-Id: I20c14624fbd357ab91ea05521c3723ec1045a8db
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285462
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38769}
2022-11-29 22:19:31 +00:00
Alessio Bazzica
2076af4673 APM: InputVolumeController tests simplified
Bug: webrtc:7494
Change-Id: I8f622b950aed8f1d5c42fcb8eb0c37c86532b6fe
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/285440
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38757}
2022-11-29 12:45:46 +00:00
Sam Zackrisson
06cba44d7a WebRTC APM: Add missing channel format check
The check was lost  in CL https://webrtc-review.googlesource.com/c/src/+/276920

Bug: webrtc:5298
Change-Id: Ic5f072ebef4ad0bdef5446cad0536728b4ad610e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/284560
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38746}
2022-11-28 18:19:06 +00:00
Hanna Silen
27fed4513f InputVolumeController: Make speech_probability non-optional
Make the argument speech_probability non-optional in
InputVolumeController::Process() and
MonoInputVolumeController::Process().

Additional clean-up: Remove the flag enabled in the
config. Add unit tests for MonoInputVolumeController.

Bug: webrtc:7494
Change-Id: Ie28af77dc628bf71d09ce1ff033d39031f77a21e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/283700
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38710}
2022-11-22 15:19:02 +00:00
Alessio Bazzica
79beaa7f38 APM tests: check that the applied input volume is recommended
when volume emulation is used or when neither an input volume
controller nor volume emulation are used.

This CL adds 3 tests, 2 of which currently fail because APM
behaves in an undesired way. In [1] the behavior is fixed and
the tests are enabled.

A DCHECK in `AudioProcessingImpl::set_stream_analog_level` has
been removed since a more robust behavior can be obtained - namely,
that expected in the disabled unit tests added in this CL.

[1] https://webrtc-review.googlesource.com/c/src/+/281185

Bug: webrtc:14581
Change-Id: I29d2c000cd1baf90606487afd9a4042e6f487834
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/281184
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38696}
2022-11-21 10:35:23 +00:00
Alessio Bazzica
78b466a0d1 AGC1: remove unused field trial WebRTC-UseLegacyDigitalGainApplier
Bug: webrtc:14685
Change-Id: I7c9e07c56f20bd9c4b8848787d0b6e4f9785af60
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/283764
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38687}
2022-11-18 21:58:04 +00:00
Hanna Silen
bf28277774 InputVolumeController: Add configurable speech probability aggregation
Make speech probability threshold configurable by replacing
kSpeechProbabilitySilenceThreshold with speech_probability_threshold in
InputVolumeController::Config.

Make the processing more robust against outliers in speech probability
estimaton by computing an aggregate speech activity over a speech
segment. In MonoInputVolumeController::Process(), use the passed
non-empty speech probabilities to compute the speech activity over the
speech segment and only allow updates for segments with a high enough
ratio of speech frames. Pass RMS error and speech probability for every
frame in Process(): If rms_error_dbfs is empty, volume updates are not
allowed; if speech_probability is empty, the frame counts as a non-
speech frame.

Remove startup_min_volume from the config since it's no longer used
after https://webrtc-review.googlesource.com/c/src/+/282821.

Bug: webrtc:7494
Change-Id: I0ab81b03371496315348f552133aa9909bd36f26
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/283523
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38685}
2022-11-18 19:37:05 +00:00
Alessio Bazzica
dd18f9f8c2 APM: remove WebRTC.Audio.ApmRuntimeSettingCannotEnqueue
The histogram definition is removed in crrev.com/c/4030265.

Bug: chromium:1272685
Change-Id: Id689cf4324ca17bef8a7d07d58d8534bae7b2178
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/283664
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38683}
2022-11-18 14:55:22 +00:00
Sam Zackrisson
5dd548261f APM: Signal error on unsupported sample rates
This CL adds more explicit tests for unsupported sample rates in the WebRTC audio processing module (APM). Rates are restricted to the range [8000, 384000] Hz. Rates outside this range are handled as best as possible, depending on the format.

Tested: bitexact on a large number of aecdumps
Bug: chromium:1332484, chromium:1334991
Change-Id: I9639d03dc837e1fdff64d1f9d1fff0edc0fb299f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/276920
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38663}
2022-11-17 12:12:04 +00:00
Alessio Bazzica
408f0be5c2 APM: remove WebRTC.Audio.Agc.DigitalGain* histograms from AGC1
Bug: chromium:1308676
Change-Id: Ib8d8f78a9ee9ac424495017455a5bc6aa400d8ca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/283663
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38661}
2022-11-17 11:10:44 +00:00
Hanna Silen
52b0ef7926 InputVolumeController: Make input volume update wait frames configurable
Replace kUpdateInputVolumeWaitFrames with
update_input_volume_wait_frames in InputVolumeController::Config.

Also, fix an off-by-one error in the frame count to give a better
readability for non-zero wait frames. Now
update_input_volume_wait_frames_ = 100 allows updates every 100 frames
instead of every 101 frames. Effectively, this makes
update_input_volume_wait_frames = 0 and 1 to behave similarly (i.e.,
they now both allow updates after every frame).

Bug: webrtc:7494
Change-Id: I597f7e88895a4dcd365dc6dee526acb9d971b2fc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282863
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38648}
2022-11-16 13:48:54 +00:00
Hanna Silen
e82d2a1773 InputVolumeController: Use clipped_level_min in clipping prediction
Replace the use of MonoInputController::min_mic_level() with
MonoInputVolumeController::clipped_level_min() when estimating input
volume adjustment from clipping prediction. The adjustment is later
capped in MonoInputVolumeController::HandleClipping() using
clipped_level_min_ so no audio changes are expected from this change.

Bug: webrtc:7494
Change-Id: Ie26d0aa5cce3eeef06f70a281504889519bb5aca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282840
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38593}
2022-11-09 13:15:17 +00:00
Alessio Bazzica
7f2d4afc40 APM: mirror "remove unused field trial" in InputVolumeController
See https://webrtc-review.googlesource.com/c/src/+/278781

Bug: webrtc:7494
Change-Id: I800a93d321bd8c8c7a71b856e151158ec2655d8a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282822
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38592}
2022-11-09 13:12:24 +00:00
Alessio Bazzica
90c08d0b2e APM: mirror "unusued min startup volume param removed" CL in AGC2
See https://webrtc-review.googlesource.com/c/src/+/278787

Bug: webrtc:7494
Change-Id: Ie8ad8acc1d2e373d59d943282701e3483e980806
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282821
Reviewed-by: Hanna Silen <silen@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38588}
2022-11-09 11:40:50 +00:00
Hanna Silen
347038bdb8 InputVolumeController: Clean up the class definition
Remove function declarations, members, and friend tests that are
no longer used. Reorder the member variables.

Bug: webrtc:7494
Change-Id: I8c24e2f4b9d9846e6d3fef4e2c998aa26f49f8c9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282180
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38570}
2022-11-07 17:22:32 +00:00
Hanna Silen
8a8de9be3b InputVolumeController: Replace speech level target and max digital gain
Replace the use of speech level target and digital gain maximum with speech level target range parameters.

Bug: webrtc:7494
Change-Id: I703756c5a3fbd330ed585e3f5b4ac3141d9ea6e2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280943
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38563}
2022-11-07 14:54:50 +00:00
Hanna Silen
dd34a482d9 InputVolumeController: Hardcode some digital gain parameters
In InputVolumeController/MonoInputVolumeController, set
min_digital_gain_db_ and disable_digital_adaptive_ to fixed values
ahead of replacing speech level target as well as digital gain
minimum and maximum with target range parameters.

In InputVolumeController, remove digital_adaptive_follows and
min_digital_gain_db from the config as they are no longer needed.

Bug: webrtc:7494
Change-Id: I1378b6e182224c41038c6d8c649e7a28961f73d4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280962
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38554}
2022-11-04 11:28:44 +00:00
Hanna Silen
49a6097e95 InputVolumeController: Modify unit tests ahead of RMS error changes
Modify unit tests ahead of changes that will replace the minimum
digital gain with a fixed value 0 and always enable digital gain
compensation.

Bug: webrtc:7494
Change-Id: I9df95667b831d5b68e70aaba22f631b398edf8e2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280960
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38553}
2022-11-04 09:39:29 +00:00
Hanna Silen
87d391f748 InputVolumeController: Rename override constants/arguments/tests
Rename constants and arguments reflecting the old naming with RMS error
overriding the error calculated by the analog AGC. Rename the related
unit tests and helper functions.

Bug: webrtc:7494
Change-Id: I9a1d972e9ff7ab5cdd43ca3568379d511801adee
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280481
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38552}
2022-11-04 08:43:20 +00:00
Hanna Silen
92d66be163 MonoInputVolumeController: Refactor Process()
Bug: webrtc:7494
Change-Id: I609b5875ba3dbbee84aa3d481f3f359c964e6373
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280480
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38549}
2022-11-03 20:38:32 +00:00
Hanna Silen
d7cfbe3843 Add support for InputVolumeController in GainController2
Add InputVolumeController as a member in GainController2 (not created
by default). Add a method GainController2::Analyze() to update the
applied input volume and run the pre-processing steps in
InputVolumeController. Add a call InputVolumeController::Process() in
GainController2::Process().

Bug: webrtc:7494
Change-Id: Idf4111ac5e19a620b6421c7f23fd642f169c7b5a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279822
Reviewed-by: Per Åhgren <peah@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38548}
2022-11-03 18:32:55 +00:00
Hanna Silen
9f06ef1cc3 Implement InputVolumeController
Implement InputVolumeController and RecommendedInputVolumeEstimator based on the copy of agc classes AgcManagerDirect and MonoAgc.
Copies of the original files created in https://webrtc-review.googlesource.com/c/src/+/278624.

Bug: webrtc:7494
Change-Id: I74acee57b0db5cc8a6b666be9ba619c6c98a1773
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278625
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38533}
2022-11-02 11:31:59 +00:00
Hanna Silen
7587755d29 Copy AgcManagerDirect files to agc2 and rename the classes
Copy AgcManagerDirect files from agc to agc2. Rename the newly
created files and classes ahead of refactoring. Add a build
target.

This change is done to enable creating a class
InputVolumeController based on AgcManagerDirect. The added
temporary dependency on files in agc will be removed
in https://webrtc-review.googlesource.com/c/src/+/278625.

The exact copy of the files happened in the 1st patchset and it
has been verified as follows:

Checksum check:
```
$ git checkout main && git pull
# Go back to the tree state before [1] landed
$ git new-branch tmp
$ git reset --hard 2235776597
$ cd modules/audio_processing/agc/
$ md5 agc_manager_direct*
MD5 (agc_manager_direct.cc) = e661481a85f72596cae4599b62907f5b
MD5 (agc_manager_direct.h) = bf68280e2d0f689b4ebcd665b5db6052
MD5 (agc_manager_direct_unittest.cc) = 6bf0bf45ff5e940b1a3bb37154f09269
```

Patchset 1 (see [2])
```
$ cd modules/audio_processing/agc2/
$ md5 input_volume_controlle*
MD5 (input_volume_controller.cc) = e661481a85f72596cae4599b62907f5b
MD5 (input_volume_controller.h) = bf68280e2d0f689b4ebcd665b5db6052
MD5 (input_volume_controller_unittest.cc) = 6bf0bf45ff5e940b1a3bb37154f09269
```

[1] https://webrtc-review.googlesource.com/c/src/+/278781
[2] https://webrtc-review.googlesource.com/c/src/+/278624/1

Bug: webrtc:7494
Change-Id: I7804da899d18adf556b089c76a567ce27c299a62
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278624
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38512}
2022-10-31 15:58:11 +00:00
Jesús de Vicente Peña
b24ebc535b pre echo delay: adding different options for detecting pre echoes.
Bug: webrtc:14205
Change-Id: I9de13c8525914278a2961bd1193b1ce2472c8c02
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280900
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Lionel Koenig <lionelk@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38511}
2022-10-31 15:55:29 +00:00
Jesús de Vicente Peña
bb4ccf8495 Pre echo delay estimator: Explicitly considering the initial region when updating the pre echo delay histogram.
Bug: webrtc:14205
Change-Id: Iaa075a52c07ab87fe21da7c40be806c7f80f0e32
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280540
Reviewed-by: Lionel Koenig <lionelk@webrtc.org>
Reviewed-by: Lionel Koenig <lionelk@google.com>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Jesus de Vicente Pena <devicentepena@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38489}
2022-10-28 07:02:58 +00:00
Alessio Bazzica
fbe5d7c3d4 Reland "APM: log both applied and recommended input volume stats"
This is a reland of commit 8d7273357d

Root cause:
audioproc_f doesn't call `metrics::Enable()` and therefore the stats
reporter crashed when `metrics::HistogramFactoryGetCountsLinear()`
returned a nullptr.

Bug fix:
Added `InputVolumeStatsReporter::cannot_log_stats_`, a const flag
that is set to true if any histogram factory returns a nullptr.
When true, the class does nothing.

This CL also includes other code readability improvements that were
not part of the original CL.

Original change's description:
> APM: log both applied and recommended input volume stats
>
> This CL replaces the existing `WebRTC.Audio.ApmAnalogGain.*` stats
> with `WebRTC.Audio.Apm.AppliedInputVolume.*` and adds the
> `WebRTC.Audio.Apm.RecommendedInputVolume.*` stats.
>
> Bug: webrtc:7494
> Change-Id: I70be710d20b1589fc814cbce3d3329ac1500686f
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280220
> Reviewed-by: Hanna Silen <silen@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#38468}

Bug: webrtc:7494
Change-Id: I8373d16beb06b84f439d2c2274ededea7c5e95b0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/280661
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Hanna Silen <silen@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38484}
2022-10-27 14:40:40 +00:00