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

Side by Side Diff: webrtc/modules/audio_processing/test/wav_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 "webrtc/modules/audio_processing/test/wav_based_simulator.h" 11 #include "webrtc/modules/audio_processing/test/wav_based_simulator.h"
12 12
13 #include <stdio.h> 13 #include <stdio.h>
14 #include <iostream> 14 #include <iostream>
15 #include <memory>
16 #include <utility>
peah-webrtc 2017/06/29 05:45:27 Why is utility needed?
AleBzk 2017/06/29 11:43:36 Good catch, thanks!
15 17
16 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/modules/audio_processing/test/fake_recording_device.h"
peah-webrtc 2017/06/29 05:45:27 This include is not needed.
AleBzk 2017/06/29 11:43:36 Done.
17 #include "webrtc/modules/audio_processing/test/test_utils.h" 20 #include "webrtc/modules/audio_processing/test/test_utils.h"
18 #include "webrtc/test/testsupport/trace_to_stderr.h" 21 #include "webrtc/test/testsupport/trace_to_stderr.h"
19 22
20 namespace webrtc { 23 namespace webrtc {
21 namespace test { 24 namespace test {
22 25
23 std::vector<WavBasedSimulator::SimulationEventType> 26 std::vector<WavBasedSimulator::SimulationEventType>
24 WavBasedSimulator::GetCustomEventChain(const std::string& filename) { 27 WavBasedSimulator::GetCustomEventChain(const std::string& filename) {
25 std::vector<WavBasedSimulator::SimulationEventType> call_chain; 28 std::vector<WavBasedSimulator::SimulationEventType> call_chain;
26 FILE* stream = OpenFile(filename.c_str(), "r"); 29 FILE* stream = OpenFile(filename.c_str(), "r");
(...skipping 21 matching lines...) Expand all
48 } 51 }
49 52
50 num_read = fread(&c, sizeof(char), 1, stream); 53 num_read = fread(&c, sizeof(char), 1, stream);
51 } 54 }
52 55
53 fclose(stream); 56 fclose(stream);
54 return call_chain; 57 return call_chain;
55 } 58 }
56 59
57 WavBasedSimulator::WavBasedSimulator(const SimulationSettings& settings) 60 WavBasedSimulator::WavBasedSimulator(const SimulationSettings& settings)
58 : AudioProcessingSimulator(settings) {} 61 : AudioProcessingSimulator(settings) {}
peah-webrtc 2017/06/29 05:45:27 Is this caused by git cl format? Was the indendati
AleBzk 2017/06/29 11:43:36 Right.
59 62
60 WavBasedSimulator::~WavBasedSimulator() = default; 63 WavBasedSimulator::~WavBasedSimulator() = default;
61 64
62 std::vector<WavBasedSimulator::SimulationEventType> 65 std::vector<WavBasedSimulator::SimulationEventType>
63 WavBasedSimulator::GetDefaultEventChain() { 66 WavBasedSimulator::GetDefaultEventChain() {
64 std::vector<WavBasedSimulator::SimulationEventType> call_chain(2); 67 std::vector<WavBasedSimulator::SimulationEventType> call_chain(2);
65 call_chain[0] = SimulationEventType::kProcessStream; 68 call_chain[0] = SimulationEventType::kProcessStream;
66 call_chain[1] = SimulationEventType::kProcessReverseStream; 69 call_chain[1] = SimulationEventType::kProcessReverseStream;
67 return call_chain; 70 return call_chain;
68 } 71 }
69 72
70 void WavBasedSimulator::PrepareProcessStreamCall() { 73 void WavBasedSimulator::PrepareProcessStreamCall() {
71 if (settings_.fixed_interface) { 74 if (settings_.fixed_interface) {
72 CopyToAudioFrame(*in_buf_, &fwd_frame_); 75 CopyToAudioFrame(*in_buf_, &fwd_frame_);
73 } 76 }
74 ap_->set_stream_key_pressed(settings_.use_ts && (*settings_.use_ts)); 77 ap_->set_stream_key_pressed(settings_.use_ts && (*settings_.use_ts));
75 78
76 RTC_CHECK_EQ(AudioProcessing::kNoError, 79 RTC_CHECK_EQ(AudioProcessing::kNoError,
77 ap_->set_stream_delay_ms( 80 ap_->set_stream_delay_ms(
78 settings_.stream_delay ? *settings_.stream_delay : 0)); 81 settings_.stream_delay ? *settings_.stream_delay : 0));
79 82
80 ap_->echo_cancellation()->set_stream_drift_samples( 83 ap_->echo_cancellation()->set_stream_drift_samples(
81 settings_.stream_drift_samples ? *settings_.stream_drift_samples : 0); 84 settings_.stream_drift_samples ? *settings_.stream_drift_samples : 0);
82
83 RTC_CHECK_EQ(AudioProcessing::kNoError,
84 ap_->gain_control()->set_stream_analog_level(
85 last_specified_microphone_level_));
86 } 85 }
87 86
88 void WavBasedSimulator::PrepareReverseProcessStreamCall() { 87 void WavBasedSimulator::PrepareReverseProcessStreamCall() {
89 if (settings_.fixed_interface) { 88 if (settings_.fixed_interface) {
90 CopyToAudioFrame(*reverse_in_buf_, &rev_frame_); 89 CopyToAudioFrame(*reverse_in_buf_, &rev_frame_);
91 } 90 }
92 } 91 }
93 92
94 void WavBasedSimulator::Process() { 93 void WavBasedSimulator::Process() {
95 std::unique_ptr<test::TraceToStderr> trace_to_stderr; 94 std::unique_ptr<test::TraceToStderr> trace_to_stderr;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 135 }
137 136
138 DestroyAudioProcessor(); 137 DestroyAudioProcessor();
139 } 138 }
140 139
141 bool WavBasedSimulator::HandleProcessStreamCall() { 140 bool WavBasedSimulator::HandleProcessStreamCall() {
142 bool samples_left_to_process = buffer_reader_->Read(in_buf_.get()); 141 bool samples_left_to_process = buffer_reader_->Read(in_buf_.get());
143 if (samples_left_to_process) { 142 if (samples_left_to_process) {
144 PrepareProcessStreamCall(); 143 PrepareProcessStreamCall();
145 ProcessStream(settings_.fixed_interface); 144 ProcessStream(settings_.fixed_interface);
146 // Call stream analog level to ensure that any side-effects are triggered.
147 (void)ap_->gain_control()->stream_analog_level();
148 last_specified_microphone_level_ =
149 ap_->gain_control()->stream_analog_level();
150 } 145 }
151 return samples_left_to_process; 146 return samples_left_to_process;
152 } 147 }
153 148
154 bool WavBasedSimulator::HandleProcessReverseStreamCall() { 149 bool WavBasedSimulator::HandleProcessReverseStreamCall() {
155 bool samples_left_to_process = 150 bool samples_left_to_process =
156 reverse_buffer_reader_->Read(reverse_in_buf_.get()); 151 reverse_buffer_reader_->Read(reverse_in_buf_.get());
157 if (samples_left_to_process) { 152 if (samples_left_to_process) {
158 PrepareReverseProcessStreamCall(); 153 PrepareReverseProcessStreamCall();
159 ProcessReverseStream(settings_.fixed_interface); 154 ProcessReverseStream(settings_.fixed_interface);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 192 }
198 193
199 SetupBuffersConfigsOutputs( 194 SetupBuffersConfigsOutputs(
200 input_sample_rate_hz, output_sample_rate_hz, reverse_sample_rate_hz, 195 input_sample_rate_hz, output_sample_rate_hz, reverse_sample_rate_hz,
201 reverse_output_sample_rate_hz, input_num_channels, output_num_channels, 196 reverse_output_sample_rate_hz, input_num_channels, output_num_channels,
202 reverse_num_channels, reverse_output_num_channels); 197 reverse_num_channels, reverse_output_num_channels);
203 } 198 }
204 199
205 } // namespace test 200 } // namespace test
206 } // namespace webrtc 201 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698