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

Side by Side Diff: webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc

Issue 2834643002: audioproc_f with simulated mic analog gain (Closed)
Patch Set: fake rec device boilerplate reduced, aec dump simulated analog gain logic moved Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <algorithm>
peah-webrtc 2017/06/29 05:45:26 Why was algorithm and utility added to the include
AleBzk 2017/06/29 11:43:35 Good catch! Thanks!
11 #include <iostream> 12 #include <iostream>
13 #include <utility>
12 14
13 #include "webrtc/modules/audio_processing/test/aec_dump_based_simulator.h" 15 #include "webrtc/modules/audio_processing/test/aec_dump_based_simulator.h"
14 16
15 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h"
19 #include "webrtc/modules/audio_processing/test/fake_recording_device.h"
peah-webrtc 2017/06/29 05:45:26 This include is not needed, right?
AleBzk 2017/06/29 11:43:35 Yet another good catch :)
16 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" 20 #include "webrtc/modules/audio_processing/test/protobuf_utils.h"
17 #include "webrtc/test/testsupport/trace_to_stderr.h" 21 #include "webrtc/test/testsupport/trace_to_stderr.h"
18 22
19 namespace webrtc { 23 namespace webrtc {
20 namespace test { 24 namespace test {
21 namespace { 25 namespace {
22 26
23 // Verify output bitexactness for the fixed interface. 27 // Verify output bitexactness for the fixed interface.
24 // TODO(peah): Check whether it would make sense to add a threshold 28 // TODO(peah): Check whether it would make sense to add a threshold
25 // to use for checking the bitexactness in a soft manner. 29 // to use for checking the bitexactness in a soft manner.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 61 }
58 } 62 }
59 } 63 }
60 } 64 }
61 return true; 65 return true;
62 } 66 }
63 67
64 } // namespace 68 } // namespace
65 69
66 AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings) 70 AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings)
67 : AudioProcessingSimulator(settings) {} 71 : AudioProcessingSimulator(settings) {
72 if (settings_.simulate_mic_gain) {
73 LOG(LS_VERBOSE) << "Simulating analog mic gain using AEC dump as input "
74 << "(the unmodified mic gain level will be virtually restored)";
75 }
76 }
68 77
69 AecDumpBasedSimulator::~AecDumpBasedSimulator() = default; 78 AecDumpBasedSimulator::~AecDumpBasedSimulator() = default;
70 79
71 void AecDumpBasedSimulator::PrepareProcessStreamCall( 80 void AecDumpBasedSimulator::PrepareProcessStreamCall(
72 const webrtc::audioproc::Stream& msg, 81 const webrtc::audioproc::Stream& msg) {
73 bool* set_stream_analog_level_called) {
74 if (msg.has_input_data()) { 82 if (msg.has_input_data()) {
75 // Fixed interface processing. 83 // Fixed interface processing.
76 // Verify interface invariance. 84 // Verify interface invariance.
77 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface || 85 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface ||
78 interface_used_ == InterfaceType::kNotSpecified); 86 interface_used_ == InterfaceType::kNotSpecified);
79 interface_used_ = InterfaceType::kFixedInterface; 87 interface_used_ = InterfaceType::kFixedInterface;
80 88
81 // Populate input buffer. 89 // Populate input buffer.
82 RTC_CHECK_EQ(sizeof(*fwd_frame_.data()) * fwd_frame_.samples_per_channel_ * 90 RTC_CHECK_EQ(sizeof(*fwd_frame_.data()) * fwd_frame_.samples_per_channel_ *
83 fwd_frame_.num_channels_, 91 fwd_frame_.num_channels_,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 160 }
153 161
154 if (!settings_.use_ts) { 162 if (!settings_.use_ts) {
155 if (msg.has_keypress()) { 163 if (msg.has_keypress()) {
156 ap_->set_stream_key_pressed(msg.keypress()); 164 ap_->set_stream_key_pressed(msg.keypress());
157 } 165 }
158 } else { 166 } else {
159 ap_->set_stream_key_pressed(*settings_.use_ts); 167 ap_->set_stream_key_pressed(*settings_.use_ts);
160 } 168 }
161 169
162 // TODO(peah): Add support for controlling the analog level via the 170 // Level is always logged in AEC dumps.
163 // command-line. 171 RTC_CHECK(msg.has_level());
164 if (msg.has_level()) { 172 aec_dump_mic_level_ = rtc::Optional<int>(msg.level());
165 RTC_CHECK_EQ(AudioProcessing::kNoError,
166 ap_->gain_control()->set_stream_analog_level(msg.level()));
167 *set_stream_analog_level_called = true;
168 } else {
169 *set_stream_analog_level_called = false;
170 }
171 } 173 }
172 174
173 void AecDumpBasedSimulator::VerifyProcessStreamBitExactness( 175 void AecDumpBasedSimulator::VerifyProcessStreamBitExactness(
174 const webrtc::audioproc::Stream& msg) { 176 const webrtc::audioproc::Stream& msg) {
175 if (bitexact_output_) { 177 if (bitexact_output_) {
176 if (interface_used_ == InterfaceType::kFixedInterface) { 178 if (interface_used_ == InterfaceType::kFixedInterface) {
177 bitexact_output_ = VerifyFixedBitExactness(msg, fwd_frame_); 179 bitexact_output_ = VerifyFixedBitExactness(msg, fwd_frame_);
178 } else { 180 } else {
179 bitexact_output_ = VerifyFloatBitExactness(msg, out_config_, *out_buf_); 181 bitexact_output_ = VerifyFloatBitExactness(msg, out_config_, *out_buf_);
180 } 182 }
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 560 }
559 561
560 SetupBuffersConfigsOutputs( 562 SetupBuffersConfigsOutputs(
561 msg.sample_rate(), output_sample_rate, msg.reverse_sample_rate(), 563 msg.sample_rate(), output_sample_rate, msg.reverse_sample_rate(),
562 reverse_output_sample_rate, msg.num_input_channels(), num_output_channels, 564 reverse_output_sample_rate, msg.num_input_channels(), num_output_channels,
563 msg.num_reverse_channels(), num_reverse_output_channels); 565 msg.num_reverse_channels(), num_reverse_output_channels);
564 } 566 }
565 567
566 void AecDumpBasedSimulator::HandleMessage( 568 void AecDumpBasedSimulator::HandleMessage(
567 const webrtc::audioproc::Stream& msg) { 569 const webrtc::audioproc::Stream& msg) {
568 bool set_stream_analog_level_called = false; 570 PrepareProcessStreamCall(msg);
569 PrepareProcessStreamCall(msg, &set_stream_analog_level_called);
570 ProcessStream(interface_used_ == InterfaceType::kFixedInterface); 571 ProcessStream(interface_used_ == InterfaceType::kFixedInterface);
571 if (set_stream_analog_level_called) {
572 // Call stream analog level to ensure that any side-effects are triggered.
573 (void)ap_->gain_control()->stream_analog_level();
574 }
575
576 VerifyProcessStreamBitExactness(msg); 572 VerifyProcessStreamBitExactness(msg);
577 } 573 }
578 574
579 void AecDumpBasedSimulator::HandleMessage( 575 void AecDumpBasedSimulator::HandleMessage(
580 const webrtc::audioproc::ReverseStream& msg) { 576 const webrtc::audioproc::ReverseStream& msg) {
581 PrepareReverseProcessStreamCall(msg); 577 PrepareReverseProcessStreamCall(msg);
582 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface); 578 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface);
583 } 579 }
584 580
585 } // namespace test 581 } // namespace test
586 } // namespace webrtc 582 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698