reverb_model.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2018 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_AEC3_REVERB_MODEL_H_
  11. #define MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_H_
  12. #include <array>
  13. #include "api/array_view.h"
  14. #include "modules/audio_processing/aec3/aec3_common.h"
  15. namespace webrtc {
  16. // The ReverbModel class describes an exponential reverberant model
  17. // that can be applied over power spectrums.
  18. class ReverbModel {
  19. public:
  20. ReverbModel();
  21. ~ReverbModel();
  22. // Resets the state.
  23. void Reset();
  24. // Returns the reverb.
  25. rtc::ArrayView<const float, kFftLengthBy2Plus1> reverb() const {
  26. return reverb_;
  27. }
  28. // The methods UpdateReverbNoFreqShaping and UpdateReverb update the
  29. // estimate of the reverberation contribution to an input/output power
  30. // spectrum. Before applying the exponential reverberant model, the input
  31. // power spectrum is pre-scaled. Use the method UpdateReverb when a different
  32. // scaling should be applied per frequency and UpdateReverb_no_freq_shape if
  33. // the same scaling should be used for all the frequencies.
  34. void UpdateReverbNoFreqShaping(rtc::ArrayView<const float> power_spectrum,
  35. float power_spectrum_scaling,
  36. float reverb_decay);
  37. // Update the reverb based on new data.
  38. void UpdateReverb(rtc::ArrayView<const float> power_spectrum,
  39. rtc::ArrayView<const float> power_spectrum_scaling,
  40. float reverb_decay);
  41. private:
  42. std::array<float, kFftLengthBy2Plus1> reverb_;
  43. };
  44. } // namespace webrtc
  45. #endif // MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_H_