blob: 56e2266e569e7447a1fb0fc2f6279820d997034a [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
Jesús de Vicente Peñae58bd8a2018-06-26 17:19:15 +020031 // The methods AddReverbNoFreqShaping and AddReverb add the reverberation
32 // contribution to an input/output power spectrum
33 // Before applying the exponential reverberant model, the input power spectrum
34 // is pre-scaled. Use the method AddReverb when a different scaling should be
35 // applied per frequency and AddReverb_no_freq_shape if the same scaling
36 // should be used for all the frequencies.
37 void AddReverbNoFreqShaping(rtc::ArrayView<const float> power_spectrum,
38 float power_spectrum_scaling,
39 float reverb_decay,
40 rtc::ArrayView<float> reverb_power_spectrum);
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020041
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020042 void AddReverb(rtc::ArrayView<const float> power_spectrum,
Jesús de Vicente Peñae58bd8a2018-06-26 17:19:15 +020043 rtc::ArrayView<const float> freq_response_tail,
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020044 float reverb_decay,
45 rtc::ArrayView<float> reverb_power_spectrum);
46
Jesús de Vicente Peñae58bd8a2018-06-26 17:19:15 +020047 // Updates the reverberation contributions without applying any shaping of the
48 // spectrum.
49 void UpdateReverbContributionsNoFreqShaping(
50 rtc::ArrayView<const float> power_spectrum,
51 float power_spectrum_scaling,
52 float reverb_decay);
53
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020054 // Returns the current power spectrum reverberation contributions.
Jesús de Vicente Peñac98849c2018-10-22 11:41:05 +020055 rtc::ArrayView<const float> GetPowerSpectrum() const { return reverb_; }
Jesús de Vicente Peña075cb2b2018-06-13 15:13:55 +020056
57 private:
Jesús de Vicente Peñae58bd8a2018-06-26 17:19:15 +020058 // 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ña075cb2b2018-06-13 15:13:55 +020063 std::array<float, kFftLengthBy2Plus1> reverb_;
64};
65
66} // namespace webrtc
67
68#endif // MODULES_AUDIO_PROCESSING_AEC3_REVERB_MODEL_H_