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 | |
| 14 | #include "api/array_view.h" |
| 15 | #include "modules/audio_processing/aec3/aec3_common.h" |
| 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | // The ReverbModel class describes an exponential reverberant model |
| 20 | // that can be applied over power spectrums. |
| 21 | class ReverbModel { |
| 22 | public: |
| 23 | ReverbModel(); |
| 24 | ~ReverbModel(); |
| 25 | |
| 26 | // Resets the state. |
| 27 | void Reset(); |
| 28 | |
Jesús de Vicente Peña | e58bd8a | 2018-06-26 17:19:15 +0200 | [diff] [blame^] | 29 | // The methods AddReverbNoFreqShaping and AddReverb add the reverberation |
| 30 | // contribution to an input/output power spectrum |
| 31 | // Before applying the exponential reverberant model, the input power spectrum |
| 32 | // is pre-scaled. Use the method AddReverb when a different scaling should be |
| 33 | // applied per frequency and AddReverb_no_freq_shape if the same scaling |
| 34 | // should be used for all the frequencies. |
| 35 | void AddReverbNoFreqShaping(rtc::ArrayView<const float> power_spectrum, |
| 36 | float power_spectrum_scaling, |
| 37 | float reverb_decay, |
| 38 | rtc::ArrayView<float> reverb_power_spectrum); |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 39 | |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 40 | void AddReverb(rtc::ArrayView<const float> power_spectrum, |
Jesús de Vicente Peña | e58bd8a | 2018-06-26 17:19:15 +0200 | [diff] [blame^] | 41 | rtc::ArrayView<const float> freq_response_tail, |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 42 | float reverb_decay, |
| 43 | rtc::ArrayView<float> reverb_power_spectrum); |
| 44 | |
Jesús de Vicente Peña | e58bd8a | 2018-06-26 17:19:15 +0200 | [diff] [blame^] | 45 | // Updates the reverberation contributions without applying any shaping of the |
| 46 | // spectrum. |
| 47 | void UpdateReverbContributionsNoFreqShaping( |
| 48 | rtc::ArrayView<const float> power_spectrum, |
| 49 | float power_spectrum_scaling, |
| 50 | float reverb_decay); |
| 51 | |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 52 | // Returns the current power spectrum reverberation contributions. |
| 53 | const std::array<float, kFftLengthBy2Plus1>& GetPowerSpectrum() const { |
| 54 | return reverb_; |
| 55 | } |
| 56 | |
| 57 | private: |
Jesús de Vicente Peña | e58bd8a | 2018-06-26 17:19:15 +0200 | [diff] [blame^] | 58 | // Updates the reverberation contributions. |
| 59 | void UpdateReverbContributions(rtc::ArrayView<const float>& power_spectrum, |
| 60 | rtc::ArrayView<const float>& freq_resp_tail, |
| 61 | float reverb_decay); |
| 62 | |
Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 63 | std::array<float, kFftLengthBy2Plus1> reverb_; |
| 64 | }; |
| 65 | |
| 66 | } // namespace webrtc |
| 67 | |
| 68 | #endif // MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_H_ |