OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #include "webrtc/common_audio/smoothing_filter.h" | 11 #include "webrtc/common_audio/smoothing_filter.h" |
12 | 12 |
13 #include <cmath> | 13 #include <cmath> |
14 | 14 |
15 #include "webrtc/base/timeutils.h" | 15 #include "webrtc/rtc_base/timeutils.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 SmoothingFilterImpl::SmoothingFilterImpl(int init_time_ms) | 19 SmoothingFilterImpl::SmoothingFilterImpl(int init_time_ms) |
20 : init_time_ms_(init_time_ms), | 20 : init_time_ms_(init_time_ms), |
21 // Duing the initalization time, we use an increasing alpha. Specifically, | 21 // Duing the initalization time, we use an increasing alpha. Specifically, |
22 // alpha(n) = exp(-powf(init_factor_, n)), | 22 // alpha(n) = exp(-powf(init_factor_, n)), |
23 // where |init_factor_| is chosen such that | 23 // where |init_factor_| is chosen such that |
24 // alpha(init_time_ms_) = exp(-1.0f / init_time_ms_), | 24 // alpha(init_time_ms_) = exp(-1.0f / init_time_ms_), |
25 init_factor_(init_time_ms_ == 0 | 25 init_factor_(init_time_ms_ == 0 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // \end{cases} | 135 // \end{cases} |
136 // \end{align} | 136 // \end{align} |
137 // We know $\gamma = T^{-\frac{1}{T}}$, where $T$ denotes init\_time\_ms\_. Then | 137 // We know $\gamma = T^{-\frac{1}{T}}$, where $T$ denotes init\_time\_ms\_. Then |
138 // $1 - \gamma$ approaches zero when $T$ increases. This can cause numerical | 138 // $1 - \gamma$ approaches zero when $T$ increases. This can cause numerical |
139 // difficulties. We multiply $T$ (if $T > 0$) to both numerator and denominator | 139 // difficulties. We multiply $T$ (if $T > 0$) to both numerator and denominator |
140 // in the fraction. See. | 140 // in the fraction. See. |
141 // \begin{align} | 141 // \begin{align} |
142 // \frac{\gamma^m - \gamma^n}{1 - \gamma} | 142 // \frac{\gamma^m - \gamma^n}{1 - \gamma} |
143 // &= \frac{T^\frac{T-m}{T} - T^\frac{T-n}{T}}{T - T^{1-\frac{1}{T}}} | 143 // &= \frac{T^\frac{T-m}{T} - T^\frac{T-n}{T}}{T - T^{1-\frac{1}{T}}} |
144 // \end{align} | 144 // \end{align} |
OLD | NEW |