Jesús de Vicente Peña | 075cb2b | 2018-06-13 15:13:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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_FALLBACK_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_FALLBACK_H_ |
| 13 | |
| 14 | #include <array> |
| 15 | #include <vector> |
| 16 | |
| 17 | #include "modules/audio_processing/aec3/aec3_common.h" |
| 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | // The ReverbModelFallback class describes an exponential reverberant model. |
| 22 | // This model is expected to be applied over the echo power spectrum that |
| 23 | // is estimated by the linear filter. |
| 24 | |
| 25 | class ReverbModelFallback { |
| 26 | public: |
| 27 | explicit ReverbModelFallback(size_t length_blocks); |
| 28 | ~ReverbModelFallback(); |
| 29 | |
| 30 | // Resets the state |
| 31 | void Reset(); |
| 32 | |
| 33 | // Adds the estimated unmodelled echo power to the residual echo power |
| 34 | // estimate. |
| 35 | void AddEchoReverb(const std::array<float, kFftLengthBy2Plus1>& S2, |
| 36 | size_t delay, |
| 37 | float reverb_decay_factor, |
| 38 | std::array<float, kFftLengthBy2Plus1>* R2); |
| 39 | |
| 40 | // Returns the current power spectrum reverberation contributions. |
| 41 | const std::array<float, kFftLengthBy2Plus1>& GetPowerSpectrum() const { |
| 42 | return R2_reverb_; |
| 43 | } |
| 44 | |
| 45 | private: |
| 46 | std::array<float, kFftLengthBy2Plus1> R2_reverb_; |
| 47 | int S2_old_index_ = 0; |
| 48 | std::vector<std::array<float, kFftLengthBy2Plus1>> S2_old_; |
| 49 | }; |
| 50 | |
| 51 | } // namespace webrtc |
| 52 | |
| 53 | #endif // MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_FALLBACK_H_ |