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 | |
| 29 | // Updates the reverberation contributions. |
| 30 | void UpdateReverbContributions(rtc::ArrayView<const float> power_spectrum, |
| 31 | float power_spectrum_scaling, |
| 32 | float reverb_decay); |
| 33 | |
| 34 | // Adds the reverberation contributions to an input/output power spectrum. |
| 35 | // - power_spectrum: Input to the exponential reverberation model. |
| 36 | // - power_spectrum_scaling: A pre-scaling of the power_spectrum used |
| 37 | // before applying the exponential reverberation model. |
| 38 | // - reverb_decay: Parameter used by the expontial reververation model. |
| 39 | void AddReverb(rtc::ArrayView<const float> power_spectrum, |
| 40 | float power_spectrum_scaling, |
| 41 | float reverb_decay, |
| 42 | rtc::ArrayView<float> reverb_power_spectrum); |
| 43 | |
| 44 | // Returns the current power spectrum reverberation contributions. |
| 45 | const std::array<float, kFftLengthBy2Plus1>& GetPowerSpectrum() const { |
| 46 | return reverb_; |
| 47 | } |
| 48 | |
| 49 | private: |
| 50 | std::array<float, kFftLengthBy2Plus1> reverb_; |
| 51 | }; |
| 52 | |
| 53 | } // namespace webrtc |
| 54 | |
| 55 | #endif // MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_H_ |