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

Side by Side Diff: webrtc/modules/audio_processing/intelligibility/test/intelligibility_proc.cc

Issue 2320833002: Compensate for the IntelligibilityEnhancer processing delay in high bands (Closed)
Patch Set: Rebasing Created 4 years, 3 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 21 matching lines...) Expand all
32 google::SetUsageMessage( 32 google::SetUsageMessage(
33 "\n\nInput files must be little-endian 16-bit signed raw PCM.\n"); 33 "\n\nInput files must be little-endian 16-bit signed raw PCM.\n");
34 google::ParseCommandLineFlags(&argc, &argv, true); 34 google::ParseCommandLineFlags(&argc, &argv, true);
35 35
36 WavReader in_file(FLAGS_clear_file); 36 WavReader in_file(FLAGS_clear_file);
37 WavReader noise_file(FLAGS_noise_file); 37 WavReader noise_file(FLAGS_noise_file);
38 WavWriter out_file(FLAGS_out_file, in_file.sample_rate(), 38 WavWriter out_file(FLAGS_out_file, in_file.sample_rate(),
39 in_file.num_channels()); 39 in_file.num_channels());
40 rtc::CriticalSection crit; 40 rtc::CriticalSection crit;
41 NoiseSuppressionImpl ns(&crit); 41 NoiseSuppressionImpl ns(&crit);
42 IntelligibilityEnhancer enh(in_file.sample_rate(), in_file.num_channels(), 42 IntelligibilityEnhancer enh(in_file.sample_rate(), in_file.num_channels(), 1u,
43 NoiseSuppressionImpl::num_noise_bins()); 43 NoiseSuppressionImpl::num_noise_bins());
44 ns.Initialize(noise_file.num_channels(), noise_file.sample_rate()); 44 ns.Initialize(noise_file.num_channels(), noise_file.sample_rate());
45 ns.Enable(true); 45 ns.Enable(true);
46 const size_t in_samples = noise_file.sample_rate() / 100; 46 const size_t in_samples = noise_file.sample_rate() / 100;
47 const size_t noise_samples = noise_file.sample_rate() / 100; 47 const size_t noise_samples = noise_file.sample_rate() / 100;
48 std::vector<float> in(in_samples * in_file.num_channels()); 48 std::vector<float> in(in_samples * in_file.num_channels());
49 std::vector<float> noise(noise_samples * noise_file.num_channels()); 49 std::vector<float> noise(noise_samples * noise_file.num_channels());
50 ChannelBuffer<float> in_buf(in_samples, in_file.num_channels()); 50 ChannelBuffer<float> in_buf(in_samples, in_file.num_channels());
51 ChannelBuffer<float> noise_buf(noise_samples, noise_file.num_channels()); 51 ChannelBuffer<float> noise_buf(noise_samples, noise_file.num_channels());
52 AudioBuffer capture_audio(noise_samples, noise_file.num_channels(), 52 AudioBuffer capture_audio(noise_samples, noise_file.num_channels(),
53 noise_samples, noise_file.num_channels(), 53 noise_samples, noise_file.num_channels(),
54 noise_samples); 54 noise_samples);
55 StreamConfig stream_config(noise_file.sample_rate(), 55 AudioBuffer render_audio(in_samples, in_file.num_channels(), in_samples,
56 noise_file.num_channels()); 56 in_file.num_channels(), in_samples);
57 StreamConfig noise_config(noise_file.sample_rate(),
58 noise_file.num_channels());
59 StreamConfig in_config(in_file.sample_rate(), in_file.num_channels());
57 while (in_file.ReadSamples(in.size(), in.data()) == in.size() && 60 while (in_file.ReadSamples(in.size(), in.data()) == in.size() &&
58 noise_file.ReadSamples(noise.size(), noise.data()) == noise.size()) { 61 noise_file.ReadSamples(noise.size(), noise.data()) == noise.size()) {
59 FloatS16ToFloat(noise.data(), noise.size(), noise.data()); 62 FloatS16ToFloat(noise.data(), noise.size(), noise.data());
63 FloatS16ToFloat(in.data(), in.size(), in.data());
60 Deinterleave(in.data(), in_buf.num_frames(), in_buf.num_channels(), 64 Deinterleave(in.data(), in_buf.num_frames(), in_buf.num_channels(),
61 in_buf.channels()); 65 in_buf.channels());
62 Deinterleave(noise.data(), noise_buf.num_frames(), noise_buf.num_channels(), 66 Deinterleave(noise.data(), noise_buf.num_frames(), noise_buf.num_channels(),
63 noise_buf.channels()); 67 noise_buf.channels());
64 capture_audio.CopyFrom(noise_buf.channels(), stream_config); 68 capture_audio.CopyFrom(noise_buf.channels(), noise_config);
69 render_audio.CopyFrom(in_buf.channels(), in_config);
65 ns.AnalyzeCaptureAudio(&capture_audio); 70 ns.AnalyzeCaptureAudio(&capture_audio);
66 ns.ProcessCaptureAudio(&capture_audio); 71 ns.ProcessCaptureAudio(&capture_audio);
67 enh.SetCaptureNoiseEstimate(ns.NoiseEstimate(), 0); 72 enh.SetCaptureNoiseEstimate(ns.NoiseEstimate(), 1);
68 enh.ProcessRenderAudio(in_buf.channels(), in_file.sample_rate(), 73 enh.ProcessRenderAudio(&render_audio);
69 in_file.num_channels()); 74 render_audio.CopyTo(in_config, in_buf.channels());
70 Interleave(in_buf.channels(), in_buf.num_frames(), in_buf.num_channels(), 75 Interleave(in_buf.channels(), in_buf.num_frames(), in_buf.num_channels(),
71 in.data()); 76 in.data());
77 FloatToFloatS16(in.data(), in.size(), in.data());
72 out_file.WriteSamples(in.data(), in.size()); 78 out_file.WriteSamples(in.data(), in.size());
73 } 79 }
74 } 80 }
75 81
76 } // namespace 82 } // namespace
77 } // namespace webrtc 83 } // namespace webrtc
78 84
79 int main(int argc, char* argv[]) { 85 int main(int argc, char* argv[]) {
80 webrtc::void_main(argc, argv); 86 webrtc::void_main(argc, argv);
81 return 0; 87 return 0;
82 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698