• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2019 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_NS_SIGNAL_MODEL_ESTIMATOR_H_
12 #define MODULES_AUDIO_PROCESSING_NS_SIGNAL_MODEL_ESTIMATOR_H_
13 
14 #include <array>
15 
16 #include "api/array_view.h"
17 #include "modules/audio_processing/ns/histograms.h"
18 #include "modules/audio_processing/ns/ns_common.h"
19 #include "modules/audio_processing/ns/prior_signal_model.h"
20 #include "modules/audio_processing/ns/prior_signal_model_estimator.h"
21 #include "modules/audio_processing/ns/signal_model.h"
22 
23 namespace webrtc {
24 
25 class SignalModelEstimator {
26  public:
27   SignalModelEstimator();
28   SignalModelEstimator(const SignalModelEstimator&) = delete;
29   SignalModelEstimator& operator=(const SignalModelEstimator&) = delete;
30 
31   // Compute signal normalization during the initial startup phase.
32   void AdjustNormalization(int32_t num_analyzed_frames, float signal_energy);
33 
34   void Update(
35       rtc::ArrayView<const float, kFftSizeBy2Plus1> prior_snr,
36       rtc::ArrayView<const float, kFftSizeBy2Plus1> post_snr,
37       rtc::ArrayView<const float, kFftSizeBy2Plus1> conservative_noise_spectrum,
38       rtc::ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum,
39       float signal_spectral_sum,
40       float signal_energy);
41 
get_prior_model()42   const PriorSignalModel& get_prior_model() const {
43     return prior_model_estimator_.get_prior_model();
44   }
get_model()45   const SignalModel& get_model() { return features_; }
46 
47  private:
48   float diff_normalization_ = 0.f;
49   float signal_energy_sum_ = 0.f;
50   Histograms histograms_;
51   int histogram_analysis_counter_ = 500;
52   PriorSignalModelEstimator prior_model_estimator_;
53   SignalModel features_;
54 };
55 
56 }  // namespace webrtc
57 
58 #endif  // MODULES_AUDIO_PROCESSING_NS_SIGNAL_MODEL_ESTIMATOR_H_
59