1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #ifndef MODULES_AUDIO_PROCESSING_NS_HISTOGRAMS_H_ 12*d9f75844SAndroid Build Coastguard Worker #define MODULES_AUDIO_PROCESSING_NS_HISTOGRAMS_H_ 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker #include <array> 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker #include "api/array_view.h" 17*d9f75844SAndroid Build Coastguard Worker #include "modules/audio_processing/ns/ns_common.h" 18*d9f75844SAndroid Build Coastguard Worker #include "modules/audio_processing/ns/signal_model.h" 19*d9f75844SAndroid Build Coastguard Worker 20*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 21*d9f75844SAndroid Build Coastguard Worker 22*d9f75844SAndroid Build Coastguard Worker constexpr int kHistogramSize = 1000; 23*d9f75844SAndroid Build Coastguard Worker 24*d9f75844SAndroid Build Coastguard Worker // Class for handling the updating of histograms. 25*d9f75844SAndroid Build Coastguard Worker class Histograms { 26*d9f75844SAndroid Build Coastguard Worker public: 27*d9f75844SAndroid Build Coastguard Worker Histograms(); 28*d9f75844SAndroid Build Coastguard Worker Histograms(const Histograms&) = delete; 29*d9f75844SAndroid Build Coastguard Worker Histograms& operator=(const Histograms&) = delete; 30*d9f75844SAndroid Build Coastguard Worker 31*d9f75844SAndroid Build Coastguard Worker // Clears the histograms. 32*d9f75844SAndroid Build Coastguard Worker void Clear(); 33*d9f75844SAndroid Build Coastguard Worker 34*d9f75844SAndroid Build Coastguard Worker // Extracts thresholds for feature parameters and updates the corresponding 35*d9f75844SAndroid Build Coastguard Worker // histogram. 36*d9f75844SAndroid Build Coastguard Worker void Update(const SignalModel& features_); 37*d9f75844SAndroid Build Coastguard Worker 38*d9f75844SAndroid Build Coastguard Worker // Methods for accessing the histograms. get_lrt()39*d9f75844SAndroid Build Coastguard Worker rtc::ArrayView<const int, kHistogramSize> get_lrt() const { return lrt_; } get_spectral_flatness()40*d9f75844SAndroid Build Coastguard Worker rtc::ArrayView<const int, kHistogramSize> get_spectral_flatness() const { 41*d9f75844SAndroid Build Coastguard Worker return spectral_flatness_; 42*d9f75844SAndroid Build Coastguard Worker } get_spectral_diff()43*d9f75844SAndroid Build Coastguard Worker rtc::ArrayView<const int, kHistogramSize> get_spectral_diff() const { 44*d9f75844SAndroid Build Coastguard Worker return spectral_diff_; 45*d9f75844SAndroid Build Coastguard Worker } 46*d9f75844SAndroid Build Coastguard Worker 47*d9f75844SAndroid Build Coastguard Worker private: 48*d9f75844SAndroid Build Coastguard Worker std::array<int, kHistogramSize> lrt_; 49*d9f75844SAndroid Build Coastguard Worker std::array<int, kHistogramSize> spectral_flatness_; 50*d9f75844SAndroid Build Coastguard Worker std::array<int, kHistogramSize> spectral_diff_; 51*d9f75844SAndroid Build Coastguard Worker }; 52*d9f75844SAndroid Build Coastguard Worker 53*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 54*d9f75844SAndroid Build Coastguard Worker 55*d9f75844SAndroid Build Coastguard Worker #endif // MODULES_AUDIO_PROCESSING_NS_HISTOGRAMS_H_ 56