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

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

Issue 2834643002: audioproc_f with simulated mic analog gain (Closed)
Patch Set: set_stream_analog_level and stream_analog_level moved into parent class AudioProcessingSimulator Created 3 years, 8 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 "webrtc/modules/audio_processing/test/audio_processing_simulator.h" 11 #include "webrtc/modules/audio_processing/test/audio_processing_simulator.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <iostream> 14 #include <iostream>
15 #include <sstream> 15 #include <sstream>
16 #include <string> 16 #include <string>
17 #include <utility>
17 #include <vector> 18 #include <vector>
18 19
19 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
20 #include "webrtc/base/stringutils.h" 21 #include "webrtc/base/stringutils.h"
21 #include "webrtc/common_audio/include/audio_util.h" 22 #include "webrtc/common_audio/include/audio_util.h"
22 #include "webrtc/modules/audio_processing/include/audio_processing.h" 23 #include "webrtc/modules/audio_processing/include/audio_processing.h"
23 24
24 namespace webrtc { 25 namespace webrtc {
25 namespace test { 26 namespace test {
26 namespace { 27 namespace {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 96 }
96 } 97 }
97 98
98 AudioProcessingSimulator::ScopedTimer::~ScopedTimer() { 99 AudioProcessingSimulator::ScopedTimer::~ScopedTimer() {
99 int64_t interval = rtc::TimeNanos() - start_time_; 100 int64_t interval = rtc::TimeNanos() - start_time_;
100 proc_time_->sum += interval; 101 proc_time_->sum += interval;
101 proc_time_->max = std::max(proc_time_->max, interval); 102 proc_time_->max = std::max(proc_time_->max, interval);
102 proc_time_->min = std::min(proc_time_->min, interval); 103 proc_time_->min = std::min(proc_time_->min, interval);
103 } 104 }
104 105
105 void AudioProcessingSimulator::ProcessStream(bool fixed_interface) { 106 void AudioProcessingSimulator::ProcessStream(bool fixed_interface,
107 bool skip_analog_level_update) {
108 if (!skip_analog_level_update)
aleloi 2017/04/21 11:46:42 Add brackets. Also, suggest changing |if not skip_
AleBzk 2017/04/24 09:40:26 Done.
109 RTC_CHECK_EQ(AudioProcessing::kNoError,
110 ap_->gain_control()->set_stream_analog_level(
111 last_specified_microphone_level_));
106 if (fixed_interface) { 112 if (fixed_interface) {
107 { 113 {
108 const auto st = ScopedTimer(mutable_proc_time()); 114 const auto st = ScopedTimer(mutable_proc_time());
115 // TODO(alessiob): Apply last_specified_microphone_level_ to fwd_frame_
116 // simulating a mic with analog gain.
109 RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->ProcessStream(&fwd_frame_)); 117 RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->ProcessStream(&fwd_frame_));
110 } 118 }
111 CopyFromAudioFrame(fwd_frame_, out_buf_.get()); 119 CopyFromAudioFrame(fwd_frame_, out_buf_.get());
112 } else { 120 } else {
113 const auto st = ScopedTimer(mutable_proc_time()); 121 const auto st = ScopedTimer(mutable_proc_time());
122 // TODO(alessiob): Apply last_specified_microphone_level_ to
123 // in_buf_->channels() simulating a mic with analog gain.
114 RTC_CHECK_EQ(AudioProcessing::kNoError, 124 RTC_CHECK_EQ(AudioProcessing::kNoError,
115 ap_->ProcessStream(in_buf_->channels(), in_config_, 125 ap_->ProcessStream(in_buf_->channels(), in_config_,
116 out_config_, out_buf_->channels())); 126 out_config_, out_buf_->channels()));
117 } 127 }
128 // Update last_specified_microphone_level_ using the value suggested by AGC
129 // or the default if settings_.simulate_mic_gain is false.
130 // TODO(alessiob): Check what the default value should be, probably 100 is ok.
131 if (!skip_analog_level_update)
aleloi 2017/04/21 11:46:42 Add brackets
AleBzk 2017/04/24 09:40:26 Done.
132 last_specified_microphone_level_ = (settings_.simulate_mic_gain) ?
aleloi 2017/04/21 11:46:42 Suggest drop parentheses.
AleBzk 2017/04/24 09:40:26 Done.
133 ap_->gain_control()->stream_analog_level() : 100;
118 134
119 if (buffer_writer_) { 135 if (buffer_writer_) {
120 buffer_writer_->Write(*out_buf_); 136 buffer_writer_->Write(*out_buf_);
121 } 137 }
122 138
123 if (residual_echo_likelihood_graph_writer_.is_open()) { 139 if (residual_echo_likelihood_graph_writer_.is_open()) {
124 auto stats = ap_->GetStatistics(); 140 auto stats = ap_->GetStatistics();
125 residual_echo_likelihood_graph_writer_ << stats.residual_echo_likelihood 141 residual_echo_likelihood_graph_writer_ << stats.residual_echo_likelihood
126 << ", "; 142 << ", ";
127 } 143 }
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 size_t kMaxFilenameSize = AudioProcessing::kMaxFilenameSize; 404 size_t kMaxFilenameSize = AudioProcessing::kMaxFilenameSize;
389 RTC_CHECK_LE(settings_.aec_dump_output_filename->size(), kMaxFilenameSize); 405 RTC_CHECK_LE(settings_.aec_dump_output_filename->size(), kMaxFilenameSize);
390 RTC_CHECK_EQ(AudioProcessing::kNoError, 406 RTC_CHECK_EQ(AudioProcessing::kNoError,
391 ap_->StartDebugRecording( 407 ap_->StartDebugRecording(
392 settings_.aec_dump_output_filename->c_str(), -1)); 408 settings_.aec_dump_output_filename->c_str(), -1));
393 } 409 }
394 } 410 }
395 411
396 } // namespace test 412 } // namespace test
397 } // namespace webrtc 413 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698