Commit graph

61 commits

Author SHA1 Message Date
Alessio Bazzica
82ec0faf72 Limiter reset when fixed gain controller gain set.
When FixedGainController::SetGain() is called first on a large value (e.g., 40 dB)
and afterwards on a smaller one (e.g., 0 dB), the limiter used by FixedGainController
takes time (about 10-20 seconds) to converge. During that period, the audio is not
audible and the volume slowly increases.

Even if switching from 40 dB to 0 dB is unlikely, this behavior can be corrected by
resetting the limiter every time that FixedGainController::SetGain() is called.
This eliminates the undesired effect described above even when the transient is short.

Bug: webrtc:7494
Change-Id: I419b8986d2181448b4671cdbbd1c256dfb460216
Reviewed-on: https://webrtc-review.googlesource.com/94902
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24451}
2018-08-27 14:06:32 +00:00
Alex Loiko
f3122e0efe Gain metrics for digital adaptive AGC.
We add 2 metrics for measuring applied digital gain to
AgcManagerDirect. We also add an applied gain and an estimated noise
metric to Agc2.

Chromium histogram CL is
https://chromium-review.googlesource.com/c/chromium/src/+/1170833

Bug: webrtc:7494
Change-Id: Ie40873f9e43bc7d34d8f5473cd73bd47eb84e855
Reviewed-on: https://webrtc-review.googlesource.com/93468
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24290}
2018-08-15 13:44:46 +00:00
Alex Loiko
03ad9b892c Fine-grained limiter metrics.
The FixedGainController is used in two places.
One is the AudioMixer. There it's used to limit the audio level after
adding streams. The other is GainController2, where it's placed after
steps that could boost the audio level outside the allowed range.

We log metrics from the FGC. To avoid confusion, this CL makes the two
use cases log to different histograms.

Chromium histogram CL is
https://chromium-review.googlesource.com/c/chromium/src/+/1170833

Bug: webrtc:7494
Change-Id: I1abe60fd8e96556f144d2ee576254b15beca1174
Reviewed-on: https://webrtc-review.googlesource.com/93464
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24284}
2018-08-15 08:32:18 +00:00
Alex Loiko
a837dd790d Reset Agc2 on analog gain changes.
Agc2 applies a digital gain to the nearend signal.
When the analog level changes, the digital gain calculation is no
longer valid. Therefore Agc2 should be notified to analog gain
changes.

This CL also allow audioproc_f to chain AGC1 and AGC2. In a dependent
CL we will allow using AGC1 for analog gain and AGC2 for digital
gain.

Bug: webrtc:7494
Change-Id: Id75b3728fbf2de1d84b7fba005e4670c7a2985d9
Reviewed-on: https://webrtc-review.googlesource.com/89387
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24231}
2018-08-08 14:36:37 +00:00
Alessio Bazzica
55bf92adf4 RNN VAD: more specific build target names.
Bug: webrtc:9076
Change-Id: Ie35ce0f864318a1ddc552285a5535fe411168202
Reviewed-on: https://webrtc-review.googlesource.com/91760
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24162}
2018-08-01 09:07:26 +00:00
Niels Möller
a12c42a6b2 Delete root header file typedef.h.
Usage replaced with stdint.h, rtc_base/system/arch.h and
rtc_base/system/unused.h, as appropriate.

Bug: webrtc:6854
Change-Id: I97225465d14b969903d92979e2df3c3c05d35f18
Reviewed-on: https://webrtc-review.googlesource.com/90249
Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24100}
2018-07-25 14:59:26 +00:00
Oleh Prypin
dd21474da5 Replace accidental usages of source_set with rtc_source_set
Bug: None
Change-Id: I80c5ad9e1e9942eb51ace014cd7b9127959d601b
Reviewed-on: https://webrtc-review.googlesource.com/89061
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Oleh Prypin <oprypin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24004}
2018-07-17 12:40:17 +00:00
Alex Loiko
684b401016 Division by zero in RNN-VAD.
Bug: webrtc:9450, chromium:861557
Change-Id: I00ddda1fe0e088b983707420acf1b9a6763a3535
Reviewed-on: https://webrtc-review.googlesource.com/87841
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23999}
2018-07-17 09:03:05 +00:00
Sam Zackrisson
7219d053d5 Split aec and aecm into separate build targets
This clarifies dependencies and makes it easier to customize builds
for different binaries.

Also adds BUILD files in aec/ and aecm/.

Moves unit tests to their own target, which subjects them to Chromium
Clang style checks.
The CL contains a fix for a thusly induced warning.

Bug: webrtc:9488
Change-Id: I77b680b42a4dccc5f025005e0890f60b4eaf2961
Reviewed-on: https://webrtc-review.googlesource.com/87304
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23887}
2018-07-09 14:48:06 +00:00
Alex Loiko
2ffafa8244 Allow AGC2 level estimation in AgcManagerDirect.
This CL does the following:

1. Adds a new AdaptiveModeLevelEstimatorAgc implementation of the Agc
  interface. The new implementation differs from webrtc::Agc by
   1. using the AGC2 speech level estimator in
      GetRmsErrorDb. webrtc::Agc implements its own with help of
      webrtc::LoudnessHistogram.
   2. Doesn't forget its past at every GetRmsErrorDb call.
2. Makes AgcManagerDirect use AdaptiveModeLevelEstimatorAgc instead of
   webrtc::Agc if the use_agc2_level_estimation flag is set.

Bug: webrtc:7494
Change-Id: I8df3f52e322d433eb5ce5297f4236af2f1877b04
Reviewed-on: https://webrtc-review.googlesource.com/86603
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23875}
2018-07-06 14:18:18 +00:00
Sam Zackrisson
b2e176522e Create separate build targets for utility/ in APM
This clarifies the dependencies of utility/ a lot (spoiler:
there are very few) and makes it easier to separate the build
targets for aecm and aec2.

Bug: webrtc:9488
Change-Id: If916f86e80c19d1b650d0908fbe8343ea7c47bd7
Reviewed-on: https://webrtc-review.googlesource.com/87141
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23860}
2018-07-05 15:46:28 +00:00
Karl Wiberg
918f50c5d1 Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.

This CL was generated by the following script:

  git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
  git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
  git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
  git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
  git cl format

Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.

Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 10:59:49 +00:00
Alex Loiko
4d01146f16 Prepare AGC2 for analog gain changes.
1. Adds support for Reset calls in AGC2. The AGC will be reset during
   analog gain changes.
2. Allows AdaptiveModeLevelEstimator to return estimates > 0. This can
   happen if the signal gain is too high. It's needed for letting the
   analog AGC know that the gain is too high.

Bug: webrtc:7494
Change-Id: I38def17c21cc01c36aaea79a2401d8c2f289407b
Reviewed-on: https://webrtc-review.googlesource.com/79360
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23805}
2018-07-02 15:25:49 +00:00
Alex Loiko
db6af36979 Add RNN-VAD to AGC2.
* Move 'VadWithLevel' to AGC2 where it belongs.
* Remove the vectors from VadWithLevel. They were there to make it work
  with modules/audio_processing/vad, which we don't need any longer.
* Remove the vector handling from AGC2. It was spread out across
  AdaptiveDigitalGainApplier, AdaptiveAGC and their unit tests.
* Hack the RNN VAD into VadWithLevel. The main issue is the resampling.


Bug: webrtc:9076
Change-Id: I13056c985d0ec41269735150caf4aaeb6ff9281e
Reviewed-on: https://webrtc-review.googlesource.com/77364
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23688}
2018-06-20 15:04:06 +00:00
Yves Gerey
665174fdbb Reformat the WebRTC code base
Running clang-format with chromium's style guide.

The goal is n-fold:
 * providing consistency and readability (that's what code guidelines are for)
 * preventing noise with presubmit checks and git cl format
 * building on the previous point: making it easier to automatically fix format issues
 * you name it

Please consider using git-hyper-blame to ignore this commit.

Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
2018-06-19 14:00:39 +00:00
Niels Möller
65ec0fc81e Delete unneeded includes of basictypes.h.
This is a kitchen-sink header, some pieces should be moved to
byteorder.h, the rest likely deleted.

Delete most includes of basictypes.h. In leaf headers,
include stddef.h and stdint.h explicitly where needed.

Bug: webrtc:6853
Change-Id: Ibc809936a8f94d418e4eb650da1e89c1b9142073
Reviewed-on: https://webrtc-review.googlesource.com/77721
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23333}
2018-05-21 19:35:08 +00:00
Alessio Bazzica
2f1e6d4920 AGC2 RNN VAD: Polishing.
- Code clean: exploiting the recently added ArrayView ctor for
  std::array
- Pitch search internal unit test: long const arrays moved to
  a resource file
- Minor changes

Bug: webrtc:9076
Change-Id: Iaf30753f2498b4568860d72e0b81f5351235692f
TBR: aleloi@webrtc.org
Reviewed-on: https://webrtc-review.googlesource.com/76920
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23248}
2018-05-15 16:41:02 +00:00
Alessio Bazzica
beb1d34729 AGC2 RNN VAD: Feature extraction.
This CL finalizes the feature extraction part for the RNN VAD adding
a class that combines a high-pass filter, LP residual computation,
pitch estimation and spectral features extraction.

This CL also includes a minor refactoring of the pitch estimation
library.

Bug: webrtc:9076
Change-Id: I918b9e143bc6dd2bf508a891446067258a68a777
Reviewed-on: https://webrtc-review.googlesource.com/75504
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23235}
2018-05-15 10:02:20 +00:00
Alessio Bazzica
bc0b37c08a AGC2 RNN VAD: Spectral features extraction.
This CL defines SpectralFeaturesExtractor which is responsible for
computing the spectral features used as input for the RNN.

Bug: webrtc:9076
Change-Id: I5e1396b89eca9c13bb268e8419a16436a9c3450f
Reviewed-on: https://webrtc-review.googlesource.com/73760
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23206}
2018-05-11 21:15:36 +00:00
Alex Loiko
0520b0eb7b FFT-based auto correlation.
During pitch search in the RNN VAD, we calculate auto
correlation. Before this CL, we computed kNumInvertedLags12kHz=147 dot
products of vectors with kBufSize12kHz-kMaxPitch12kHz=240
elements. This was the most time consuming step of the new VAD.

This CL makes the computation happen in frequency domain. Profiling
shows a 3x speed increase. In future, we can try using a more efficient
FFT and to reduce the FFT length to some of e.g. 400, 405, 432.

# For minimal Clang plugin check change.
TBR: kwiberg@webrtc.org

Bug: webrtc:9076
Change-Id: I688251a415869d53175a37f390f441d4e035d954
Reviewed-on: https://webrtc-review.googlesource.com/73366
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23171}
2018-05-08 12:07:42 +00:00
Alessio Bazzica
0bd0a3fe4c AGC2 RNN VAD: Spectral features internal API.
This CL adds helper functions to be used for the spectral features
computation. Namely, it includes the following:
- band boundaries (frequency to FFT coeffcient index)
- band energy coefficients
- log band energy coefficients
- fixed size DCT table and computation

Bug: webrtc:9076
Change-Id: I03a8799b226d986bc1e37cefd0c3039f94b5592a
Reviewed-on: https://webrtc-review.googlesource.com/73687
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23170}
2018-05-08 11:52:32 +00:00
Alessio Bazzica
2284c56670 Adding double braces for array initialization.
TBR=maxmorin@webrtc.org

Bug: webrtc:9076
Change-Id: Ic341ef7437392dd5d6141147a2412ec54204ae10
Reviewed-on: https://webrtc-review.googlesource.com/75121
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Max Morin <maxmorin@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23164}
2018-05-08 09:15:16 +00:00
Alessio Bazzica
0424c19fda AGC2 RNN VAD: FFT utility lib
BandAnalysisFft class that wraps the FFT library, makes it easy to change
FFT library, applies windowing function and owns the FFT input buffer.

Bug: webrtc:9076
Change-Id: I9e7ed587ae263b906e04a66bf8c06eaae64daf19
Reviewed-on: https://webrtc-review.googlesource.com/72900
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23150}
2018-05-07 16:16:28 +00:00
Alessio Bazzica
d8d02147d9 AGC2 Bi-Quad filter: separate target and unit test.
Adding a build target for the bi-qaud filter to make it available for
the RNN VAD of AGC2. Also adding a unit test to test the computation
both in-place and not in-place while comparing the produced output to
that of scipy.signal.

Bug: webrtc:9076
Change-Id: I16176a477ee4b81bb1e090c4906c3a9948ad2772
Reviewed-on: https://webrtc-review.googlesource.com/74220
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23141}
2018-05-07 12:22:54 +00:00
Alessio Bazzica
a5b903833f Reland "Reland "AGC2 RNN VAD: Recurrent Neural Network impl""
This reverts commit 3c9f47434f.

Reason for revert: downstream projects fixed

Original change's description:
> Revert "Reland "AGC2 RNN VAD: Recurrent Neural Network impl""
> 
> This reverts commit e0bba68ede.
> 
> Reason for revert: <INSERT REASONING HERE>
> 
> Original change's description:
> > Reland "AGC2 RNN VAD: Recurrent Neural Network impl"
> > 
> > This reverts commit 97e349ace7.
> > 
> > Reason for revert: downstream projects fixed
> > 
> > Original change's description:
> > > Revert "AGC2 RNN VAD: Recurrent Neural Network impl"
> > > 
> > > This reverts commit 2491cb7382.
> > > 
> > > Reason for revert: broke internal build
> > > 
> > > Original change's description:
> > > > AGC2 RNN VAD: Recurrent Neural Network impl
> > > > 
> > > > RNN implementation for the AGC2 VAD that includes a fully connected
> > > > layer and a gated recurrent unit layer.
> > > > 
> > > > Bug: webrtc:9076
> > > > Change-Id: Ibb8b0b4e9213f09eb9dbe118bbdc94d7e8e4f91b
> > > > Reviewed-on: https://webrtc-review.googlesource.com/72060
> > > > Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
> > > > Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> > > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/master@{#23101}
> > > 
> > > TBR=phoglund@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
> > > 
> > > Change-Id: Ic311c4b7d79094e959d3a2c4a53c398f34c954e2
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: webrtc:9076
> > > Reviewed-on: https://webrtc-review.googlesource.com/74200
> > > Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> > > Commit-Queue: Sam Zackrisson <saza@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#23103}
> > 
> > TBR=phoglund@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
> > 
> > Change-Id: I0c7f8e0f59be926322d05b1da1d4d19c0777dab2
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: webrtc:9076
> > Reviewed-on: https://webrtc-review.googlesource.com/74460
> > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#23113}
> 
> TBR=phoglund@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
> 
> Change-Id: I3985a6d38df1d4438a50d031bc9f6cf41eb83121
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9076
> Reviewed-on: https://webrtc-review.googlesource.com/74560
> Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> Commit-Queue: Sam Zackrisson <saza@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23117}

TBR=phoglund@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: webrtc:9076
Change-Id: I4d81786837017d4daf0dbb1218306795b977ade5
Reviewed-on: https://webrtc-review.googlesource.com/74760
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23138}
2018-05-07 11:13:14 +00:00
Sam Zackrisson
3c9f47434f Revert "Reland "AGC2 RNN VAD: Recurrent Neural Network impl""
This reverts commit e0bba68ede.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> Reland "AGC2 RNN VAD: Recurrent Neural Network impl"
> 
> This reverts commit 97e349ace7.
> 
> Reason for revert: downstream projects fixed
> 
> Original change's description:
> > Revert "AGC2 RNN VAD: Recurrent Neural Network impl"
> > 
> > This reverts commit 2491cb7382.
> > 
> > Reason for revert: broke internal build
> > 
> > Original change's description:
> > > AGC2 RNN VAD: Recurrent Neural Network impl
> > > 
> > > RNN implementation for the AGC2 VAD that includes a fully connected
> > > layer and a gated recurrent unit layer.
> > > 
> > > Bug: webrtc:9076
> > > Change-Id: Ibb8b0b4e9213f09eb9dbe118bbdc94d7e8e4f91b
> > > Reviewed-on: https://webrtc-review.googlesource.com/72060
> > > Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
> > > Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> > > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#23101}
> > 
> > TBR=phoglund@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
> > 
> > Change-Id: Ic311c4b7d79094e959d3a2c4a53c398f34c954e2
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: webrtc:9076
> > Reviewed-on: https://webrtc-review.googlesource.com/74200
> > Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> > Commit-Queue: Sam Zackrisson <saza@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#23103}
> 
> TBR=phoglund@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
> 
> Change-Id: I0c7f8e0f59be926322d05b1da1d4d19c0777dab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9076
> Reviewed-on: https://webrtc-review.googlesource.com/74460
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23113}

TBR=phoglund@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org

Change-Id: I3985a6d38df1d4438a50d031bc9f6cf41eb83121
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9076
Reviewed-on: https://webrtc-review.googlesource.com/74560
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23117}
2018-05-04 11:52:26 +00:00
Alessio Bazzica
e0bba68ede Reland "AGC2 RNN VAD: Recurrent Neural Network impl"
This reverts commit 97e349ace7.

Reason for revert: downstream projects fixed

Original change's description:
> Revert "AGC2 RNN VAD: Recurrent Neural Network impl"
> 
> This reverts commit 2491cb7382.
> 
> Reason for revert: broke internal build
> 
> Original change's description:
> > AGC2 RNN VAD: Recurrent Neural Network impl
> > 
> > RNN implementation for the AGC2 VAD that includes a fully connected
> > layer and a gated recurrent unit layer.
> > 
> > Bug: webrtc:9076
> > Change-Id: Ibb8b0b4e9213f09eb9dbe118bbdc94d7e8e4f91b
> > Reviewed-on: https://webrtc-review.googlesource.com/72060
> > Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
> > Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> > Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#23101}
> 
> TBR=phoglund@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org
> 
> Change-Id: Ic311c4b7d79094e959d3a2c4a53c398f34c954e2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9076
> Reviewed-on: https://webrtc-review.googlesource.com/74200
> Reviewed-by: Sam Zackrisson <saza@webrtc.org>
> Commit-Queue: Sam Zackrisson <saza@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23103}

TBR=phoglund@webrtc.org,saza@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org

Change-Id: I0c7f8e0f59be926322d05b1da1d4d19c0777dab2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9076
Reviewed-on: https://webrtc-review.googlesource.com/74460
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23113}
2018-05-04 09:33:25 +00:00
Sam Zackrisson
97e349ace7 Revert "AGC2 RNN VAD: Recurrent Neural Network impl"
This reverts commit 2491cb7382.

Reason for revert: broke internal build

Original change's description:
> AGC2 RNN VAD: Recurrent Neural Network impl
> 
> RNN implementation for the AGC2 VAD that includes a fully connected
> layer and a gated recurrent unit layer.
> 
> Bug: webrtc:9076
> Change-Id: Ibb8b0b4e9213f09eb9dbe118bbdc94d7e8e4f91b
> Reviewed-on: https://webrtc-review.googlesource.com/72060
> Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
> Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#23101}

TBR=phoglund@webrtc.org,alessiob@webrtc.org,aleloi@webrtc.org,ivoc@webrtc.org

Change-Id: Ic311c4b7d79094e959d3a2c4a53c398f34c954e2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9076
Reviewed-on: https://webrtc-review.googlesource.com/74200
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23103}
2018-05-03 13:49:22 +00:00
Alessio Bazzica
2491cb7382 AGC2 RNN VAD: Recurrent Neural Network impl
RNN implementation for the AGC2 VAD that includes a fully connected
layer and a gated recurrent unit layer.

Bug: webrtc:9076
Change-Id: Ibb8b0b4e9213f09eb9dbe118bbdc94d7e8e4f91b
Reviewed-on: https://webrtc-review.googlesource.com/72060
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23101}
2018-05-03 13:05:31 +00:00
Alessio Bazzica
f22550175b AGC2 RNN VAD: Pitch Search
Functions to estimate pitch period and gain.

Bug: webrtc:9076
Change-Id: Icfe9430dcae11bdb96165c5bfe6e2b1d3bf848ab
Reviewed-on: https://webrtc-review.googlesource.com/70382
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23066}
2018-04-30 10:20:39 +00:00
Alex Loiko
95141d91d8 Set a positive initial gain in the Adaptive Digital GC.
If the adaptive gain is too low, we raise it slowly and only during
speech.

The CL gives better behavior at the start of a call. If the gain is too
high, the fixed-digital limits it. The gain is also quickly reduced by
the AdaptiveGainApplier.

Bug: webrtc:7494
Change-Id: I683f1e3e463cddec2d91f6c7f15c73e744430034
Reviewed-on: https://webrtc-review.googlesource.com/71484
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23053}
2018-04-27 09:05:25 +00:00
Alessio Bazzica
e63d38ba34 AGC2 RNN VAD: Linear Prediction Residual
Functions to estimate the inverse filter via LPC and compute the LP
residual applying the inverse filter.

This CL also includes test utilities, in particular BinaryFileReader,
used to read chunks of data and optionally cast them on the fly, and
Create*Reader() functions to read resource files available at test
time.

Bug: webrtc:9076
Change-Id: Ia4793b8ad6a63cb3089ed11ddad89d1aa0b840f6
Reviewed-on: https://webrtc-review.googlesource.com/70244
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22946}
2018-04-19 17:32:20 +00:00
Alessio Bazzica
b4c748de03 AGC2 RNN VAD: Symmetric matrix buffer
Adding a data structure to cache the results of pair-wise comparisons
between items stored in a ring buffer. This is used to avoid recomputing
the pair-wise comparison every time that a new item is added in a ring
buffer.

Bug: webrtc:9076
Change-Id: I88fb67a80bd3fd8497764dc7ae7e0a577c06b20f
Reviewed-on: https://webrtc-review.googlesource.com/70162
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22942}
2018-04-19 15:31:09 +00:00
Alessio Bazzica
adbd808e0a AGC2 RNN VAD: Ring buffer
Ring buffer template for a finite number of arrays of given type and size.

Bug: webrtc:9076
Change-Id: Ia6c2065b0013f4a00f693966641f9aebe09f6f5c
Reviewed-on: https://webrtc-review.googlesource.com/70161
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22939}
2018-04-19 13:36:58 +00:00
Alessio Bazzica
4736d4e524 AGC2 RNN VAD: Sequence buffer
The SequenceBuffer class template implements a linear buffer with a Push
operation that is used to add a fixed size chunk of new samples into the
buffer. Its properties are its size and the size of the chunks that are
pushed. It is used to implement the pitch buffer in the RNN VAD feature
extractor, for which a ring buffer would be a painful choice.

Bug: webrtc:9076
Change-Id: I4767bf06d5a414dbed724a96ea4186ef013a1e30
Reviewed-on: https://webrtc-review.googlesource.com/70204
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22919}
2018-04-18 09:43:54 +00:00
Alessio Bazzica
a44b91de3e Reland "Reland "AGC2 RNN VAD: initial build targets""
This reverts commit 772d43d4c0.

Reason for revert: fix issues and reland revert

Original change's description:
> Revert "Reland "AGC2 RNN VAD: initial build targets""
> 
> This reverts commit e0031500ba.
> 
> Reason for revert: reland automatically landed by mistake
> 
> Original change's description:
> > Reland "AGC2 RNN VAD: initial build targets"
> > 
> > This reverts commit a153c00bce.
> > 
> > Reason for revert: fix issues and reland revert
> > 
> > Original change's description:
> > > Revert "AGC2 RNN VAD: initial build targets"
> > > 
> > > This reverts commit 8628f5bb7c.
> > > 
> > > Reason for revert: iOS buildbot failing
> > > 
> > > Original change's description:
> > > > AGC2 RNN VAD: initial build targets
> > > > 
> > > > rnn_vad_tool is an executable that reads a wav file of any sample rate
> > > > compatible with 10 ms frames that are resampled and, when the VAD is
> > > > fully landed, will process the resampled frames to compute the VAD
> > > > probability.
> > > > 
> > > > To avoid mac, win and ios trybot failures, to_be_removed.h/.cc have
> > > > been added and will be removed as soon as the :lib target includes
> > > > code that leads to a non-empty static lib file on those platforms.
> > > > 
> > > > Bug: webrtc:9076
> > > > Change-Id: I810c08acfa1adf2029e3baac2adda3045ae5214a
> > > > Reviewed-on: https://webrtc-review.googlesource.com/70202
> > > > Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> > > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/master@{#22898}
> > > 
> > > TBR=alessiob@webrtc.org,aleloi@webrtc.org
> > > 
> > > Change-Id: Ic6014dde78b0ef371804c52608145ba8acdd9c97
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: webrtc:9076
> > > Reviewed-on: https://webrtc-review.googlesource.com/70144
> > > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#22899}
> > 
> > TBR=alessiob@webrtc.org,aleloi@webrtc.org
> > 
> > Change-Id: I55e5a77274684b4cff3c950ca3514cc769d5dc26
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: webrtc:9076
> > Reviewed-on: https://webrtc-review.googlesource.com/70145
> > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#22901}
> 
> TBR=alessiob@webrtc.org,aleloi@webrtc.org
> 
> Change-Id: Ia6a837f79ac3f12aa4b0659938454141c69fee61
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9076
> Reviewed-on: https://webrtc-review.googlesource.com/70520
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22902}

TBR=alessiob@webrtc.org,aleloi@webrtc.org

Change-Id: If0884ab59d66ac3ba6460dbfe14a083f20493c10
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9076
Reviewed-on: https://webrtc-review.googlesource.com/70521
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22904}
2018-04-17 14:34:14 +00:00
Alessio Bazzica
772d43d4c0 Revert "Reland "AGC2 RNN VAD: initial build targets""
This reverts commit e0031500ba.

Reason for revert: reland automatically landed by mistake

Original change's description:
> Reland "AGC2 RNN VAD: initial build targets"
> 
> This reverts commit a153c00bce.
> 
> Reason for revert: fix issues and reland revert
> 
> Original change's description:
> > Revert "AGC2 RNN VAD: initial build targets"
> > 
> > This reverts commit 8628f5bb7c.
> > 
> > Reason for revert: iOS buildbot failing
> > 
> > Original change's description:
> > > AGC2 RNN VAD: initial build targets
> > > 
> > > rnn_vad_tool is an executable that reads a wav file of any sample rate
> > > compatible with 10 ms frames that are resampled and, when the VAD is
> > > fully landed, will process the resampled frames to compute the VAD
> > > probability.
> > > 
> > > To avoid mac, win and ios trybot failures, to_be_removed.h/.cc have
> > > been added and will be removed as soon as the :lib target includes
> > > code that leads to a non-empty static lib file on those platforms.
> > > 
> > > Bug: webrtc:9076
> > > Change-Id: I810c08acfa1adf2029e3baac2adda3045ae5214a
> > > Reviewed-on: https://webrtc-review.googlesource.com/70202
> > > Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> > > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#22898}
> > 
> > TBR=alessiob@webrtc.org,aleloi@webrtc.org
> > 
> > Change-Id: Ic6014dde78b0ef371804c52608145ba8acdd9c97
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: webrtc:9076
> > Reviewed-on: https://webrtc-review.googlesource.com/70144
> > Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#22899}
> 
> TBR=alessiob@webrtc.org,aleloi@webrtc.org
> 
> Change-Id: I55e5a77274684b4cff3c950ca3514cc769d5dc26
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9076
> Reviewed-on: https://webrtc-review.googlesource.com/70145
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22901}

TBR=alessiob@webrtc.org,aleloi@webrtc.org

Change-Id: Ia6a837f79ac3f12aa4b0659938454141c69fee61
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9076
Reviewed-on: https://webrtc-review.googlesource.com/70520
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22902}
2018-04-17 13:17:49 +00:00
Alessio Bazzica
e0031500ba Reland "AGC2 RNN VAD: initial build targets"
This reverts commit a153c00bce.

Reason for revert: fix issues and reland revert

Original change's description:
> Revert "AGC2 RNN VAD: initial build targets"
> 
> This reverts commit 8628f5bb7c.
> 
> Reason for revert: iOS buildbot failing
> 
> Original change's description:
> > AGC2 RNN VAD: initial build targets
> > 
> > rnn_vad_tool is an executable that reads a wav file of any sample rate
> > compatible with 10 ms frames that are resampled and, when the VAD is
> > fully landed, will process the resampled frames to compute the VAD
> > probability.
> > 
> > To avoid mac, win and ios trybot failures, to_be_removed.h/.cc have
> > been added and will be removed as soon as the :lib target includes
> > code that leads to a non-empty static lib file on those platforms.
> > 
> > Bug: webrtc:9076
> > Change-Id: I810c08acfa1adf2029e3baac2adda3045ae5214a
> > Reviewed-on: https://webrtc-review.googlesource.com/70202
> > Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> > Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#22898}
> 
> TBR=alessiob@webrtc.org,aleloi@webrtc.org
> 
> Change-Id: Ic6014dde78b0ef371804c52608145ba8acdd9c97
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:9076
> Reviewed-on: https://webrtc-review.googlesource.com/70144
> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22899}

TBR=alessiob@webrtc.org,aleloi@webrtc.org

Change-Id: I55e5a77274684b4cff3c950ca3514cc769d5dc26
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9076
Reviewed-on: https://webrtc-review.googlesource.com/70145
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22901}
2018-04-17 13:16:44 +00:00
Alessio Bazzica
a153c00bce Revert "AGC2 RNN VAD: initial build targets"
This reverts commit 8628f5bb7c.

Reason for revert: iOS buildbot failing

Original change's description:
> AGC2 RNN VAD: initial build targets
> 
> rnn_vad_tool is an executable that reads a wav file of any sample rate
> compatible with 10 ms frames that are resampled and, when the VAD is
> fully landed, will process the resampled frames to compute the VAD
> probability.
> 
> To avoid mac, win and ios trybot failures, to_be_removed.h/.cc have
> been added and will be removed as soon as the :lib target includes
> code that leads to a non-empty static lib file on those platforms.
> 
> Bug: webrtc:9076
> Change-Id: I810c08acfa1adf2029e3baac2adda3045ae5214a
> Reviewed-on: https://webrtc-review.googlesource.com/70202
> Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22898}

TBR=alessiob@webrtc.org,aleloi@webrtc.org

Change-Id: Ic6014dde78b0ef371804c52608145ba8acdd9c97
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9076
Reviewed-on: https://webrtc-review.googlesource.com/70144
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22899}
2018-04-17 12:48:35 +00:00
Alessio Bazzica
8628f5bb7c AGC2 RNN VAD: initial build targets
rnn_vad_tool is an executable that reads a wav file of any sample rate
compatible with 10 ms frames that are resampled and, when the VAD is
fully landed, will process the resampled frames to compute the VAD
probability.

To avoid mac, win and ios trybot failures, to_be_removed.h/.cc have
been added and will be removed as soon as the :lib target includes
code that leads to a non-empty static lib file on those platforms.

Bug: webrtc:9076
Change-Id: I810c08acfa1adf2029e3baac2adda3045ae5214a
Reviewed-on: https://webrtc-review.googlesource.com/70202
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22898}
2018-04-17 12:22:23 +00:00
Alex Loiko
8a3eaddc95 Pre-amplification in the audio processing module.
Added a new sub-module 'GainApplier'. The build target is
'modules/audio_processing/agc2:gain_applier'. A small refactoring
makes the GainApplier used in adaptive-digital AGC2.

The AGC2 now multiplies samples with a gain in 3 places. It's the
GainApplier, the GainCurveApplier, and the FixedGainController. The
GainApplier is used in AdaptiveDigitalGainApplier and will be used as
a pre-amplifier.

Bug: webrtc:9138
Change-Id: Ibc4c0ea109c6757f159d4adb6e3d8614179c9bc6
Reviewed-on: https://webrtc-review.googlesource.com/69321
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22849}
2018-04-13 10:19:58 +00:00
Alex Loiko
cab48c391d Adaptive digital gain applier
AGC2 component that computes and applies the digital gain.
The gain is computed from an estimated speech and noise level.
This component decides how fast the gain can change and what it
should be.

Bug: webrtc:7494
Change-Id: If55b6e5c765f958e433730cd9e3b2b93c14a7910
Reviewed-on: https://webrtc-review.googlesource.com/64985
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22741}
2018-04-05 06:40:02 +00:00
Alex Loiko
4ed47d0190 Noise level estimation for AGC2.
We put back the old noise estimator from LevelController. We add a few
new unit tests. We also re-arrange the code so that it fits with how
it is used in AGC2. The differences are:

1. The NoiseLevelEstimator is now fully self-contained.
2. The NoiseLevelEstimator is responsible for calling SignalClassifier
   and computing the signal energy. Previously the signal type and
   energy were used in several places. It made sense to compute the
   values independently of the noise calculation.
3. Re-initialization doesn't have to be done by the caller.
4. The interface is AudioFrameView instead of AudioBuffer.

# Bots are green, nothing should break internal stuff
NOTRY=True

Bug: webrtc:7494
Change-Id: I442bdbbeb3796eb2518e96000aec9dc5a039ae6d
Reviewed-on: https://webrtc-review.googlesource.com/66380
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22738}
2018-04-04 18:23:55 +00:00
Alex Loiko
9917c4a780 Saturation Protector in AGC2.
Another submodule of the Automatic Gain Controller 2. It refines the
biased estimate of the Adaptive Mode Level Estimator. It works by
generating a delayed stream of peak levels. The delayed peaks are
compared to the level estimate.

Bug: webrtc:7494
Change-Id: If4c2c19088d1ca73fb93511dad4e1c8ccabcaf03
Reviewed-on: https://webrtc-review.googlesource.com/65461
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22732}
2018-04-04 13:07:30 +00:00
Alex Loiko
9d2788f745 Make possible to activate adaptive AGC2 in the APM.
We update the configuration settings for AGC2. We also update their
effects. Now, 'gain_controller2.enable=true' means 'first run Adaptive
AGC2; then run AGC2 limiter'.

Previously, only the AGC2 limiter was implemented. To run that, one
had to set both 'gain_controller2.enable=true' and
'gain_controller2.enable_limiter=true'.

This setting also enables adaptive AGC2 in the test tool 'audioproc_f'.

Bug: webrtc:7494
Change-Id: I0d5dfe443f2cdc0ecf3aa4054442dab6276d284d
Reviewed-on: https://webrtc-review.googlesource.com/64990
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22669}
2018-03-29 09:42:07 +00:00
Alex Loiko
1e48e8095c Level estimation and saturation protection stub.
The level estimator (AdaptiveModeLevelEstimator) produces a biased
estimate of the speech level. In our model, we use another module
(the SaturationProtector) to compute the bias. This CL contains the
estimator and a stub of the saturation protector.

Bug: webrtc:7494
Change-Id: I0df736d0346063f544fa680b4cc84177ea548545
Reviewed-on: https://webrtc-review.googlesource.com/64820
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22641}
2018-03-28 08:41:45 +00:00
Alex Loiko
2bac896d5e Adaptive Digital gain control structure.
This CL defines the control flow of the adaptive AGC. It also defines
method and class stubs.

Contents:
1. Divide the 'agc2' build target into 'fixed_digital' and
'adaptive_digital'.
1. Update the dependencies of everything that depended on 'agc2'.
2. Define the sub-modules of the adaptive digital AGC 2. They are:
   1. Level Estimator - it gets the energy and a speech probability
      and updates a speech level estimate.
   2. Noise Estimator - it gets an immutable view of the speech frame
      and updates the noise level estimate
   3. Gain applier - it gets the speech frame, the current speech and
      noise estimates, and the speech probability. It finds a gain to
      apply and applies it.
   4. AdaptiveAgc - sets up and controls the sub-modules described
      above.

Bug: webrtc:7494
Change-Id: Ib7ccd8924e94eead0bc5f935b5d8a12e06e24fd1
Reviewed-on: https://webrtc-review.googlesource.com/64440
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22628}
2018-03-27 14:12:50 +00:00
Alex Loiko
250155d0db Fix histogram logging in InterpolatedGainCurve.
We had the following pattern:

if (case_A) metric = METRIC_A;
if (case_B) metric = METRIC_B;
RTC_HISTOGRAM_COUNTS_10000(metric, value);

That's wrong, because once the logging macro runs once, it will use
the same histogram no matter what the first argument is. The macro
expands into roughly

static Histogram* histogram_ptr = nullptr;
if (histogram_ptr == nullptr) {
  // Look up the histogram and put in histogram_ptr
}
// Add data through the histogram pointer.

We change the logging to use macros with string literals. We add a
macro for every of the 4 possible invocations. The macros will expand
to one static pointer each.

Bug: webrtc:8925
Change-Id: Ic7e4a6299eff31dd5988047edfcedce7d369e5ce
Reviewed-on: https://webrtc-review.googlesource.com/64724
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22606}
2018-03-26 14:17:00 +00:00
Alex Loiko
b9a02e523c Change place of UMA logging in AudioMixer.
And fix typo in UMA metric.

We have this pattern in the FrameCombiner component of the AudioMixer:

  if (number_of_streams <= 1) {
    // Copy or fill with zeros.
    return;
  }
  // Mix and limit
  LogMixingStats(/* args */);

When there is only one remote stream, info about active streams and
sample rate is not logged. This CL moves the call to log stats before
the 'return'.

Bug: webrtc:8925
Change-Id: I7b54f61f628273631909dafbfafa21e155e18d4a
Reviewed-on: https://webrtc-review.googlesource.com/62860
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22493}
2018-03-19 14:10:51 +00:00
Alex Loiko
6f2fcb4962 Add more Audio Mixer and Fixed Gain Controller metrics.
We want to know how the AudioMixer is used and how FixedGainController
behaves.

The WebRTC.Audio.Agc2.FixedDigitalGainCurveRegion.* metrics measures
how often the input level hits different regions of the Fixed Gain
Controller gain curve (when the limiter is enabled). They also measure
how long the metrics stay in different regions. They are related to
WebRTC.Audio.ApmCaptureOutputLevelPeakRms, but the new metrics measure
the level before any processing done in APM.

The AudioMixer mixes incoming audio streams. Their number should be
mostly constant, and often some of them could be muted. The metrics
WebRTC.Audio.AudioMixer.NumIncomingStreams,
WebRTC.Audio.AudioMixer.NumIncomingActiveStreams log the number of
incoming stream and how many are not muted. We currently don't have
any stats related to that.

The metric WebRTC.Audio.AudioMixer.MixingRate logs the rate selected
for mixing. The rate can sometimes be inferred from
WebRTC.Audio.Encoder.CodecType. But that metric measures encoding and
not decoding, and codecs don't always map to rates.

See also accompanying Chromium CL
https://chromium-review.googlesource.com/c/chromium/src/+/939473

Bug: webrtc:8925
Change-Id: Ib1405877fc1b39e5d2f0ceccba04434813f20b0d
Reviewed-on: https://webrtc-review.googlesource.com/57740
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22443}
2018-03-15 10:51:06 +00:00