OLD | NEW |
---|---|
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 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 for (size_t ch = 0; ch < dest->num_channels_; ++ch) { | 54 for (size_t ch = 0; ch < dest->num_channels_; ++ch) { |
55 for (size_t sample = 0; sample < dest->samples_per_channel_; ++sample) { | 55 for (size_t sample = 0; sample < dest->samples_per_channel_; ++sample) { |
56 dest->data_[sample * dest->num_channels_ + ch] = | 56 dest->data_[sample * dest->num_channels_ + ch] = |
57 src.channels()[ch][sample] * 32767; | 57 src.channels()[ch][sample] * 32767; |
58 } | 58 } |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 AudioProcessingSimulator::AudioProcessingSimulator( | 62 AudioProcessingSimulator::AudioProcessingSimulator( |
63 const SimulationSettings& settings) | 63 const SimulationSettings& settings) |
64 : settings_(settings) {} | 64 : settings_(settings) { |
65 if (settings_.red_graph_output_filename && | |
66 settings_.red_graph_output_filename->size() > 0) { | |
67 residual_echo_likelihood_graph_.open(*settings_.red_graph_output_filename); | |
68 residual_echo_likelihood_graph_ << "import numpy as np" << std::endl | |
peah-webrtc
2016/11/10 10:47:10
Would it be possible to abstract this printout int
ivoc
2016/11/10 15:36:08
Ok, done.
| |
69 << "import matplotlib.pyplot as plt" | |
70 << std::endl | |
71 << "y = np.array(["; | |
72 } | |
73 } | |
65 | 74 |
66 AudioProcessingSimulator::~AudioProcessingSimulator() = default; | 75 AudioProcessingSimulator::~AudioProcessingSimulator() { |
76 if (residual_echo_likelihood_graph_.is_open()) { | |
77 residual_echo_likelihood_graph_ << "])" << std::endl | |
peah-webrtc
2016/11/10 10:47:09
Would it be possible to abstract this printout int
ivoc
2016/11/10 15:36:08
Done.
| |
78 << "x = np.arange(len(y))*.01" << std::endl | |
79 << "plt.plot(x, y)" << std::endl | |
80 << "plt.ylabel('Echo likelihood')" | |
81 << std::endl | |
82 << "plt.xlabel('Time (s)')" << std::endl | |
83 << "plt.ylim([0,1])" << std::endl | |
84 << "plt.show()" << std::endl; | |
85 residual_echo_likelihood_graph_.close(); | |
86 } | |
87 } | |
67 | 88 |
68 AudioProcessingSimulator::ScopedTimer::~ScopedTimer() { | 89 AudioProcessingSimulator::ScopedTimer::~ScopedTimer() { |
69 int64_t interval = rtc::TimeNanos() - start_time_; | 90 int64_t interval = rtc::TimeNanos() - start_time_; |
70 proc_time_->sum += interval; | 91 proc_time_->sum += interval; |
71 proc_time_->max = std::max(proc_time_->max, interval); | 92 proc_time_->max = std::max(proc_time_->max, interval); |
72 proc_time_->min = std::min(proc_time_->min, interval); | 93 proc_time_->min = std::min(proc_time_->min, interval); |
73 } | 94 } |
74 | 95 |
75 void AudioProcessingSimulator::ProcessStream(bool fixed_interface) { | 96 void AudioProcessingSimulator::ProcessStream(bool fixed_interface) { |
76 if (fixed_interface) { | 97 if (fixed_interface) { |
77 { | 98 { |
78 const auto st = ScopedTimer(mutable_proc_time()); | 99 const auto st = ScopedTimer(mutable_proc_time()); |
79 RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->ProcessStream(&fwd_frame_)); | 100 RTC_CHECK_EQ(AudioProcessing::kNoError, ap_->ProcessStream(&fwd_frame_)); |
80 } | 101 } |
81 CopyFromAudioFrame(fwd_frame_, out_buf_.get()); | 102 CopyFromAudioFrame(fwd_frame_, out_buf_.get()); |
82 } else { | 103 } else { |
83 const auto st = ScopedTimer(mutable_proc_time()); | 104 const auto st = ScopedTimer(mutable_proc_time()); |
84 RTC_CHECK_EQ(AudioProcessing::kNoError, | 105 RTC_CHECK_EQ(AudioProcessing::kNoError, |
85 ap_->ProcessStream(in_buf_->channels(), in_config_, | 106 ap_->ProcessStream(in_buf_->channels(), in_config_, |
86 out_config_, out_buf_->channels())); | 107 out_config_, out_buf_->channels())); |
87 } | 108 } |
88 | 109 |
89 if (buffer_writer_) { | 110 if (buffer_writer_) { |
90 buffer_writer_->Write(*out_buf_); | 111 buffer_writer_->Write(*out_buf_); |
91 } | 112 } |
92 | 113 |
114 if (residual_echo_likelihood_graph_.is_open()) { | |
115 auto stats = ap_->GetStatistics(); | |
116 residual_echo_likelihood_graph_ << stats.residual_echo_likelihood << ", "; | |
117 } | |
118 | |
93 ++num_process_stream_calls_; | 119 ++num_process_stream_calls_; |
94 } | 120 } |
95 | 121 |
96 void AudioProcessingSimulator::ProcessReverseStream(bool fixed_interface) { | 122 void AudioProcessingSimulator::ProcessReverseStream(bool fixed_interface) { |
97 if (fixed_interface) { | 123 if (fixed_interface) { |
98 const auto st = ScopedTimer(mutable_proc_time()); | 124 const auto st = ScopedTimer(mutable_proc_time()); |
99 RTC_CHECK_EQ(AudioProcessing::kNoError, | 125 RTC_CHECK_EQ(AudioProcessing::kNoError, |
100 ap_->ProcessReverseStream(&rev_frame_)); | 126 ap_->ProcessReverseStream(&rev_frame_)); |
101 CopyFromAudioFrame(rev_frame_, reverse_out_buf_.get()); | 127 CopyFromAudioFrame(rev_frame_, reverse_out_buf_.get()); |
102 | 128 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 apm_config.level_controller.enabled = *settings_.use_lc; | 264 apm_config.level_controller.enabled = *settings_.use_lc; |
239 } | 265 } |
240 if (settings_.use_refined_adaptive_filter) { | 266 if (settings_.use_refined_adaptive_filter) { |
241 config.Set<RefinedAdaptiveFilter>( | 267 config.Set<RefinedAdaptiveFilter>( |
242 new RefinedAdaptiveFilter(*settings_.use_refined_adaptive_filter)); | 268 new RefinedAdaptiveFilter(*settings_.use_refined_adaptive_filter)); |
243 } | 269 } |
244 config.Set<ExtendedFilter>(new ExtendedFilter( | 270 config.Set<ExtendedFilter>(new ExtendedFilter( |
245 !settings_.use_extended_filter || *settings_.use_extended_filter)); | 271 !settings_.use_extended_filter || *settings_.use_extended_filter)); |
246 config.Set<DelayAgnostic>(new DelayAgnostic(!settings_.use_delay_agnostic || | 272 config.Set<DelayAgnostic>(new DelayAgnostic(!settings_.use_delay_agnostic || |
247 *settings_.use_delay_agnostic)); | 273 *settings_.use_delay_agnostic)); |
274 if (settings_.use_red) { | |
275 apm_config.residual_echo_detector.enabled = *settings_.use_red; | |
276 } | |
248 | 277 |
249 ap_.reset(AudioProcessing::Create(config)); | 278 ap_.reset(AudioProcessing::Create(config)); |
250 RTC_CHECK(ap_); | 279 RTC_CHECK(ap_); |
251 | 280 |
252 ap_->ApplyConfig(apm_config); | 281 ap_->ApplyConfig(apm_config); |
253 | 282 |
254 if (settings_.use_aec) { | 283 if (settings_.use_aec) { |
255 RTC_CHECK_EQ(AudioProcessing::kNoError, | 284 RTC_CHECK_EQ(AudioProcessing::kNoError, |
256 ap_->echo_cancellation()->Enable(*settings_.use_aec)); | 285 ap_->echo_cancellation()->Enable(*settings_.use_aec)); |
257 } | 286 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 size_t kMaxFilenameSize = AudioProcessing::kMaxFilenameSize; | 372 size_t kMaxFilenameSize = AudioProcessing::kMaxFilenameSize; |
344 RTC_CHECK_LE(settings_.aec_dump_output_filename->size(), kMaxFilenameSize); | 373 RTC_CHECK_LE(settings_.aec_dump_output_filename->size(), kMaxFilenameSize); |
345 RTC_CHECK_EQ(AudioProcessing::kNoError, | 374 RTC_CHECK_EQ(AudioProcessing::kNoError, |
346 ap_->StartDebugRecording( | 375 ap_->StartDebugRecording( |
347 settings_.aec_dump_output_filename->c_str(), -1)); | 376 settings_.aec_dump_output_filename->c_str(), -1)); |
348 } | 377 } |
349 } | 378 } |
350 | 379 |
351 } // namespace test | 380 } // namespace test |
352 } // namespace webrtc | 381 } // namespace webrtc |
OLD | NEW |