OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_GAIN_CHANGE_CALCULATOR_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_MIXER_GAIN_CHANGE_CALCULATOR_H_ |
12 #define WEBRTC_MODULES_AUDIO_MIXER_GAIN_CHANGE_CALCULATOR_H_ | 12 #define WEBRTC_MODULES_AUDIO_MIXER_GAIN_CHANGE_CALCULATOR_H_ |
13 | 13 |
14 #include "webrtc/base/array_view.h" | 14 #include "webrtc/rtc_base/array_view.h" |
15 | 15 |
16 namespace webrtc { | 16 namespace webrtc { |
17 | 17 |
18 class GainChangeCalculator { | 18 class GainChangeCalculator { |
19 public: | 19 public: |
20 // The 'out' signal is assumed to be produced from 'in' by applying | 20 // The 'out' signal is assumed to be produced from 'in' by applying |
21 // a smoothly varying gain. This method computes variations of the | 21 // a smoothly varying gain. This method computes variations of the |
22 // gain and handles special cases when the samples are small. | 22 // gain and handles special cases when the samples are small. |
23 float CalculateGainChange(rtc::ArrayView<const int16_t> in, | 23 float CalculateGainChange(rtc::ArrayView<const int16_t> in, |
24 rtc::ArrayView<const int16_t> out); | 24 rtc::ArrayView<const int16_t> out); |
25 | 25 |
26 private: | 26 private: |
27 void CalculateGain(rtc::ArrayView<const int16_t> in, | 27 void CalculateGain(rtc::ArrayView<const int16_t> in, |
28 rtc::ArrayView<const int16_t> out, | 28 rtc::ArrayView<const int16_t> out, |
29 rtc::ArrayView<float> gain); | 29 rtc::ArrayView<float> gain); |
30 | 30 |
31 float CalculateDifferences(rtc::ArrayView<const float> values); | 31 float CalculateDifferences(rtc::ArrayView<const float> values); |
32 float last_value_ = 0.f; | 32 float last_value_ = 0.f; |
33 float last_reliable_gain_ = 1.0f; | 33 float last_reliable_gain_ = 1.0f; |
34 }; | 34 }; |
35 | 35 |
36 } // namespace webrtc | 36 } // namespace webrtc |
37 | 37 |
38 #endif // WEBRTC_MODULES_AUDIO_MIXER_GAIN_CHANGE_CALCULATOR_H_ | 38 #endif // WEBRTC_MODULES_AUDIO_MIXER_GAIN_CHANGE_CALCULATOR_H_ |
OLD | NEW |