• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef MODULES_AUDIO_PROCESSING_AGC2_NOISE_LEVEL_ESTIMATOR_H_
12 #define MODULES_AUDIO_PROCESSING_AGC2_NOISE_LEVEL_ESTIMATOR_H_
13 
14 #include "modules/audio_processing/agc2/signal_classifier.h"
15 #include "modules/audio_processing/include/audio_frame_view.h"
16 #include "rtc_base/constructor_magic.h"
17 
18 namespace webrtc {
19 class ApmDataDumper;
20 
21 class NoiseLevelEstimator {
22  public:
23   NoiseLevelEstimator(ApmDataDumper* data_dumper);
24   ~NoiseLevelEstimator();
25   // Returns the estimated noise level in dBFS.
26   float Analyze(const AudioFrameView<const float>& frame);
27 
28  private:
29   void Initialize(int sample_rate_hz);
30 
31   int sample_rate_hz_;
32   float min_noise_energy_;
33   bool first_update_;
34   float noise_energy_;
35   int noise_energy_hold_counter_;
36   SignalClassifier signal_classifier_;
37 
38   RTC_DISALLOW_COPY_AND_ASSIGN(NoiseLevelEstimator);
39 };
40 
41 }  // namespace webrtc
42 
43 #endif  // MODULES_AUDIO_PROCESSING_AGC2_NOISE_LEVEL_ESTIMATOR_H_
44