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