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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 GainApplier::~GainApplier() {} | 59 GainApplier::~GainApplier() {} |
60 | 60 |
61 void GainApplier::Apply(const std::complex<float>* in_block, | 61 void GainApplier::Apply(const std::complex<float>* in_block, |
62 std::complex<float>* out_block) { | 62 std::complex<float>* out_block) { |
63 for (size_t i = 0; i < num_freqs_; ++i) { | 63 for (size_t i = 0; i < num_freqs_; ++i) { |
64 current_[i] = UpdateFactor(target_[i], current_[i], relative_change_limit_); | 64 current_[i] = UpdateFactor(target_[i], current_[i], relative_change_limit_); |
65 out_block[i] = sqrtf(fabsf(current_[i])) * in_block[i]; | 65 out_block[i] = sqrtf(fabsf(current_[i])) * in_block[i]; |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
| 69 DelayBuffer::DelayBuffer(size_t delay, size_t num_channels) |
| 70 : buffer_(num_channels, std::vector<float>(delay, 0.f)), read_index_(0u) {} |
| 71 |
| 72 DelayBuffer::~DelayBuffer() {} |
| 73 |
| 74 void DelayBuffer::Delay(float* const* data, size_t length) { |
| 75 size_t sample_index = read_index_; |
| 76 for (size_t i = 0u; i < buffer_.size(); ++i) { |
| 77 sample_index = read_index_; |
| 78 for (size_t j = 0u; j < length; ++j) { |
| 79 float swap = data[i][j]; |
| 80 data[i][j] = buffer_[i][sample_index]; |
| 81 buffer_[i][sample_index] = swap; |
| 82 if (++sample_index == buffer_.size()) { |
| 83 sample_index = 0u; |
| 84 } |
| 85 } |
| 86 } |
| 87 read_index_ = sample_index; |
| 88 } |
| 89 |
69 } // namespace intelligibility | 90 } // namespace intelligibility |
70 | 91 |
71 } // namespace webrtc | 92 } // namespace webrtc |
OLD | NEW |