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
50 lines
1.7 KiB
C++
50 lines
1.7 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.
|
|
*/
|
|
|
|
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_
|
|
#define WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_
|
|
|
|
#include "webrtc/common_audio/include/audio_util.h"
|
|
#include "webrtc/modules/audio_processing/common.h"
|
|
|
|
namespace webrtc {
|
|
|
|
// One int16_t and one float ChannelBuffer that are kept in sync. The sync is
|
|
// broken when someone requests write access to either ChannelBuffer, and
|
|
// reestablished when someone requests the outdated ChannelBuffer. It is
|
|
// therefore safe to use the return value of ibuf_const() and fbuf_const()
|
|
// until the next call to ibuf() or fbuf(), and the return value of ibuf() and
|
|
// fbuf() until the next call to any of the other functions.
|
|
class IFChannelBuffer {
|
|
public:
|
|
IFChannelBuffer(int samples_per_channel, int num_channels);
|
|
|
|
ChannelBuffer<int16_t>* ibuf();
|
|
ChannelBuffer<float>* fbuf();
|
|
const ChannelBuffer<int16_t>* ibuf_const() const;
|
|
const ChannelBuffer<float>* fbuf_const() const;
|
|
|
|
int num_channels() const { return ibuf_.num_channels(); }
|
|
int samples_per_channel() const { return ibuf_.samples_per_channel(); }
|
|
|
|
private:
|
|
void RefreshF() const;
|
|
void RefreshI() const;
|
|
|
|
mutable bool ivalid_;
|
|
mutable ChannelBuffer<int16_t> ibuf_;
|
|
mutable bool fvalid_;
|
|
mutable ChannelBuffer<float> fbuf_;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_CHANNEL_BUFFER_H_
|