"when -ir or -i is used, the specified files will be processed directly in\n"
"a simulation mode. Otherwise the full set of legacy test files is expected\n"
"to be present in the working directory. OUT_FILE should be specified\n"
- "without extension to support both int and float output.\n\n");
+ "without extension to support both raw and wav output.\n\n");
printf("Options\n");
printf("General configuration (only used for the simulation mode):\n");
printf(" -fs SAMPLE_RATE_HZ\n");
printf(" --no_delay_logging\n");
printf(" --aec_suppression_level LEVEL [0 - 2]\n");
printf(" --extended_filter\n");
+ printf(" --no_reported_delay\n");
printf("\n -aecm Echo control mobile\n");
printf(" --aecm_echo_path_in_file FILE\n");
printf(" --aecm_echo_path_out_file FILE\n");
printf(" --perf Measure performance.\n");
printf(" --quiet Suppress text output.\n");
printf(" --no_progress Suppress progress.\n");
+ printf(" --raw_output Raw output instead of WAV file.\n");
printf(" --debug_file FILE Dump a debug recording.\n");
}
bool perf_testing = false;
bool verbose = true;
bool progress = true;
+ bool raw_output = false;
int extra_delay_ms = 0;
int override_delay_ms = 0;
config.Set<DelayCorrection>(new DelayCorrection(true));
apm->SetExtraOptions(config);
+ } else if (strcmp(argv[i], "--no_reported_delay") == 0) {
+ Config config;
+ config.Set<ReportedDelay>(new ReportedDelay(false));
+ apm->SetExtraOptions(config);
+
} else if (strcmp(argv[i], "-aecm") == 0) {
ASSERT_EQ(apm->kNoError, apm->echo_control_mobile()->Enable(true));
vad_out_filename = argv[i];
} else if (strcmp(argv[i], "-expns") == 0) {
- ASSERT_EQ(apm->kNoError, apm->EnableExperimentalNs(true));
+ Config config;
+ config.Set<ExperimentalNs>(new ExperimentalNs(true));
+ apm->SetExtraOptions(config);
} else if (strcmp(argv[i], "--noasm") == 0) {
WebRtc_GetCPUInfo = WebRtc_GetCPUInfoNoASM;
} else if (strcmp(argv[i], "--no_progress") == 0) {
progress = false;
+ } else if (strcmp(argv[i], "--raw_output") == 0) {
+ raw_output = true;
+
} else if (strcmp(argv[i], "--debug_file") == 0) {
i++;
ASSERT_LT(i, argc) << "Specify filename after --debug_file";
if (out_filename.size() == 0) {
out_filename = out_path + "out";
}
- std::string out_float_filename = out_filename + ".float";
- out_filename += ".pcm";
if (!vad_out_filename) {
vad_out_filename = vad_file_default.c_str();
FILE* aecm_echo_path_in_file = NULL;
FILE* aecm_echo_path_out_file = NULL;
+ scoped_ptr<WavWriter> output_wav_file;
+ scoped_ptr<RawFile> output_raw_file;
+
if (pb_filename) {
pb_file = OpenFile(pb_filename, "rb");
} else {
samples_per_channel = msg.sample_rate() / 100;
far_frame.sample_rate_hz_ = msg.sample_rate();
- far_frame.samples_per_channel_ = samples_per_channel;
+ far_frame.samples_per_channel_ = reverse_sample_rate / 100;
far_frame.num_channels_ = msg.num_reverse_channels();
near_frame.sample_rate_hz_ = msg.sample_rate();
near_frame.samples_per_channel_ = samples_per_channel;
near_frame.num_channels_ = msg.num_input_channels();
- reverse_cb.reset(new ChannelBuffer<float>(samples_per_channel,
- msg.num_reverse_channels()));
+ reverse_cb.reset(new ChannelBuffer<float>(
+ far_frame.samples_per_channel_,
+ msg.num_reverse_channels()));
primary_cb.reset(new ChannelBuffer<float>(samples_per_channel,
msg.num_input_channels()));
printf(" Reverse channels: %d\n", msg.num_reverse_channels());
}
+ if (!raw_output) {
+ // The WAV file needs to be reset every time, because it cant change
+ // it's sample rate or number of channels.
+ output_wav_file.reset(new WavWriter(out_filename + ".wav",
+ output_sample_rate,
+ msg.num_output_channels()));
+ }
+
} else if (event_msg.type() == Event::REVERSE_STREAM) {
ASSERT_TRUE(event_msg.has_reverse_stream());
ReverseStream msg = event_msg.reverse_stream();
ASSERT_TRUE(msg.has_data() ^ (msg.channel_size() > 0));
if (msg.has_data()) {
- ASSERT_EQ(sizeof(int16_t) * samples_per_channel *
+ ASSERT_EQ(sizeof(int16_t) * far_frame.samples_per_channel_ *
far_frame.num_channels_, msg.data().size());
memcpy(far_frame.data_, msg.data().data(), msg.data().size());
} else {
memcpy(near_frame.data_,
msg.input_data().data(),
msg.input_data().size());
+ near_read_bytes += msg.input_data().size();
} else {
for (int i = 0; i < msg.input_channel_size(); ++i) {
primary_cb->CopyFrom(msg.input_channel(i).data(), i);
+ near_read_bytes += msg.input_channel(i).size();
}
}
- near_read_bytes += msg.input_data().size();
if (progress && primary_count % 100 == 0) {
+ near_read_bytes = std::min(near_read_bytes, near_size_bytes);
printf("%.0f%% complete\r",
(near_read_bytes * 100.0) / near_size_bytes);
fflush(stdout);
}
}
- size_t num_samples = samples_per_channel * apm->num_output_channels();
+ const size_t samples_per_channel = output_sample_rate / 100;
if (msg.has_input_data()) {
- static FILE* out_file = OpenFile(out_filename, "wb");
- ASSERT_EQ(num_samples, fwrite(near_frame.data_,
- sizeof(*near_frame.data_),
- num_samples,
- out_file));
+ if (raw_output && !output_raw_file) {
+ output_raw_file.reset(new RawFile(out_filename + ".pcm"));
+ }
+ WriteIntData(near_frame.data_,
+ apm->num_output_channels() * samples_per_channel,
+ output_wav_file.get(),
+ output_raw_file.get());
} else {
- static FILE* out_float_file = OpenFile(out_float_filename, "wb");
- ASSERT_EQ(num_samples, fwrite(primary_cb->data(),
- sizeof(*primary_cb->data()),
- num_samples,
- out_float_file));
+ if (raw_output && !output_raw_file) {
+ output_raw_file.reset(new RawFile(out_filename + ".float"));
+ }
+ WriteFloatData(primary_cb->channels(),
+ samples_per_channel,
+ apm->num_output_channels(),
+ output_wav_file.get(),
+ output_raw_file.get());
}
}
}
near_frame.sample_rate_hz_ = sample_rate_hz;
near_frame.samples_per_channel_ = samples_per_channel;
+ if (!raw_output) {
+ // The WAV file needs to be reset every time, because it can't change
+ // it's sample rate or number of channels.
+ output_wav_file.reset(new WavWriter(out_filename + ".wav",
+ sample_rate_hz,
+ num_capture_output_channels));
+ }
+
if (verbose) {
printf("Init at frame: %d (primary), %d (reverse)\n",
primary_count, reverse_count);
}
}
- size = samples_per_channel * near_frame.num_channels_;
- static FILE* out_file = OpenFile(out_filename, "wb");
- ASSERT_EQ(size, fwrite(near_frame.data_,
- sizeof(int16_t),
- size,
- out_file));
+ if (raw_output && !output_raw_file) {
+ output_raw_file.reset(new RawFile(out_filename + ".pcm"));
+ }
+ if (!raw_output && !output_wav_file) {
+ output_wav_file.reset(new WavWriter(out_filename + ".wav",
+ sample_rate_hz,
+ num_capture_output_channels));
+ }
+ WriteIntData(near_frame.data_,
+ size,
+ output_wav_file.get(),
+ output_raw_file.get());
}
else {
FAIL() << "Event " << event << " is unrecognized";