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 24 matching lines...) Expand all Loading... | |
35 } | 35 } |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 DEFINE_string(dump, "", "Name of the aecdump debug file to read from."); | 39 DEFINE_string(dump, "", "Name of the aecdump debug file to read from."); |
40 DEFINE_string(i, "", "Name of the capture input stream file to read from."); | 40 DEFINE_string(i, "", "Name of the capture input stream file to read from."); |
41 DEFINE_string( | 41 DEFINE_string( |
42 o, | 42 o, |
43 "out.wav", | 43 "out.wav", |
44 "Name of the output file to write the processed capture stream to."); | 44 "Name of the output file to write the processed capture stream to."); |
45 DEFINE_string(ri, "", "Name of the render input stream file to read from."); | |
46 DEFINE_string( | |
47 ro, | |
48 "out_reverse.wav", | |
49 "Name of the output file to write the processed render stream to."); | |
45 DEFINE_int32(out_channels, 1, "Number of output channels."); | 50 DEFINE_int32(out_channels, 1, "Number of output channels."); |
46 const bool out_channels_dummy = | 51 const bool out_channels_dummy = |
47 google::RegisterFlagValidator(&FLAGS_out_channels, &ValidateOutChannels); | 52 google::RegisterFlagValidator(&FLAGS_out_channels, &ValidateOutChannels); |
53 DEFINE_int32(rev_out_channels, 1, "Number of reverse output channels."); | |
54 const bool rev_out_channels_dummy = | |
55 google::RegisterFlagValidator(&FLAGS_rev_out_channels, | |
56 &ValidateOutChannels); | |
48 DEFINE_int32(out_sample_rate, 48000, "Output sample rate in Hz."); | 57 DEFINE_int32(out_sample_rate, 48000, "Output sample rate in Hz."); |
58 DEFINE_int32(rev_out_sample_rate, 48000, "Reverse output sample rate in Hz."); | |
49 DEFINE_string(mic_positions, "", | 59 DEFINE_string(mic_positions, "", |
50 "Space delimited cartesian coordinates of microphones in meters. " | 60 "Space delimited cartesian coordinates of microphones in meters. " |
51 "The coordinates of each point are contiguous. " | 61 "The coordinates of each point are contiguous. " |
52 "For a two element array: \"x1 y1 z1 x2 y2 z2\""); | 62 "For a two element array: \"x1 y1 z1 x2 y2 z2\""); |
53 DEFINE_double( | 63 DEFINE_double( |
54 target_angle_degrees, | 64 target_angle_degrees, |
55 90, | 65 90, |
56 "The azimuth of the target in degrees. Only applies to beamforming."); | 66 "The azimuth of the target in degrees. Only applies to beamforming."); |
57 | 67 |
58 DEFINE_bool(aec, false, "Enable echo cancellation."); | 68 DEFINE_bool(aec, false, "Enable echo cancellation."); |
(...skipping 11 matching lines...) Expand all Loading... | |
70 | 80 |
71 namespace webrtc { | 81 namespace webrtc { |
72 namespace { | 82 namespace { |
73 | 83 |
74 const int kChunksPerSecond = 100; | 84 const int kChunksPerSecond = 100; |
75 const char kUsage[] = | 85 const char kUsage[] = |
76 "Command-line tool to run audio processing on WAV files. Accepts either\n" | 86 "Command-line tool to run audio processing on WAV files. Accepts either\n" |
77 "an input capture WAV file or protobuf debug dump and writes to an output\n" | 87 "an input capture WAV file or protobuf debug dump and writes to an output\n" |
78 "WAV file.\n" | 88 "WAV file.\n" |
79 "\n" | 89 "\n" |
80 "All components are disabled by default. If any bi-directional components\n" | 90 "All components are disabled by default. If the AEC is enabled, only\n" |
peah-webrtc
2016/03/18 21:57:17
Actually, I'd rather you fully remove this line ab
aluebs-webrtc
2016/03/18 23:39:29
Agreed. Done.
| |
81 "are enabled, only debug dump files are permitted."; | 91 "debug dump files are permitted."; |
82 | 92 |
83 } // namespace | 93 } // namespace |
84 | 94 |
85 int main(int argc, char* argv[]) { | 95 int main(int argc, char* argv[]) { |
86 google::SetUsageMessage(kUsage); | 96 google::SetUsageMessage(kUsage); |
87 google::ParseCommandLineFlags(&argc, &argv, true); | 97 google::ParseCommandLineFlags(&argc, &argv, true); |
88 | 98 |
89 if (!((FLAGS_i.empty()) ^ (FLAGS_dump.empty()))) { | 99 if (!((FLAGS_i.empty()) ^ (FLAGS_dump.empty()))) { |
90 fprintf(stderr, | 100 fprintf(stderr, |
91 "An input file must be specified with either -i or -dump.\n"); | 101 "An input file must be specified with either -i or -dump.\n"); |
92 return 1; | 102 return 1; |
93 } | 103 } |
94 if (FLAGS_dump.empty() && (FLAGS_aec || FLAGS_ie)) { | 104 if (FLAGS_dump.empty() && FLAGS_aec) { |
peah-webrtc
2016/03/18 21:57:17
Please remove this statement. The statement is not
aluebs-webrtc
2016/03/18 23:39:29
Done. If by "not at all yet ready to operate prope
peah-webrtc
2016/03/19 01:00:16
There is afaics lots of things missing:
AEC:
set_s
aluebs-webrtc
2016/03/19 02:09:55
Thank you for doing that analysis. I agree we shou
| |
95 fprintf(stderr, "-aec and -ie require a -dump file.\n"); | 105 fprintf(stderr, "-aec requires a -dump file.\n"); |
96 return 1; | |
97 } | |
98 if (FLAGS_ie) { | |
99 fprintf(stderr, | |
100 "FIXME(ajm): The intelligibility enhancer output is not dumped.\n"); | |
101 return 1; | 106 return 1; |
102 } | 107 } |
103 | 108 |
104 test::TraceToStderr trace_to_stderr(true); | 109 test::TraceToStderr trace_to_stderr(true); |
105 Config config; | 110 Config config; |
106 if (FLAGS_bf || FLAGS_all) { | 111 if (FLAGS_bf || FLAGS_all) { |
107 if (FLAGS_mic_positions.empty()) { | 112 if (FLAGS_mic_positions.empty()) { |
108 fprintf(stderr, "-mic_positions must be specified when -bf is used.\n"); | 113 fprintf(stderr, "-mic_positions must be specified when -bf is used.\n"); |
109 return 1; | 114 return 1; |
110 } | 115 } |
(...skipping 17 matching lines...) Expand all Loading... | |
128 } | 133 } |
129 ap->set_stream_key_pressed(FLAGS_ts); | 134 ap->set_stream_key_pressed(FLAGS_ts); |
130 | 135 |
131 std::unique_ptr<AudioFileProcessor> processor; | 136 std::unique_ptr<AudioFileProcessor> processor; |
132 auto out_file = std::unique_ptr<WavWriter>(new WavWriter( | 137 auto out_file = std::unique_ptr<WavWriter>(new WavWriter( |
133 FLAGS_o, FLAGS_out_sample_rate, static_cast<size_t>(FLAGS_out_channels))); | 138 FLAGS_o, FLAGS_out_sample_rate, static_cast<size_t>(FLAGS_out_channels))); |
134 std::cout << FLAGS_o << ": " << out_file->FormatAsString() << std::endl; | 139 std::cout << FLAGS_o << ": " << out_file->FormatAsString() << std::endl; |
135 if (FLAGS_dump.empty()) { | 140 if (FLAGS_dump.empty()) { |
136 auto in_file = std::unique_ptr<WavReader>(new WavReader(FLAGS_i)); | 141 auto in_file = std::unique_ptr<WavReader>(new WavReader(FLAGS_i)); |
137 std::cout << FLAGS_i << ": " << in_file->FormatAsString() << std::endl; | 142 std::cout << FLAGS_i << ": " << in_file->FormatAsString() << std::endl; |
138 processor.reset(new WavFileProcessor(std::move(ap), std::move(in_file), | 143 std::unique_ptr<WavReader> reverse_in_file; |
139 std::move(out_file))); | 144 std::unique_ptr<WavWriter> reverse_out_file; |
145 if (!FLAGS_ri.empty()) { | |
146 reverse_in_file.reset(new WavReader(FLAGS_ri)); | |
147 reverse_out_file.reset(new WavWriter( | |
148 FLAGS_ro, | |
149 FLAGS_rev_out_sample_rate, | |
150 static_cast<size_t>(FLAGS_rev_out_channels))); | |
151 std::cout << FLAGS_ri << ": " | |
152 << reverse_in_file->FormatAsString() << std::endl; | |
153 std::cout << FLAGS_ro << ": " | |
154 << reverse_out_file->FormatAsString() << std::endl; | |
155 } | |
156 processor.reset(new WavFileProcessor(std::move(ap), | |
157 std::move(in_file), | |
158 std::move(out_file), | |
159 std::move(reverse_in_file), | |
160 std::move(reverse_out_file))); | |
140 | 161 |
141 } else { | 162 } else { |
142 processor.reset(new AecDumpFileProcessor( | 163 processor.reset(new AecDumpFileProcessor( |
143 std::move(ap), fopen(FLAGS_dump.c_str(), "rb"), std::move(out_file))); | 164 std::move(ap), fopen(FLAGS_dump.c_str(), "rb"), std::move(out_file))); |
144 } | 165 } |
145 | 166 |
146 int num_chunks = 0; | 167 int num_chunks = 0; |
147 while (processor->ProcessChunk()) { | 168 while (processor->ProcessChunk()) { |
148 trace_to_stderr.SetTimeSeconds(num_chunks * 1.f / kChunksPerSecond); | 169 trace_to_stderr.SetTimeSeconds(num_chunks * 1.f / kChunksPerSecond); |
149 ++num_chunks; | 170 ++num_chunks; |
(...skipping 11 matching lines...) Expand all Loading... | |
161 } | 182 } |
162 | 183 |
163 return 0; | 184 return 0; |
164 } | 185 } |
165 | 186 |
166 } // namespace webrtc | 187 } // namespace webrtc |
167 | 188 |
168 int main(int argc, char* argv[]) { | 189 int main(int argc, char* argv[]) { |
169 return webrtc::main(argc, argv); | 190 return webrtc::main(argc, argv); |
170 } | 191 } |
OLD | NEW |