Chromium Code Reviews| Index: webrtc/modules/audio_processing/intelligibility/test/intelligibility_proc.cc |
| diff --git a/webrtc/modules/audio_processing/intelligibility/test/intelligibility_proc.cc b/webrtc/modules/audio_processing/intelligibility/test/intelligibility_proc.cc |
| index f949046b1d34dc6ab50c5f23ad95483058d27fb5..ed903514d414bc01c5b7e5b4e482163bf677010e 100644 |
| --- a/webrtc/modules/audio_processing/intelligibility/test/intelligibility_proc.cc |
| +++ b/webrtc/modules/audio_processing/intelligibility/test/intelligibility_proc.cc |
| @@ -40,15 +40,6 @@ using std::complex; |
| namespace webrtc { |
| namespace { |
| -DEFINE_double(clear_alpha, 0.9, "Power decay factor for clear data."); |
| -DEFINE_int32(sample_rate, |
| - 16000, |
| - "Audio sample rate used in the input and output files."); |
| -DEFINE_int32(ana_rate, |
| - 60, |
| - "Analysis rate; gains recalculated every N blocks."); |
| -DEFINE_double(gain_limit, 1000.0, "Maximum gain change in one block."); |
| - |
| DEFINE_string(clear_file, "speech.wav", "Input file with clear speech."); |
| DEFINE_string(noise_file, "noise.wav", "Input file with noise data."); |
| DEFINE_string(out_file, |
| @@ -56,31 +47,20 @@ DEFINE_string(out_file, |
| "Enhanced output. Use '-' to " |
| "play through aplay immediately."); |
| -const size_t kNumChannels = 1; |
| - |
| // void function for gtest |
| void void_main(int argc, char* argv[]) { |
| google::SetUsageMessage( |
| "\n\nInput files must be little-endian 16-bit signed raw PCM.\n"); |
| google::ParseCommandLineFlags(&argc, &argv, true); |
| - size_t samples; // Number of samples in input PCM file |
| - size_t fragment_size; // Number of samples to process at a time |
| - // to simulate APM stream processing |
| - |
| // Load settings and wav input. |
| - |
| - fragment_size = FLAGS_sample_rate / 100; // Mirror real time APM chunk size. |
| - // Duplicates chunk_length_ in |
| - // IntelligibilityEnhancer. |
| - |
| struct stat in_stat, noise_stat; |
| ASSERT_EQ(stat(FLAGS_clear_file.c_str(), &in_stat), 0) |
| << "Empty speech file."; |
| ASSERT_EQ(stat(FLAGS_noise_file.c_str(), &noise_stat), 0) |
| << "Empty noise file."; |
| - samples = std::min(in_stat.st_size, noise_stat.st_size) / 2; |
| + size_t samples = std::min(in_stat.st_size, noise_stat.st_size) / 2; |
|
hlundin-webrtc
2016/02/15 13:05:12
const?
aluebs-webrtc
2016/02/19 03:56:31
Done.
|
| WavReader in_file(FLAGS_clear_file); |
| std::vector<float> in_fpcm(samples); |
| @@ -93,23 +73,21 @@ void void_main(int argc, char* argv[]) { |
| FloatS16ToFloat(&noise_fpcm[0], samples, &noise_fpcm[0]); |
| // Run intelligibility enhancement. |
| - IntelligibilityEnhancer::Config config; |
| - config.sample_rate_hz = FLAGS_sample_rate; |
| - config.decay_rate = static_cast<float>(FLAGS_clear_alpha); |
| - config.analysis_rate = FLAGS_ana_rate; |
| - config.gain_change_limit = FLAGS_gain_limit; |
| - IntelligibilityEnhancer enh(config); |
| + IntelligibilityEnhancer enh(in_file.sample_rate(), in_file.num_channels()); |
| rtc::CriticalSection crit; |
| NoiseSuppressionImpl ns(&crit); |
| - ns.Initialize(kNumChannels, FLAGS_sample_rate); |
| + ns.Initialize(noise_file.num_channels(), noise_file.sample_rate()); |
| ns.Enable(true); |
| + // Mirror real time APM chunk size. Duplicates chunk_length_ in |
| + // IntelligibilityEnhancer. |
| + size_t fragment_size = in_file.sample_rate() / 100; |
| AudioBuffer capture_audio(fragment_size, |
| - kNumChannels, |
| + noise_file.num_channels(), |
| fragment_size, |
| - kNumChannels, |
| + noise_file.num_channels(), |
| fragment_size); |
| - StreamConfig stream_config(FLAGS_sample_rate, kNumChannels); |
| + StreamConfig stream_config(in_file.sample_rate(), noise_file.num_channels()); |
| // Slice the input into smaller chunks, as the APM would do, and feed them |
| // through the enhancer. |
| @@ -121,7 +99,9 @@ void void_main(int argc, char* argv[]) { |
| ns.AnalyzeCaptureAudio(&capture_audio); |
| ns.ProcessCaptureAudio(&capture_audio); |
| enh.SetCaptureNoiseEstimate(ns.NoiseEstimate()); |
| - enh.ProcessRenderAudio(&clear_cursor, FLAGS_sample_rate, kNumChannels); |
| + enh.ProcessRenderAudio(&clear_cursor, |
| + in_file.sample_rate(), |
| + in_file.num_channels()); |
| clear_cursor += fragment_size; |
| noise_cursor += fragment_size; |
| } |
| @@ -132,13 +112,17 @@ void void_main(int argc, char* argv[]) { |
| const std::string temp_out_filename = |
| test::TempFilename(test::WorkingDir(), "temp_wav_file"); |
| { |
| - WavWriter out_file(temp_out_filename, FLAGS_sample_rate, kNumChannels); |
| + WavWriter out_file(temp_out_filename, |
| + in_file.sample_rate(), |
| + in_file.num_channels()); |
| out_file.WriteSamples(&in_fpcm[0], samples); |
| } |
| system(("aplay " + temp_out_filename).c_str()); |
| system(("rm " + temp_out_filename).c_str()); |
| } else { |
| - WavWriter out_file(FLAGS_out_file, FLAGS_sample_rate, kNumChannels); |
| + WavWriter out_file(FLAGS_out_file, |
| + in_file.sample_rate(), |
| + in_file.num_channels()); |
| out_file.WriteSamples(&in_fpcm[0], samples); |
| } |
| } |