Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc

Issue 2320833002: Compensate for the IntelligibilityEnhancer processing delay in high bands (Closed)
Patch Set: Fix glitches Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
index 45f338c642540acaabf8fb96652b55c28f51cce0..372a8935177ab7f18a071e1282d5f304f5ecafd6 100644
--- a/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
+++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_enhancer_unittest.cc
@@ -202,11 +202,12 @@ static_assert(arraysize(kTestCenterFreqs) ==
const float kMaxTestError = 0.005f;
// Enhancer initialization parameters.
-const int kSamples = 1000;
+const int kSamples = 10000;
peah-webrtc 2016/09/13 13:30:00 What is the motivation behind the changed number o
aluebs-webrtc 2016/09/14 00:35:55 The number samples before where not enough for the
const int kSampleRate = 4000;
peah-webrtc 2016/09/13 13:30:00 What is the purpose of the samplerate constant of
aluebs-webrtc 2016/09/14 00:35:54 To set a sample rate for the tests.
peah-webrtc 2016/09/15 15:06:20 You mean that the test is running at a sample rate
aluebs-webrtc 2016/09/15 23:45:25 Other test (like the bitexactness and the one I ju
peah-webrtc 2016/09/16 13:35:56 It makes sense to test for other sample rates. But
aluebs-webrtc 2016/09/17 00:48:48 Acknowledged.
const int kNumChannels = 1;
const int kFragmentSize = kSampleRate / 100;
const size_t kNumNoiseBins = 129;
+const size_t kNumBands = 1;
// Number of frames to process in the bitexactness tests.
const size_t kNumFramesToProcess = 1000;
@@ -228,10 +229,7 @@ void ProcessOneFrame(int sample_rate_hz,
capture_audio_buffer->SplitIntoFrequencyBands();
}
- intelligibility_enhancer->ProcessRenderAudio(
- render_audio_buffer->split_channels_f(kBand0To8kHz),
- IntelligibilityEnhancerSampleRate(sample_rate_hz),
- render_audio_buffer->num_channels());
+ intelligibility_enhancer->ProcessRenderAudio(render_audio_buffer);
noise_suppressor->AnalyzeCaptureAudio(capture_audio_buffer);
noise_suppressor->ProcessCaptureAudio(capture_audio_buffer);
@@ -276,7 +274,8 @@ void RunBitexactnessTest(int sample_rate_hz,
IntelligibilityEnhancer intelligibility_enhancer(
IntelligibilityEnhancerSampleRate(sample_rate_hz),
- render_config.num_channels(), NoiseSuppressionImpl::num_noise_bins());
+ render_config.num_channels(), kNumBands,
+ NoiseSuppressionImpl::num_noise_bins());
for (size_t frame_no = 0u; frame_no < kNumFramesToProcess; ++frame_no) {
ReadFloatSamplesFromStereoFile(render_buffer.num_frames(),
@@ -320,24 +319,34 @@ float float_rand() {
class IntelligibilityEnhancerTest : public ::testing::Test {
protected:
IntelligibilityEnhancerTest()
- : clear_data_(kSamples), noise_data_(kSamples), orig_data_(kSamples) {
+ : clear_buffer_(kFragmentSize,
+ kNumChannels,
+ kFragmentSize,
+ kNumChannels,
+ kFragmentSize),
+ stream_config_(kSampleRate, kNumChannels),
+ clear_data_(kSamples),
+ noise_data_(kNumNoiseBins),
+ orig_data_(kSamples) {
std::srand(1);
- enh_.reset(
- new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumNoiseBins));
+ enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumBands,
+ kNumNoiseBins));
}
bool CheckUpdate() {
peah-webrtc 2016/09/13 13:30:00 I'd like a more descriptive name here. This method
aluebs-webrtc 2016/09/14 00:35:54 I think that it is a great idea, but I don't think
peah-webrtc 2016/09/15 15:06:20 Acknowledged.
- enh_.reset(
- new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumNoiseBins));
+ enh_.reset(new IntelligibilityEnhancer(kSampleRate, kNumChannels, kNumBands,
+ kNumNoiseBins));
float* clear_cursor = clear_data_.data();
peah-webrtc 2016/09/13 13:30:00 The name cursor I think is quite misleading as I c
aluebs-webrtc 2016/09/14 00:35:54 See above about naming.
- float* noise_cursor = noise_data_.data();
for (int i = 0; i < kSamples; i += kFragmentSize) {
- enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
+ enh_->SetCaptureNoiseEstimate(noise_data_, 1);
+ clear_buffer_.CopyFrom(&clear_cursor, stream_config_);
+ enh_->ProcessRenderAudio(&clear_buffer_);
+ clear_buffer_.CopyTo(stream_config_, &clear_cursor);
clear_cursor += kFragmentSize;
- noise_cursor += kFragmentSize;
}
- for (int i = 0; i < kSamples; i++) {
- if (std::fabs(clear_data_[i] - orig_data_[i]) > kMaxTestError) {
+ for (int i = initial_delay_; i < kSamples; i++) {
+ if (std::fabs(clear_data_[i] - orig_data_[i - initial_delay_]) >
peah-webrtc 2016/09/13 13:30:00 As far as I can see, this does not verify that the
aluebs-webrtc 2016/09/14 00:35:54 Added test.
+ kMaxTestError) {
return true;
}
}
@@ -345,22 +354,29 @@ class IntelligibilityEnhancerTest : public ::testing::Test {
}
std::unique_ptr<IntelligibilityEnhancer> enh_;
+ AudioBuffer clear_buffer_;
peah-webrtc 2016/09/13 13:30:00 What is the reason for this name? Please explain,
aluebs-webrtc 2016/09/14 00:35:54 To be consistent with the naming in the test I am
+ StreamConfig stream_config_;
std::vector<float> clear_data_;
std::vector<float> noise_data_;
std::vector<float> orig_data_;
+ size_t initial_delay_;
};
// For each class of generated data, tests that render stream is updated when
// it should be.
TEST_F(IntelligibilityEnhancerTest, TestRenderUpdate) {
+ initial_delay_ = enh_->render_mangler_->initial_delay();
std::fill(noise_data_.begin(), noise_data_.end(), 0.f);
std::fill(orig_data_.begin(), orig_data_.end(), 0.f);
std::fill(clear_data_.begin(), clear_data_.end(), 0.f);
EXPECT_FALSE(CheckUpdate());
- std::generate(noise_data_.begin(), noise_data_.end(), float_rand);
+ std::generate(clear_data_.begin(), clear_data_.end(), float_rand);
+ orig_data_ = clear_data_;
EXPECT_FALSE(CheckUpdate());
std::generate(clear_data_.begin(), clear_data_.end(), float_rand);
orig_data_ = clear_data_;
+ std::generate(noise_data_.begin(), noise_data_.end(), float_rand);
+ FloatToFloatS16(noise_data_.data(), noise_data_.size(), noise_data_.data());
EXPECT_TRUE(CheckUpdate());
}
@@ -418,7 +434,8 @@ TEST_F(IntelligibilityEnhancerTest, TestNoiseGainHasExpectedResult) {
float* clear_cursor = clear_data_.data();
for (size_t i = 0; i < kNumFramesToProcess; ++i) {
enh_->SetCaptureNoiseEstimate(noise, kGain);
- enh_->ProcessRenderAudio(&clear_cursor, kSampleRate, kNumChannels);
+ clear_buffer_.CopyFrom(&clear_cursor, stream_config_);
peah-webrtc 2016/09/13 13:30:00 Why don't you update the clear cursor counter here
aluebs-webrtc 2016/09/14 00:35:54 Because it is irrelevant to the Noise PSD estimati
peah-webrtc 2016/09/15 15:06:20 I see, so basically you don't really care about wh
aluebs-webrtc 2016/09/15 23:45:25 Agreed. But it is unrelated to this CL, so we shou
+ enh_->ProcessRenderAudio(&clear_buffer_);
}
const std::vector<float>& estimated_psd =
enh_->noise_power_estimator_.power();

Powered by Google App Engine
This is Rietveld 408576698