• 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_HISTOGRAMS_H_
12 #define MODULES_AUDIO_PROCESSING_NS_HISTOGRAMS_H_
13 
14 #include <array>
15 
16 #include "api/array_view.h"
17 #include "modules/audio_processing/ns/ns_common.h"
18 #include "modules/audio_processing/ns/signal_model.h"
19 
20 namespace webrtc {
21 
22 constexpr int kHistogramSize = 1000;
23 
24 // Class for handling the updating of histograms.
25 class Histograms {
26  public:
27   Histograms();
28   Histograms(const Histograms&) = delete;
29   Histograms& operator=(const Histograms&) = delete;
30 
31   // Clears the histograms.
32   void Clear();
33 
34   // Extracts thresholds for feature parameters and updates the corresponding
35   // histogram.
36   void Update(const SignalModel& features_);
37 
38   // Methods for accessing the histograms.
get_lrt()39   rtc::ArrayView<const int, kHistogramSize> get_lrt() const { return lrt_; }
get_spectral_flatness()40   rtc::ArrayView<const int, kHistogramSize> get_spectral_flatness() const {
41     return spectral_flatness_;
42   }
get_spectral_diff()43   rtc::ArrayView<const int, kHistogramSize> get_spectral_diff() const {
44     return spectral_diff_;
45   }
46 
47  private:
48   std::array<int, kHistogramSize> lrt_;
49   std::array<int, kHistogramSize> spectral_flatness_;
50   std::array<int, kHistogramSize> spectral_diff_;
51 };
52 
53 }  // namespace webrtc
54 
55 #endif  // MODULES_AUDIO_PROCESSING_NS_HISTOGRAMS_H_
56