blob: 5ba54853daa5fb8a55d465c66ee53edf0d96a33a [file] [log] [blame]
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +02001/*
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 Gerey988cc082018-10-23 12:03:01 +020014#include <array>
15
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020016#include "api/array_view.h"
17#include "modules/audio_processing/aec3/aec3_common.h"
18
19namespace webrtc {
20
21// The ReverbModel class describes an exponential reverberant model
22// that can be applied over power spectrums.
23class ReverbModel {
24 public:
25 ReverbModel();
26 ~ReverbModel();
27
28 // Resets the state.
29 void Reset();
30
Per Åhgrenb4161d32019-10-08 12:35:47 +020031 // Returns the reverb.
32 rtc::ArrayView<const float, kFftLengthBy2Plus1> reverb() const {
33 return reverb_;
34 }
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020035
Per Åhgrenb4161d32019-10-08 12:35:47 +020036 // 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ña075cb2b2018-06-13 15:13:55 +020045
Per Åhgrenb4161d32019-10-08 12:35:47 +020046 // 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ña075cb2b2018-06-13 15:13:55 +020050
51 private:
Jesús de Vicente Peñae58bd8a2018-06-26 17:19:15 +020052
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020053 std::array<float, kFftLengthBy2Plus1> reverb_;
54};
55
56} // namespace webrtc
57
58#endif // MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_H_