Chromium Code Reviews| Index: webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
| diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
| index 6e641a23325984bee6daab921a67c9acc959a489..49df9c3eb6bef7fc04bd5fd261dfef982d8ac9b5 100644 |
| --- a/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
| +++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
| @@ -66,6 +66,29 @@ void GainApplier::Apply(const std::complex<float>* in_block, |
| } |
| } |
| +DelayBuffer::DelayBuffer(size_t delay, size_t num_channels) |
| + : buffer_(num_channels, std::vector<float>(delay, 0.f)), read_index_(0u) {} |
| + |
| +DelayBuffer::~DelayBuffer() {} |
| + |
| +void DelayBuffer::Delay(float* const* data, size_t length) { |
| + for (size_t i = 0u; i < buffer_.size(); ++i) { |
| + size_t channel_index = read_index_; |
|
peah-webrtc
2016/09/17 21:31:30
Please consider changing this name.
To me, a chan
aluebs-webrtc
2016/09/19 19:17:14
Good point. Done.
|
| + for (size_t j = 0u; j < length; ++j) { |
| + float swap = data[i][j]; |
| + data[i][j] = buffer_[i][channel_index]; |
| + buffer_[i][channel_index] = swap; |
| + if (++channel_index == buffer_.size()) { |
| + channel_index = 0u; |
| + } |
| + } |
| + } |
| + read_index_ += length; |
| + while (read_index_ >= buffer_.size()) { |
|
peah-webrtc
2016/09/17 21:31:30
This part is not necessary. You have the wraparoun
aluebs-webrtc
2016/09/19 19:17:14
Good point. Done.
|
| + read_index_ -= buffer_.size(); |
| + } |
| +} |
| + |
| } // namespace intelligibility |
| } // namespace webrtc |