Chromium Code Reviews| Index: webrtc/modules/audio_processing/test/audio_processing_simulator.cc |
| diff --git a/webrtc/modules/audio_processing/test/audio_processing_simulator.cc b/webrtc/modules/audio_processing/test/audio_processing_simulator.cc |
| index d2c274f460010af7976fc2a2f1032c8bb72ecc8a..3be28314066fb17b3f6e55a8f5212bc96e3bf3d4 100644 |
| --- a/webrtc/modules/audio_processing/test/audio_processing_simulator.cc |
| +++ b/webrtc/modules/audio_processing/test/audio_processing_simulator.cc |
| @@ -14,9 +14,11 @@ |
| #include <iostream> |
| #include <sstream> |
| #include <string> |
| +#include <utility> |
| #include <vector> |
| #include "webrtc/base/checks.h" |
| +#include "webrtc/base/logging.h" |
| #include "webrtc/base/stringutils.h" |
| #include "webrtc/common_audio/include/audio_util.h" |
| #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| @@ -78,7 +80,13 @@ void CopyToAudioFrame(const ChannelBuffer<float>& src, AudioFrame* dest) { |
| AudioProcessingSimulator::AudioProcessingSimulator( |
| const SimulationSettings& settings) |
| - : settings_(settings) { |
| + : settings_(settings), |
| + fake_recording_device_(settings_.simulate_mic_gain ? |
| + static_cast<FakeRecordingDevice::LevelToScalingMappingKind>( |
| + *settings.simulated_mic_kind) : kDefaultMicKind) { |
| + if (settings_.simulate_mic_gain) { |
| + fake_recording_device_.set_analog_level(kInitialMicrophoneGainLevel); |
| + } |
| if (settings_.ed_graph_output_filename && |
| settings_.ed_graph_output_filename->size() > 0) { |
| residual_echo_likelihood_graph_writer_.open( |
| @@ -103,19 +111,48 @@ AudioProcessingSimulator::ScopedTimer::~ScopedTimer() { |
| } |
| void AudioProcessingSimulator::ProcessStream(bool fixed_interface) { |
| + LOG(LS_VERBOSE) << "AGC set_stream_analog_level set to " |
|
peah-webrtc
2017/05/05 06:28:41
Too verbose logging.
AleBzk
2017/05/05 12:20:17
I only removed the log below (namely, LOG(LS_VERBO
peah-webrtc
2017/05/05 20:25:20
I would not analyze the AGC suggested values like
|
| + << fake_recording_device_.analog_level(); |
| + RTC_CHECK_EQ(AudioProcessing::kNoError, |
| + ap_->gain_control()->set_stream_analog_level( |
|
peah-webrtc
2017/05/05 06:28:41
I'd prefer a decoupling between the stored stream
AleBzk
2017/05/05 12:20:17
Done.
|
| + fake_recording_device_.analog_level())); |
| + |
| if (fixed_interface) { |
| { |
| const auto st = ScopedTimer(mutable_proc_time()); |
| + // TODO(alessiob): Simulate application gain. |
| + if (settings_.simulate_mic_gain) { |
| + fake_recording_device_.ProcessStream(&fwd_frame_, &fwd_frame_); |
| + } |
| RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->ProcessStream(&fwd_frame_)); |
| } |
| CopyFromAudioFrame(fwd_frame_, out_buf_.get()); |
| } else { |
| const auto st = ScopedTimer(mutable_proc_time()); |
| + // TODO(alessiob): Simulate application gain. |
| + if (settings_.simulate_mic_gain) { |
| + const size_t channel_size = in_config_.num_frames(); |
| + |
| + std::vector<rtc::ArrayView<const float>> data_view; |
| + std::vector<rtc::ArrayView<float>> after_scaling_view; |
| + for (size_t i = 0; i < in_config_.num_channels(); ++i) { |
| + data_view.emplace_back(in_buf_->channels()[i], channel_size); |
| + after_scaling_view.emplace_back(in_buf_->channels()[i], channel_size); |
| + } |
| + |
| + fake_recording_device_.ProcessStream(data_view, after_scaling_view); |
| + } |
| RTC_CHECK_EQ(AudioProcessing::kNoError, |
| ap_->ProcessStream(in_buf_->channels(), in_config_, |
| out_config_, out_buf_->channels())); |
| } |
| + // Store the mic gain level suggested by AGC if required. |
| + fake_recording_device_.set_analog_level( |
| + ap_->gain_control()->stream_analog_level()); |
| + LOG(LS_VERBOSE) << "AGC stream_analog_level() returned " |
|
peah-webrtc
2017/05/05 06:28:41
This will become too much logging.
AleBzk
2017/05/05 12:20:17
Done.
|
| + << fake_recording_device_.analog_level(); |
| + |
| if (buffer_writer_) { |
| buffer_writer_->Write(*out_buf_); |
| } |
| @@ -193,6 +230,8 @@ void AudioProcessingSimulator::SetupBuffersConfigsOutputs( |
| rev_frame_.num_channels_ = reverse_input_num_channels; |
| if (settings_.use_verbose_logging) { |
| + rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE); |
| + |
| std::cout << "Sample rates:" << std::endl; |
| std::cout << " Forward input: " << input_sample_rate_hz << std::endl; |
| std::cout << " Forward output: " << output_sample_rate_hz << std::endl; |