Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 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 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame] | 14 | #include <array> |
| 15 | |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 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 | |
Per Åhgren | b4161d3 | 2019-10-08 12:35:47 +0200 | [diff] [blame] | 31 | // Returns the reverb. |
| 32 | rtc::ArrayView<const float, kFftLengthBy2Plus1> reverb() const { |
| 33 | return reverb_; |
| 34 | } |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 35 | |
Per Åhgren | b4161d3 | 2019-10-08 12:35:47 +0200 | [diff] [blame] | 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); |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 45 | |
Per Åhgren | b4161d3 | 2019-10-08 12:35:47 +0200 | [diff] [blame] | 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); |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 50 | |
| 51 | private: |
Jesús de Vicente Peña | e58bd8a | 2018-06-26 17:19:15 +0200 | [diff] [blame] | 52 | |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 53 | std::array<float, kFftLengthBy2Plus1> reverb_; |
| 54 | }; |
| 55 | |
| 56 | } // namespace webrtc |
| 57 | |
| 58 | #endif // MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_H_ |