blob: d0c813f151e827d7760334ccf0c8f420b318a5a9 [file] [log] [blame]
andrew@webrtc.org08df9b22014-12-16 20:57:15 +00001/*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
aluebsb0ad43b2015-11-20 00:11:53 -080011#include <iostream>
kwiberg62eaacf2016-02-17 06:39:05 -080012#include <memory>
peah60a189f2016-05-24 20:54:40 -070013
14#include <string.h>
andrew@webrtc.org08df9b22014-12-16 20:57:15 +000015
andrew@webrtc.org08df9b22014-12-16 20:57:15 +000016#include "webrtc/modules/audio_processing/include/audio_processing.h"
peah60a189f2016-05-24 20:54:40 -070017#include "webrtc/modules/audio_processing/test/aec_dump_based_simulator.h"
18#include "webrtc/modules/audio_processing/test/audio_processing_simulator.h"
19#include "webrtc/modules/audio_processing/test/wav_based_simulator.h"
oprypin6e09d872017-08-31 03:21:39 -070020#include "webrtc/rtc_base/flags.h"
andrew@webrtc.org08df9b22014-12-16 20:57:15 +000021
peah60a189f2016-05-24 20:54:40 -070022namespace webrtc {
23namespace test {
Peter Kasting69558702016-01-12 16:26:35 -080024namespace {
25
peah60a189f2016-05-24 20:54:40 -070026const int kParameterNotSpecifiedValue = -10000;
27
28const char kUsageDescription[] =
29 "Usage: audioproc_f [options] -i <input.wav>\n"
30 " or\n"
31 " audioproc_f [options] -dump_input <aec_dump>\n"
32 "\n\n"
33 "Command-line tool to simulate a call using the audio "
34 "processing module, either based on wav files or "
oprypin6e09d872017-08-31 03:21:39 -070035 "protobuf debug dump recordings.\n";
peah60a189f2016-05-24 20:54:40 -070036
37DEFINE_string(dump_input, "", "Aec dump input filename");
38DEFINE_string(dump_output, "", "Aec dump output filename");
39DEFINE_string(i, "", "Forward stream input wav filename");
40DEFINE_string(o, "", "Forward stream output wav filename");
41DEFINE_string(ri, "", "Reverse stream input wav filename");
42DEFINE_string(ro, "", "Reverse stream output wav filename");
peahdf80fd12016-12-09 02:43:40 -080043DEFINE_string(artificial_nearend, "", "Artificial nearend wav filename");
oprypin6e09d872017-08-31 03:21:39 -070044DEFINE_int(output_num_channels,
45 kParameterNotSpecifiedValue,
46 "Number of forward stream output channels");
47DEFINE_int(reverse_output_num_channels,
48 kParameterNotSpecifiedValue,
49 "Number of Reverse stream output channels");
50DEFINE_int(output_sample_rate_hz,
51 kParameterNotSpecifiedValue,
52 "Forward stream output sample rate in Hz");
53DEFINE_int(reverse_output_sample_rate_hz,
54 kParameterNotSpecifiedValue,
55 "Reverse stream output sample rate in Hz");
peah60a189f2016-05-24 20:54:40 -070056DEFINE_string(mic_positions,
57 "",
58 "Space delimited cartesian coordinates of microphones in "
59 "meters. The coordinates of each point are contiguous. For a "
60 "two element array: \"x1 y1 z1 x2 y2 z2\"");
oprypin6e09d872017-08-31 03:21:39 -070061DEFINE_int(target_angle_degrees,
62 90,
63 "The azimuth of the target in degrees (0-359). Only applies to "
64 "beamforming.");
peah60a189f2016-05-24 20:54:40 -070065DEFINE_bool(fixed_interface,
66 false,
67 "Use the fixed interface when operating on wav files");
oprypin6e09d872017-08-31 03:21:39 -070068DEFINE_int(aec,
69 kParameterNotSpecifiedValue,
70 "Activate (1) or deactivate(0) the echo canceller");
71DEFINE_int(aecm,
72 kParameterNotSpecifiedValue,
73 "Activate (1) or deactivate(0) the mobile echo controller");
74DEFINE_int(ed,
75 kParameterNotSpecifiedValue,
76 "Activate (1) or deactivate (0) the residual echo detector");
ivoc0bff12a2016-11-17 00:55:43 -080077DEFINE_string(ed_graph, "", "Output filename for graph of echo likelihood");
oprypin6e09d872017-08-31 03:21:39 -070078DEFINE_int(agc,
79 kParameterNotSpecifiedValue,
80 "Activate (1) or deactivate(0) the AGC");
81DEFINE_int(agc2,
82 kParameterNotSpecifiedValue,
83 "Activate (1) or deactivate(0) the AGC2");
84DEFINE_int(hpf,
85 kParameterNotSpecifiedValue,
86 "Activate (1) or deactivate(0) the high-pass filter");
87DEFINE_int(ns,
88 kParameterNotSpecifiedValue,
89 "Activate (1) or deactivate(0) the noise suppressor");
90DEFINE_int(ts,
91 kParameterNotSpecifiedValue,
92 "Activate (1) or deactivate(0) the transient suppressor");
93DEFINE_int(bf,
94 kParameterNotSpecifiedValue,
95 "Activate (1) or deactivate(0) the beamformer");
96DEFINE_int(ie,
97 kParameterNotSpecifiedValue,
98 "Activate (1) or deactivate(0) the intelligibility enhancer");
99DEFINE_int(vad,
100 kParameterNotSpecifiedValue,
101 "Activate (1) or deactivate(0) the voice activity detector");
102DEFINE_int(le,
103 kParameterNotSpecifiedValue,
104 "Activate (1) or deactivate(0) the level estimator");
peah60a189f2016-05-24 20:54:40 -0700105DEFINE_bool(all_default,
106 false,
107 "Activate all of the default components (will be overridden by any "
108 "other settings)");
oprypin6e09d872017-08-31 03:21:39 -0700109DEFINE_int(aec_suppression_level,
110 kParameterNotSpecifiedValue,
111 "Set the aec suppression level (0-2)");
112DEFINE_int(delay_agnostic,
113 kParameterNotSpecifiedValue,
114 "Activate (1) or deactivate(0) the AEC delay agnostic mode");
115DEFINE_int(extended_filter,
116 kParameterNotSpecifiedValue,
117 "Activate (1) or deactivate(0) the AEC extended filter mode");
118DEFINE_int(drift_compensation,
119 kParameterNotSpecifiedValue,
120 "Activate (1) or deactivate(0) the drift compensation");
121DEFINE_int(aec3,
122 kParameterNotSpecifiedValue,
123 "Activate (1) or deactivate(0) the experimental AEC mode AEC3");
124DEFINE_int(lc,
125 kParameterNotSpecifiedValue,
126 "Activate (1) or deactivate(0) the level control");
127DEFINE_int(experimental_agc,
128 kParameterNotSpecifiedValue,
129 "Activate (1) or deactivate(0) the experimental AGC");
130DEFINE_int(
peah60a189f2016-05-24 20:54:40 -0700131 refined_adaptive_filter,
132 kParameterNotSpecifiedValue,
133 "Activate (1) or deactivate(0) the refined adaptive filter functionality");
oprypin6e09d872017-08-31 03:21:39 -0700134DEFINE_int(aecm_routing_mode,
135 kParameterNotSpecifiedValue,
136 "Specify the AECM routing mode (0-4)");
137DEFINE_int(aecm_comfort_noise,
138 kParameterNotSpecifiedValue,
139 "Activate (1) or deactivate(0) the AECM comfort noise");
140DEFINE_int(agc_mode,
141 kParameterNotSpecifiedValue,
142 "Specify the AGC mode (0-2)");
143DEFINE_int(agc_target_level,
144 kParameterNotSpecifiedValue,
145 "Specify the AGC target level (0-31)");
146DEFINE_int(agc_limiter,
147 kParameterNotSpecifiedValue,
148 "Activate (1) or deactivate(0) the level estimator");
149DEFINE_int(agc_compression_gain,
150 kParameterNotSpecifiedValue,
151 "Specify the AGC compression gain (0-90)");
152DEFINE_int(vad_likelihood,
153 kParameterNotSpecifiedValue,
154 "Specify the VAD likelihood (0-3)");
155DEFINE_int(ns_level,
156 kParameterNotSpecifiedValue,
157 "Specify the NS level (0-3)");
158DEFINE_int(stream_delay,
159 kParameterNotSpecifiedValue,
160 "Specify the stream delay in ms to use");
161DEFINE_int(stream_drift_samples,
162 kParameterNotSpecifiedValue,
163 "Specify the number of stream drift samples to use");
peah60a189f2016-05-24 20:54:40 -0700164DEFINE_bool(performance_report, false, "Report the APM performance ");
165DEFINE_bool(verbose, false, "Produce verbose output");
166DEFINE_bool(bitexactness_report,
167 false,
168 "Report bitexactness for aec dump result reproduction");
169DEFINE_bool(discard_settings_in_aecdump,
170 false,
171 "Discard any config settings specified in the aec dump");
172DEFINE_bool(store_intermediate_output,
173 false,
174 "Creates new output files after each init");
peah5ad5de32016-12-09 03:18:22 -0800175DEFINE_string(custom_call_order_file, "", "Custom process API call order file");
oprypin6e09d872017-08-31 03:21:39 -0700176DEFINE_bool(help, false, "Print this message");
peah60a189f2016-05-24 20:54:40 -0700177
Alex Loiko890988c2017-08-31 10:25:48 +0200178void SetSettingIfSpecified(const std::string& value,
peah60a189f2016-05-24 20:54:40 -0700179 rtc::Optional<std::string>* parameter) {
180 if (value.compare("") != 0) {
181 *parameter = rtc::Optional<std::string>(value);
182 }
183}
184
185void SetSettingIfSpecified(int value, rtc::Optional<int>* parameter) {
186 if (value != kParameterNotSpecifiedValue) {
187 *parameter = rtc::Optional<int>(value);
188 }
189}
190
191void SetSettingIfFlagSet(int32_t flag, rtc::Optional<bool>* parameter) {
192 if (flag == 0) {
193 *parameter = rtc::Optional<bool>(false);
194 } else if (flag == 1) {
195 *parameter = rtc::Optional<bool>(true);
196 }
197}
198
199SimulationSettings CreateSettings() {
200 SimulationSettings settings;
oprypin6e09d872017-08-31 03:21:39 -0700201 if (FLAG_all_default) {
peah60a189f2016-05-24 20:54:40 -0700202 settings.use_le = rtc::Optional<bool>(true);
203 settings.use_vad = rtc::Optional<bool>(true);
204 settings.use_ie = rtc::Optional<bool>(false);
205 settings.use_bf = rtc::Optional<bool>(false);
206 settings.use_ts = rtc::Optional<bool>(true);
207 settings.use_ns = rtc::Optional<bool>(true);
208 settings.use_hpf = rtc::Optional<bool>(true);
209 settings.use_agc = rtc::Optional<bool>(true);
210 settings.use_aec = rtc::Optional<bool>(true);
211 settings.use_aecm = rtc::Optional<bool>(false);
ivoc0bff12a2016-11-17 00:55:43 -0800212 settings.use_ed = rtc::Optional<bool>(false);
peah60a189f2016-05-24 20:54:40 -0700213 }
oprypin6e09d872017-08-31 03:21:39 -0700214 SetSettingIfSpecified(FLAG_dump_input, &settings.aec_dump_input_filename);
215 SetSettingIfSpecified(FLAG_dump_output, &settings.aec_dump_output_filename);
216 SetSettingIfSpecified(FLAG_i, &settings.input_filename);
217 SetSettingIfSpecified(FLAG_o, &settings.output_filename);
218 SetSettingIfSpecified(FLAG_ri, &settings.reverse_input_filename);
219 SetSettingIfSpecified(FLAG_ro, &settings.reverse_output_filename);
220 SetSettingIfSpecified(FLAG_artificial_nearend,
peahdf80fd12016-12-09 02:43:40 -0800221 &settings.artificial_nearend_filename);
oprypin6e09d872017-08-31 03:21:39 -0700222 SetSettingIfSpecified(FLAG_output_num_channels,
peah60a189f2016-05-24 20:54:40 -0700223 &settings.output_num_channels);
oprypin6e09d872017-08-31 03:21:39 -0700224 SetSettingIfSpecified(FLAG_reverse_output_num_channels,
peah60a189f2016-05-24 20:54:40 -0700225 &settings.reverse_output_num_channels);
oprypin6e09d872017-08-31 03:21:39 -0700226 SetSettingIfSpecified(FLAG_output_sample_rate_hz,
peah60a189f2016-05-24 20:54:40 -0700227 &settings.output_sample_rate_hz);
oprypin6e09d872017-08-31 03:21:39 -0700228 SetSettingIfSpecified(FLAG_reverse_output_sample_rate_hz,
peah60a189f2016-05-24 20:54:40 -0700229 &settings.reverse_output_sample_rate_hz);
oprypin6e09d872017-08-31 03:21:39 -0700230 SetSettingIfSpecified(FLAG_mic_positions, &settings.microphone_positions);
231 settings.target_angle_degrees = FLAG_target_angle_degrees;
232 SetSettingIfFlagSet(FLAG_aec, &settings.use_aec);
233 SetSettingIfFlagSet(FLAG_aecm, &settings.use_aecm);
234 SetSettingIfFlagSet(FLAG_ed, &settings.use_ed);
235 SetSettingIfSpecified(FLAG_ed_graph, &settings.ed_graph_output_filename);
236 SetSettingIfFlagSet(FLAG_agc, &settings.use_agc);
237 SetSettingIfFlagSet(FLAG_agc2, &settings.use_agc2);
238 SetSettingIfFlagSet(FLAG_hpf, &settings.use_hpf);
239 SetSettingIfFlagSet(FLAG_ns, &settings.use_ns);
240 SetSettingIfFlagSet(FLAG_ts, &settings.use_ts);
241 SetSettingIfFlagSet(FLAG_bf, &settings.use_bf);
242 SetSettingIfFlagSet(FLAG_ie, &settings.use_ie);
243 SetSettingIfFlagSet(FLAG_vad, &settings.use_vad);
244 SetSettingIfFlagSet(FLAG_le, &settings.use_le);
245 SetSettingIfSpecified(FLAG_aec_suppression_level,
peah60a189f2016-05-24 20:54:40 -0700246 &settings.aec_suppression_level);
oprypin6e09d872017-08-31 03:21:39 -0700247 SetSettingIfFlagSet(FLAG_delay_agnostic, &settings.use_delay_agnostic);
248 SetSettingIfFlagSet(FLAG_extended_filter, &settings.use_extended_filter);
249 SetSettingIfFlagSet(FLAG_drift_compensation,
peah60a189f2016-05-24 20:54:40 -0700250 &settings.use_drift_compensation);
oprypin6e09d872017-08-31 03:21:39 -0700251 SetSettingIfFlagSet(FLAG_refined_adaptive_filter,
peah60a189f2016-05-24 20:54:40 -0700252 &settings.use_refined_adaptive_filter);
253
oprypin6e09d872017-08-31 03:21:39 -0700254 SetSettingIfFlagSet(FLAG_aec3, &settings.use_aec3);
255 SetSettingIfFlagSet(FLAG_lc, &settings.use_lc);
256 SetSettingIfFlagSet(FLAG_experimental_agc, &settings.use_experimental_agc);
257 SetSettingIfSpecified(FLAG_aecm_routing_mode, &settings.aecm_routing_mode);
258 SetSettingIfFlagSet(FLAG_aecm_comfort_noise,
peah60a189f2016-05-24 20:54:40 -0700259 &settings.use_aecm_comfort_noise);
oprypin6e09d872017-08-31 03:21:39 -0700260 SetSettingIfSpecified(FLAG_agc_mode, &settings.agc_mode);
261 SetSettingIfSpecified(FLAG_agc_target_level, &settings.agc_target_level);
262 SetSettingIfFlagSet(FLAG_agc_limiter, &settings.use_agc_limiter);
263 SetSettingIfSpecified(FLAG_agc_compression_gain,
peah60a189f2016-05-24 20:54:40 -0700264 &settings.agc_compression_gain);
oprypin6e09d872017-08-31 03:21:39 -0700265 SetSettingIfSpecified(FLAG_vad_likelihood, &settings.vad_likelihood);
266 SetSettingIfSpecified(FLAG_ns_level, &settings.ns_level);
267 SetSettingIfSpecified(FLAG_stream_delay, &settings.stream_delay);
268 SetSettingIfSpecified(FLAG_stream_drift_samples,
peah60a189f2016-05-24 20:54:40 -0700269 &settings.stream_drift_samples);
oprypin6e09d872017-08-31 03:21:39 -0700270 SetSettingIfSpecified(FLAG_custom_call_order_file,
peah5ad5de32016-12-09 03:18:22 -0800271 &settings.custom_call_order_filename);
oprypin6e09d872017-08-31 03:21:39 -0700272 settings.report_performance = FLAG_performance_report;
273 settings.use_verbose_logging = FLAG_verbose;
274 settings.report_bitexactness = FLAG_bitexactness_report;
275 settings.discard_all_settings_in_aecdump = FLAG_discard_settings_in_aecdump;
276 settings.fixed_interface = FLAG_fixed_interface;
277 settings.store_intermediate_output = FLAG_store_intermediate_output;
peah60a189f2016-05-24 20:54:40 -0700278
279 return settings;
280}
281
Alex Loiko890988c2017-08-31 10:25:48 +0200282void ReportConditionalErrorAndExit(bool condition, const std::string& message) {
peah60a189f2016-05-24 20:54:40 -0700283 if (condition) {
284 std::cerr << message << std::endl;
285 exit(1);
286 }
287}
288
289void PerformBasicParameterSanityChecks(const SimulationSettings& settings) {
290 if (settings.input_filename || settings.reverse_input_filename) {
291 ReportConditionalErrorAndExit(!!settings.aec_dump_input_filename,
292 "Error: The aec dump cannot be specified "
293 "together with input wav files!\n");
294
peahdf80fd12016-12-09 02:43:40 -0800295 ReportConditionalErrorAndExit(!!settings.artificial_nearend_filename,
296 "Error: The artificial nearend cannot be "
297 "specified together with input wav files!\n");
298
peah60a189f2016-05-24 20:54:40 -0700299 ReportConditionalErrorAndExit(!settings.input_filename,
300 "Error: When operating at wav files, the "
301 "input wav filename must be "
302 "specified!\n");
303
304 ReportConditionalErrorAndExit(
305 settings.reverse_output_filename && !settings.reverse_input_filename,
306 "Error: When operating at wav files, the reverse input wav filename "
307 "must be specified if the reverse output wav filename is specified!\n");
308 } else {
309 ReportConditionalErrorAndExit(!settings.aec_dump_input_filename,
310 "Error: Either the aec dump or the wav "
311 "input files must be specified!\n");
312 }
313
314 ReportConditionalErrorAndExit(
315 settings.use_aec && *settings.use_aec && settings.use_aecm &&
316 *settings.use_aecm,
317 "Error: The AEC and the AECM cannot be activated at the same time!\n");
318
319 ReportConditionalErrorAndExit(
320 settings.output_sample_rate_hz && *settings.output_sample_rate_hz <= 0,
321 "Error: --output_sample_rate_hz must be positive!\n");
322
323 ReportConditionalErrorAndExit(
324 settings.reverse_output_sample_rate_hz &&
325 settings.output_sample_rate_hz &&
326 *settings.output_sample_rate_hz <= 0,
327 "Error: --reverse_output_sample_rate_hz must be positive!\n");
328
329 ReportConditionalErrorAndExit(
330 settings.output_num_channels && *settings.output_num_channels <= 0,
331 "Error: --output_num_channels must be positive!\n");
332
333 ReportConditionalErrorAndExit(
334 settings.reverse_output_num_channels &&
335 *settings.reverse_output_num_channels <= 0,
336 "Error: --reverse_output_num_channels must be positive!\n");
337
338 ReportConditionalErrorAndExit(
339 settings.use_bf && *settings.use_bf && !settings.microphone_positions,
340 "Error: --mic_positions must be specified when the beamformer is "
341 "activated.\n");
342
343 ReportConditionalErrorAndExit(
344 settings.target_angle_degrees < 0 || settings.target_angle_degrees > 359,
345 "Error: -target_angle_degrees must be specified between 0 and 359.\n");
346
347 ReportConditionalErrorAndExit(
348 settings.aec_suppression_level &&
349 ((*settings.aec_suppression_level) < 0 ||
350 (*settings.aec_suppression_level) > 2),
351 "Error: --aec_suppression_level must be specified between 0 and 2.\n");
352
353 ReportConditionalErrorAndExit(
354 settings.aecm_routing_mode && ((*settings.aecm_routing_mode) < 0 ||
355 (*settings.aecm_routing_mode) > 4),
356 "Error: --aecm_routing_mode must be specified between 0 and 4.\n");
357
358 ReportConditionalErrorAndExit(
359 settings.agc_target_level && ((*settings.agc_target_level) < 0 ||
360 (*settings.agc_target_level) > 31),
361 "Error: --agc_target_level must be specified between 0 and 31.\n");
362
363 ReportConditionalErrorAndExit(
364 settings.agc_compression_gain && ((*settings.agc_compression_gain) < 0 ||
365 (*settings.agc_compression_gain) > 90),
366 "Error: --agc_compression_gain must be specified between 0 and 90.\n");
367
368 ReportConditionalErrorAndExit(
369 settings.vad_likelihood &&
370 ((*settings.vad_likelihood) < 0 || (*settings.vad_likelihood) > 3),
371 "Error: --vad_likelihood must be specified between 0 and 3.\n");
372
373 ReportConditionalErrorAndExit(
374 settings.ns_level &&
375 ((*settings.ns_level) < 0 || (*settings.ns_level) > 3),
376 "Error: --ns_level must be specified between 0 and 3.\n");
377
378 ReportConditionalErrorAndExit(
379 settings.report_bitexactness && !settings.aec_dump_input_filename,
380 "Error: --bitexactness_report can only be used when operating on an "
381 "aecdump\n");
382
peah5ad5de32016-12-09 03:18:22 -0800383 ReportConditionalErrorAndExit(
384 settings.custom_call_order_filename && settings.aec_dump_input_filename,
385 "Error: --custom_call_order_file cannot be used when operating on an "
386 "aecdump\n");
387
peah60a189f2016-05-24 20:54:40 -0700388 auto valid_wav_name = [](const std::string& wav_file_name) {
389 if (wav_file_name.size() < 5) {
390 return false;
391 }
392 if ((wav_file_name.compare(wav_file_name.size() - 4, 4, ".wav") == 0) ||
393 (wav_file_name.compare(wav_file_name.size() - 4, 4, ".WAV") == 0)) {
394 return true;
395 }
396 return false;
397 };
398
399 ReportConditionalErrorAndExit(
400 settings.input_filename && (!valid_wav_name(*settings.input_filename)),
401 "Error: --i must be a valid .wav file name.\n");
402
403 ReportConditionalErrorAndExit(
404 settings.output_filename && (!valid_wav_name(*settings.output_filename)),
405 "Error: --o must be a valid .wav file name.\n");
406
407 ReportConditionalErrorAndExit(
408 settings.reverse_input_filename &&
409 (!valid_wav_name(*settings.reverse_input_filename)),
410 "Error: --ri must be a valid .wav file name.\n");
411
412 ReportConditionalErrorAndExit(
413 settings.reverse_output_filename &&
414 (!valid_wav_name(*settings.reverse_output_filename)),
415 "Error: --ro must be a valid .wav file name.\n");
peahdf80fd12016-12-09 02:43:40 -0800416
417 ReportConditionalErrorAndExit(
418 settings.artificial_nearend_filename &&
419 !valid_wav_name(*settings.artificial_nearend_filename),
420 "Error: --artifical_nearend must be a valid .wav file name.\n");
Peter Kasting69558702016-01-12 16:26:35 -0800421}
422
423} // namespace
424
andrew@webrtc.org08df9b22014-12-16 20:57:15 +0000425int main(int argc, char* argv[]) {
oprypin6e09d872017-08-31 03:21:39 -0700426 if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
427 FLAG_help || argc != 1) {
428 printf("%s", kUsageDescription);
429 if (FLAG_help) {
430 rtc::FlagList::Print(nullptr, false);
431 return 0;
432 }
433 return 1;
434 }
andrew@webrtc.org08df9b22014-12-16 20:57:15 +0000435
peah60a189f2016-05-24 20:54:40 -0700436 SimulationSettings settings = CreateSettings();
437 PerformBasicParameterSanityChecks(settings);
438 std::unique_ptr<AudioProcessingSimulator> processor;
andrew@webrtc.org08df9b22014-12-16 20:57:15 +0000439
peah60a189f2016-05-24 20:54:40 -0700440 if (settings.aec_dump_input_filename) {
441 processor.reset(new AecDumpBasedSimulator(settings));
aluebsb0ad43b2015-11-20 00:11:53 -0800442 } else {
peah60a189f2016-05-24 20:54:40 -0700443 processor.reset(new WavBasedSimulator(settings));
andrewbdafe312015-10-29 23:42:54 -0700444 }
445
peah60a189f2016-05-24 20:54:40 -0700446 processor->Process();
aluebsb0ad43b2015-11-20 00:11:53 -0800447
peah60a189f2016-05-24 20:54:40 -0700448 if (settings.report_performance) {
aluebsb0ad43b2015-11-20 00:11:53 -0800449 const auto& proc_time = processor->proc_time();
Niels Möllerd28db7f2016-05-10 16:31:47 +0200450 int64_t exec_time_us = proc_time.sum / rtc::kNumNanosecsPerMicrosec;
peah60a189f2016-05-24 20:54:40 -0700451 std::cout << std::endl
452 << "Execution time: " << exec_time_us * 1e-6 << " s, File time: "
453 << processor->get_num_process_stream_calls() * 1.f /
454 AudioProcessingSimulator::kChunksPerSecond
455 << std::endl
456 << "Time per fwd stream chunk (mean, max, min): " << std::endl
457 << exec_time_us * 1.f / processor->get_num_process_stream_calls()
458 << " us, " << 1.f * proc_time.max / rtc::kNumNanosecsPerMicrosec
459 << " us, " << 1.f * proc_time.min / rtc::kNumNanosecsPerMicrosec
460 << " us" << std::endl;
461 }
462
463 if (settings.report_bitexactness && settings.aec_dump_input_filename) {
464 if (processor->OutputWasBitexact()) {
465 std::cout << "The processing was bitexact.";
466 } else {
467 std::cout << "The processing was not bitexact.";
468 }
Alejandro Luebs5d22c002015-04-15 11:26:40 -0700469 }
aluebsb0ad43b2015-11-20 00:11:53 -0800470
andrew@webrtc.org08df9b22014-12-16 20:57:15 +0000471 return 0;
472}
473
peah60a189f2016-05-24 20:54:40 -0700474} // namespace test
andrew@webrtc.org08df9b22014-12-16 20:57:15 +0000475} // namespace webrtc
476
477int main(int argc, char* argv[]) {
peah60a189f2016-05-24 20:54:40 -0700478 return webrtc::test::main(argc, argv);
andrew@webrtc.org08df9b22014-12-16 20:57:15 +0000479}