| 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 25 matching lines...) Expand all Loading... |
| 36 "in as a single band, unlike the audio processing interface which splits\n" | 36 "in as a single band, unlike the audio processing interface which splits\n" |
| 37 "signals into multiple bands."; | 37 "signals into multiple bands."; |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 int main(int argc, char* argv[]) { | 41 int main(int argc, char* argv[]) { |
| 42 google::SetUsageMessage(kUsage); | 42 google::SetUsageMessage(kUsage); |
| 43 google::ParseCommandLineFlags(&argc, &argv, true); | 43 google::ParseCommandLineFlags(&argc, &argv, true); |
| 44 | 44 |
| 45 WavReader in_file(FLAGS_i); | 45 WavReader in_file(FLAGS_i); |
| 46 WavWriter out_file(FLAGS_o, in_file.sample_rate(), 1); | 46 WavWriter out_file(FLAGS_o, in_file.sample_rate(), in_file.num_channels()); |
| 47 | 47 |
| 48 const size_t num_mics = in_file.num_channels(); | 48 const size_t num_mics = in_file.num_channels(); |
| 49 const std::vector<Point> array_geometry = | 49 const std::vector<Point> array_geometry = |
| 50 ParseArrayGeometry(FLAGS_mic_positions, num_mics); | 50 ParseArrayGeometry(FLAGS_mic_positions, num_mics); |
| 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, array_geometry.size()); |
| 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()) { |
| 71 FloatS16ToFloat(&interleaved[0], interleaved.size(), &interleaved[0]); | 68 FloatS16ToFloat(&interleaved[0], interleaved.size(), &interleaved[0]); |
| 72 Deinterleave(&interleaved[0], in_buf.num_frames(), | 69 Deinterleave(&interleaved[0], buf.num_frames(), |
| 73 in_buf.num_channels(), in_buf.channels()); | 70 buf.num_channels(), buf.channels()); |
| 74 | 71 |
| 75 bf.ProcessChunk(in_buf, &out_buf); | 72 bf.AnalyzeChunk(buf); |
| 73 bf.PostFilter(&buf); |
| 76 | 74 |
| 77 Interleave(out_buf.channels(), out_buf.num_frames(), | 75 Interleave(buf.channels(), buf.num_frames(), |
| 78 out_buf.num_channels(), &interleaved[0]); | 76 buf.num_channels(), &interleaved[0]); |
| 79 FloatToFloatS16(&interleaved[0], interleaved.size(), &interleaved[0]); | 77 FloatToFloatS16(&interleaved[0], interleaved.size(), &interleaved[0]); |
| 80 out_file.WriteSamples(&interleaved[0], interleaved.size()); | 78 out_file.WriteSamples(&interleaved[0], interleaved.size()); |
| 81 } | 79 } |
| 82 | 80 |
| 83 return 0; | 81 return 0; |
| 84 } | 82 } |
| 85 | 83 |
| 86 } // namespace webrtc | 84 } // namespace webrtc |
| 87 | 85 |
| 88 int main(int argc, char* argv[]) { | 86 int main(int argc, char* argv[]) { |
| 89 return webrtc::main(argc, argv); | 87 return webrtc::main(argc, argv); |
| 90 } | 88 } |
| OLD | NEW |