AEC3: Make RenderSignalAnalyzer multi-channel
In this CL: - Render signal analyzer considers a frequency bin a narrow band (peak) if any channel exhibits narrowband (-peak) behavior. - The unit tests have to fill frames with noise because small inaccuracies in the FFT spectrum lead to consistent "narrow bands" despite spectrum being essentially flat. Bug: webrtc:10913 Change-Id: I8fa181412c0ee1beeacfda37ffef18251d5f0cd7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/151912 Reviewed-by: Per Åhgren <peah@webrtc.org> Commit-Queue: Sam Zackrisson <saza@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29176}
This commit is contained in:
committed by
Commit Bot
parent
b5a4ae8a57
commit
3f17221d98
@ -15,8 +15,15 @@
|
||||
namespace webrtc {
|
||||
|
||||
void RandomizeSampleVector(Random* random_generator, rtc::ArrayView<float> v) {
|
||||
RandomizeSampleVector(random_generator, v,
|
||||
/*amplitude=*/32767.f);
|
||||
}
|
||||
|
||||
void RandomizeSampleVector(Random* random_generator,
|
||||
rtc::ArrayView<float> v,
|
||||
float amplitude) {
|
||||
for (auto& v_k : v) {
|
||||
v_k = 2 * 32767.f * random_generator->Rand<float>() - 32767.f;
|
||||
v_k = 2 * amplitude * random_generator->Rand<float>() - amplitude;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,11 @@ namespace webrtc {
|
||||
// Randomizes the elements in a vector with values -32767.f:32767.f.
|
||||
void RandomizeSampleVector(Random* random_generator, rtc::ArrayView<float> v);
|
||||
|
||||
// Randomizes the elements in a vector with values -amplitude:amplitude.
|
||||
void RandomizeSampleVector(Random* random_generator,
|
||||
rtc::ArrayView<float> v,
|
||||
float amplitude);
|
||||
|
||||
// Class for delaying a signal a fixed number of samples.
|
||||
template <typename T>
|
||||
class DelayBuffer {
|
||||
|
||||
@ -68,4 +68,15 @@ TEST(EchoCancellerTestTools, RandomizeSampleVector) {
|
||||
EXPECT_NE(v, v_ref);
|
||||
}
|
||||
|
||||
TEST(EchoCancellerTestTools, RandomizeSampleVectorWithAmplitude) {
|
||||
Random random_generator(42U);
|
||||
std::vector<float> v(50, 0.f);
|
||||
RandomizeSampleVector(&random_generator, v, 1000.f);
|
||||
EXPECT_GE(1000.f, *std::max_element(v.begin(), v.end()));
|
||||
EXPECT_LE(-1000.f, *std::min_element(v.begin(), v.end()));
|
||||
RandomizeSampleVector(&random_generator, v, 100.f);
|
||||
EXPECT_GE(100.f, *std::max_element(v.begin(), v.end()));
|
||||
EXPECT_LE(-100.f, *std::min_element(v.begin(), v.end()));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user