quantile_noise_estimator.h (1454B)
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_QUANTILE_NOISE_ESTIMATOR_H_ 12 #define MODULES_AUDIO_PROCESSING_NS_QUANTILE_NOISE_ESTIMATOR_H_ 13 14 #include <math.h> 15 16 #include <array> 17 18 #include "api/array_view.h" 19 #include "modules/audio_processing/ns/ns_common.h" 20 21 namespace webrtc { 22 23 constexpr int kSimult = 3; 24 25 // For quantile noise estimation. 26 class QuantileNoiseEstimator { 27 public: 28 QuantileNoiseEstimator(); 29 QuantileNoiseEstimator(const QuantileNoiseEstimator&) = delete; 30 QuantileNoiseEstimator& operator=(const QuantileNoiseEstimator&) = delete; 31 32 // Estimate noise. 33 void Estimate(ArrayView<const float, kFftSizeBy2Plus1> signal_spectrum, 34 ArrayView<float, kFftSizeBy2Plus1> noise_spectrum); 35 36 private: 37 std::array<float, kSimult * kFftSizeBy2Plus1> density_; 38 std::array<float, kSimult * kFftSizeBy2Plus1> log_quantile_; 39 std::array<float, kFftSizeBy2Plus1> quantile_; 40 std::array<int, kSimult> counter_; 41 int num_updates_ = 1; 42 }; 43 44 } // namespace webrtc 45 46 #endif // MODULES_AUDIO_PROCESSING_NS_QUANTILE_NOISE_ESTIMATOR_H_