histograms.h 1.6 KB

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