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