OLD | NEW |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 StreamConfig stream_config(noise_file.sample_rate(), |
56 noise_file.num_channels()); | 56 noise_file.num_channels()); |
57 while (in_file.ReadSamples(in.size(), in.data()) == in.size() && | 57 while (in_file.ReadSamples(in.size(), in.data()) == in.size() && |
58 noise_file.ReadSamples(noise.size(), noise.data()) == noise.size()) { | 58 noise_file.ReadSamples(noise.size(), noise.data()) == noise.size()) { |
| 59 FloatS16ToFloat(in.data(), in.size(), in.data()); |
59 FloatS16ToFloat(noise.data(), noise.size(), noise.data()); | 60 FloatS16ToFloat(noise.data(), noise.size(), noise.data()); |
60 Deinterleave(in.data(), in_buf.num_frames(), in_buf.num_channels(), | 61 Deinterleave(in.data(), in_buf.num_frames(), in_buf.num_channels(), |
61 in_buf.channels()); | 62 in_buf.channels()); |
62 Deinterleave(noise.data(), noise_buf.num_frames(), noise_buf.num_channels(), | 63 Deinterleave(noise.data(), noise_buf.num_frames(), noise_buf.num_channels(), |
63 noise_buf.channels()); | 64 noise_buf.channels()); |
64 capture_audio.CopyFrom(noise_buf.channels(), stream_config); | 65 capture_audio.CopyFrom(noise_buf.channels(), stream_config); |
65 ns.AnalyzeCaptureAudio(&capture_audio); | 66 ns.AnalyzeCaptureAudio(&capture_audio); |
66 ns.ProcessCaptureAudio(&capture_audio); | 67 ns.ProcessCaptureAudio(&capture_audio); |
67 enh.SetCaptureNoiseEstimate(ns.NoiseEstimate()); | 68 enh.SetCaptureNoiseEstimate(ns.NoiseEstimate()); |
68 enh.ProcessRenderAudio(in_buf.channels(), in_file.sample_rate(), | 69 enh.ProcessRenderAudio(in_buf.channels(), in_file.sample_rate(), |
69 in_file.num_channels()); | 70 in_file.num_channels()); |
70 Interleave(in_buf.channels(), in_buf.num_frames(), in_buf.num_channels(), | 71 Interleave(in_buf.channels(), in_buf.num_frames(), in_buf.num_channels(), |
71 in.data()); | 72 in.data()); |
| 73 FloatToFloatS16(in.data(), in.size(), in.data()); |
72 out_file.WriteSamples(in.data(), in.size()); | 74 out_file.WriteSamples(in.data(), in.size()); |
73 } | 75 } |
74 } | 76 } |
75 | 77 |
76 } // namespace | 78 } // namespace |
77 } // namespace webrtc | 79 } // namespace webrtc |
78 | 80 |
79 int main(int argc, char* argv[]) { | 81 int main(int argc, char* argv[]) { |
80 webrtc::void_main(argc, argv); | 82 webrtc::void_main(argc, argv); |
81 return 0; | 83 return 0; |
82 } | 84 } |
OLD | NEW |