OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
(...skipping 101 matching lines...) Loading... |
112 // Sample history for the rolling window in kStepWindowed and block-wise | 112 // Sample history for the rolling window in kStepWindowed and block-wise |
113 // histories for kStepBlocked. | 113 // histories for kStepBlocked. |
114 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> history_; | 114 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> history_; |
115 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> subhistory_; | 115 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> subhistory_; |
116 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> subhistory_sq_; | 116 rtc::scoped_ptr<rtc::scoped_ptr<std::complex<float>[]>[]> subhistory_sq_; |
117 | 117 |
118 // The current set of variances and sums for Welford's algorithm. | 118 // The current set of variances and sums for Welford's algorithm. |
119 rtc::scoped_ptr<float[]> variance_; | 119 rtc::scoped_ptr<float[]> variance_; |
120 rtc::scoped_ptr<float[]> conj_sum_; | 120 rtc::scoped_ptr<float[]> conj_sum_; |
121 | 121 |
122 const int freqs_; | 122 const int num_freqs_; |
123 const int window_size_; | 123 const int window_size_; |
124 const float decay_; | 124 const float decay_; |
125 int history_cursor_; | 125 int history_cursor_; |
126 int count_; | 126 int count_; |
127 float array_mean_; | 127 float array_mean_; |
128 bool buffer_full_; | 128 bool buffer_full_; |
129 void (VarianceArray::*step_func_)(const std::complex<float>*, bool); | 129 void (VarianceArray::*step_func_)(const std::complex<float>*, bool); |
130 }; | 130 }; |
131 | 131 |
132 // Helper class for smoothing gain changes. On each applicatiion step, the | 132 // Helper class for smoothing gain changes. On each applicatiion step, the |
133 // currently used gains are changed towards a set of settable target gains, | 133 // currently used gains are changed towards a set of settable target gains, |
134 // constrained by a limit on the magnitude of the changes. | 134 // constrained by a limit on the magnitude of the changes. |
135 class GainApplier { | 135 class GainApplier { |
136 public: | 136 public: |
137 GainApplier(int freqs, float change_limit); | 137 GainApplier(int freqs, float change_limit); |
138 | 138 |
139 // Copy |in_block| to |out_block|, multiplied by the current set of gains, | 139 // Copy |in_block| to |out_block|, multiplied by the current set of gains, |
140 // and step the current set of gains towards the target set. | 140 // and step the current set of gains towards the target set. |
141 void Apply(const std::complex<float>* in_block, | 141 void Apply(const std::complex<float>* in_block, |
142 std::complex<float>* out_block); | 142 std::complex<float>* out_block); |
143 | 143 |
144 // Return the current target gain set. Modify this array to set the targets. | 144 // Return the current target gain set. Modify this array to set the targets. |
145 float* target() const { return target_.get(); } | 145 float* target() const { return target_.get(); } |
146 | 146 |
147 private: | 147 private: |
148 const int freqs_; | 148 const int num_freqs_; |
149 const float change_limit_; | 149 const float change_limit_; |
150 rtc::scoped_ptr<float[]> target_; | 150 rtc::scoped_ptr<float[]> target_; |
151 rtc::scoped_ptr<float[]> current_; | 151 rtc::scoped_ptr<float[]> current_; |
152 }; | 152 }; |
153 | 153 |
154 } // namespace intelligibility | 154 } // namespace intelligibility |
155 | 155 |
156 } // namespace webrtc | 156 } // namespace webrtc |
157 | 157 |
158 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS
_H_ | 158 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INTELLIGIBILITY_INTELLIGIBILITY_UTILS
_H_ |
OLD | NEW |