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 778b347091d82a9270a2904e8c4d329061df60c2..1d2f2273a0928636ddb1d2c274f230eddbb36398 100644 |
| --- a/webrtc/modules/audio_processing/test/audio_processing_simulator.cc |
| +++ b/webrtc/modules/audio_processing/test/audio_processing_simulator.cc |
| @@ -42,6 +42,22 @@ std::string GetIndexedOutputWavFilename(const std::string& wav_name, |
| return ss.str(); |
| } |
| +void WriteEchoLikelihoodGraphFileHeader(std::ofstream* output_file) { |
| + (*output_file) << "import numpy as np" << std::endl |
| + << "import matplotlib.pyplot as plt" << std::endl |
| + << "y = np.array(["; |
| +} |
| + |
| +void WriteEchoLikelihoodGraphFileFooter(std::ofstream* output_file) { |
| + (*output_file) << "])" << std::endl |
| + << "x = np.arange(len(y))*.01" << std::endl |
| + << "plt.plot(x, y)" << std::endl |
| + << "plt.ylabel('Echo likelihood')" << std::endl |
| + << "plt.xlabel('Time (s)')" << std::endl |
| + << "plt.ylim([0,1])" << std::endl |
| + << "plt.show()" << std::endl; |
| +} |
| + |
| } // namespace |
| SimulationSettings::SimulationSettings() = default; |
| @@ -61,9 +77,22 @@ void CopyToAudioFrame(const ChannelBuffer<float>& src, AudioFrame* dest) { |
| AudioProcessingSimulator::AudioProcessingSimulator( |
| const SimulationSettings& settings) |
| - : settings_(settings) {} |
| + : settings_(settings) { |
| + if (settings_.red_graph_output_filename && |
| + settings_.red_graph_output_filename->size() > 0) { |
| + residual_echo_likelihood_graph_writer_.open( |
| + *settings_.red_graph_output_filename); |
| + RTC_CHECK(residual_echo_likelihood_graph_writer_.is_open()); |
|
hlundin-webrtc
2016/11/14 14:23:11
Great! Now all you have to do is remember to #incl
ivoc
2016/11/14 14:55:04
Done. I saw all those other CHECKS in the file so
|
| + WriteEchoLikelihoodGraphFileHeader(&residual_echo_likelihood_graph_writer_); |
| + } |
| +} |
| -AudioProcessingSimulator::~AudioProcessingSimulator() = default; |
| +AudioProcessingSimulator::~AudioProcessingSimulator() { |
| + if (residual_echo_likelihood_graph_writer_.is_open()) { |
| + WriteEchoLikelihoodGraphFileFooter(&residual_echo_likelihood_graph_writer_); |
| + residual_echo_likelihood_graph_writer_.close(); |
| + } |
| +} |
| AudioProcessingSimulator::ScopedTimer::~ScopedTimer() { |
| int64_t interval = rtc::TimeNanos() - start_time_; |
| @@ -90,6 +119,12 @@ void AudioProcessingSimulator::ProcessStream(bool fixed_interface) { |
| buffer_writer_->Write(*out_buf_); |
| } |
| + if (residual_echo_likelihood_graph_writer_.is_open()) { |
| + auto stats = ap_->GetStatistics(); |
| + residual_echo_likelihood_graph_writer_ << stats.residual_echo_likelihood |
| + << ", "; |
| + } |
| + |
| ++num_process_stream_calls_; |
| } |
| @@ -245,6 +280,9 @@ void AudioProcessingSimulator::CreateAudioProcessor() { |
| !settings_.use_extended_filter || *settings_.use_extended_filter)); |
| config.Set<DelayAgnostic>(new DelayAgnostic(!settings_.use_delay_agnostic || |
| *settings_.use_delay_agnostic)); |
| + if (settings_.use_red) { |
| + apm_config.residual_echo_detector.enabled = *settings_.use_red; |
| + } |
| ap_.reset(AudioProcessing::Create(config)); |
| RTC_CHECK(ap_); |