
Implemented the 3 bands splitting filter bank by: 1. Upsample by 4/3. 2. Split twice into 2 bands. 3. Discard upper most band, because it is empty anyway. A unittest was also implemented: 1. Generate a signal from presence or absence of sine waves of different frequencies. 2. Split into 3 bands and check their presence or absence. 3. Recombine the bands. 4. Calculate delay (as it is an IIR it depends on frequency). 5. Check that the cross correlation of input and output is high enough at that delay. BUG=webrtc:3146 R=andrew@webrtc.org, bjornv@webrtc.org, kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/31029004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7754 4adac7df-926f-26a2-2b94-8c16560cd09d
64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "webrtc/modules/audio_processing/channel_buffer.h"
|
|
|
|
namespace webrtc {
|
|
|
|
IFChannelBuffer::IFChannelBuffer(int samples_per_channel, int num_channels)
|
|
: ivalid_(true),
|
|
ibuf_(samples_per_channel, num_channels),
|
|
fvalid_(true),
|
|
fbuf_(samples_per_channel, num_channels) {}
|
|
|
|
ChannelBuffer<int16_t>* IFChannelBuffer::ibuf() {
|
|
RefreshI();
|
|
fvalid_ = false;
|
|
return &ibuf_;
|
|
}
|
|
|
|
ChannelBuffer<float>* IFChannelBuffer::fbuf() {
|
|
RefreshF();
|
|
ivalid_ = false;
|
|
return &fbuf_;
|
|
}
|
|
|
|
const ChannelBuffer<int16_t>* IFChannelBuffer::ibuf_const() const {
|
|
RefreshI();
|
|
return &ibuf_;
|
|
}
|
|
|
|
const ChannelBuffer<float>* IFChannelBuffer::fbuf_const() const {
|
|
RefreshF();
|
|
return &fbuf_;
|
|
}
|
|
|
|
void IFChannelBuffer::RefreshF() const {
|
|
if (!fvalid_) {
|
|
assert(ivalid_);
|
|
const int16_t* const int_data = ibuf_.data();
|
|
float* const float_data = fbuf_.data();
|
|
const int length = fbuf_.length();
|
|
for (int i = 0; i < length; ++i)
|
|
float_data[i] = int_data[i];
|
|
fvalid_ = true;
|
|
}
|
|
}
|
|
|
|
void IFChannelBuffer::RefreshI() const {
|
|
if (!ivalid_) {
|
|
assert(fvalid_);
|
|
FloatS16ToS16(fbuf_.data(), ibuf_.length(), ibuf_.data());
|
|
ivalid_ = true;
|
|
}
|
|
}
|
|
|
|
} // namespace webrtc
|