Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 RTC_CHECK_EQ(array_geometry.size(), num_mics); | 51 RTC_CHECK_EQ(array_geometry.size(), num_mics); |
| 52 | 52 |
| 53 NonlinearBeamformer bf(array_geometry); | 53 NonlinearBeamformer bf(array_geometry); |
| 54 bf.Initialize(kChunkSizeMs, in_file.sample_rate()); | 54 bf.Initialize(kChunkSizeMs, in_file.sample_rate()); |
| 55 | 55 |
| 56 printf("Input file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", | 56 printf("Input file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", |
| 57 FLAGS_i.c_str(), in_file.num_channels(), in_file.sample_rate()); | 57 FLAGS_i.c_str(), in_file.num_channels(), in_file.sample_rate()); |
| 58 printf("Output file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", | 58 printf("Output file: %s\nChannels: %" PRIuS ", Sample rate: %d Hz\n\n", |
| 59 FLAGS_o.c_str(), out_file.num_channels(), out_file.sample_rate()); | 59 FLAGS_o.c_str(), out_file.num_channels(), out_file.sample_rate()); |
| 60 | 60 |
| 61 ChannelBuffer<float> in_buf( | 61 ChannelBuffer<float> buf( |
| 62 rtc::CheckedDivExact(in_file.sample_rate(), kChunksPerSecond), | 62 rtc::CheckedDivExact(in_file.sample_rate(), kChunksPerSecond), |
| 63 in_file.num_channels()); | 63 in_file.num_channels()); |
| 64 ChannelBuffer<float> out_buf( | |
| 65 rtc::CheckedDivExact(out_file.sample_rate(), kChunksPerSecond), | |
| 66 out_file.num_channels()); | |
| 67 | 64 |
| 68 std::vector<float> interleaved(in_buf.size()); | 65 std::vector<float> interleaved(buf.size()); |
| 69 while (in_file.ReadSamples(interleaved.size(), | 66 while (in_file.ReadSamples(interleaved.size(), |
| 70 &interleaved[0]) == interleaved.size()) { | 67 &interleaved[0]) == interleaved.size()) { |
| 68 buf.set_num_channels(in_file.num_channels()); | |
| 71 FloatS16ToFloat(&interleaved[0], interleaved.size(), &interleaved[0]); | 69 FloatS16ToFloat(&interleaved[0], interleaved.size(), &interleaved[0]); |
| 72 Deinterleave(&interleaved[0], in_buf.num_frames(), | 70 Deinterleave(&interleaved[0], buf.num_frames(), |
| 73 in_buf.num_channels(), in_buf.channels()); | 71 buf.num_channels(), buf.channels()); |
| 74 | 72 |
| 75 bf.ProcessChunk(in_buf, &out_buf); | 73 bf.AnalyzeChunk(buf); |
| 74 bf.PostFilter(&buf); | |
|
peah-webrtc
2016/06/08 12:04:55
Does this really work? The AnalyzeChunk does not d
aluebs-webrtc
2016/06/09 02:11:46
It did, because it doesn't use the number of chann
| |
| 76 | 75 |
| 77 Interleave(out_buf.channels(), out_buf.num_frames(), | 76 Interleave(buf.channels(), buf.num_frames(), |
| 78 out_buf.num_channels(), &interleaved[0]); | 77 buf.num_channels(), &interleaved[0]); |
| 79 FloatToFloatS16(&interleaved[0], interleaved.size(), &interleaved[0]); | 78 FloatToFloatS16(buf.channels()[0], buf.num_frames(), &interleaved[0]); |
| 80 out_file.WriteSamples(&interleaved[0], interleaved.size()); | 79 out_file.WriteSamples(&interleaved[0], buf.num_frames()); |
| 81 } | 80 } |
| 82 | 81 |
| 83 return 0; | 82 return 0; |
| 84 } | 83 } |
| 85 | 84 |
| 86 } // namespace webrtc | 85 } // namespace webrtc |
| 87 | 86 |
| 88 int main(int argc, char* argv[]) { | 87 int main(int argc, char* argv[]) { |
| 89 return webrtc::main(argc, argv); | 88 return webrtc::main(argc, argv); |
| 90 } | 89 } |
| OLD | NEW |