| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 DEFINE_double(gain_limit, 1000.0, "Maximum gain change in one block."); | 61 DEFINE_double(gain_limit, 1000.0, "Maximum gain change in one block."); |
| 62 | 62 |
| 63 DEFINE_string(clear_file, "speech.wav", "Input file with clear speech."); | 63 DEFINE_string(clear_file, "speech.wav", "Input file with clear speech."); |
| 64 DEFINE_string(noise_file, "noise.wav", "Input file with noise data."); | 64 DEFINE_string(noise_file, "noise.wav", "Input file with noise data."); |
| 65 DEFINE_string(out_file, | 65 DEFINE_string(out_file, |
| 66 "proc_enhanced.wav", | 66 "proc_enhanced.wav", |
| 67 "Enhanced output. Use '-' to " | 67 "Enhanced output. Use '-' to " |
| 68 "play through aplay immediately."); | 68 "play through aplay immediately."); |
| 69 | 69 |
| 70 // Constant IntelligibilityEnhancer constructor parameters. | 70 // Constant IntelligibilityEnhancer constructor parameters. |
| 71 const int kErbResolution = 2; | 71 const size_t kErbResolution = 2; |
| 72 const int kNumChannels = 1; | 72 const int kNumChannels = 1; |
| 73 | 73 |
| 74 // void function for gtest | 74 // void function for gtest |
| 75 void void_main(int argc, char* argv[]) { | 75 void void_main(int argc, char* argv[]) { |
| 76 google::SetUsageMessage( | 76 google::SetUsageMessage( |
| 77 "\n\nVariance algorithm types are:\n" | 77 "\n\nVariance algorithm types are:\n" |
| 78 " 0 - infinite/normal,\n" | 78 " 0 - infinite/normal,\n" |
| 79 " 1 - exponentially decaying,\n" | 79 " 1 - exponentially decaying,\n" |
| 80 " 2 - rolling window.\n" | 80 " 2 - rolling window.\n" |
| 81 "\nInput files must be little-endian 16-bit signed raw PCM.\n"); | 81 "\nInput files must be little-endian 16-bit signed raw PCM.\n"); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 104 in_file.ReadSamples(samples, &in_fpcm[0]); | 104 in_file.ReadSamples(samples, &in_fpcm[0]); |
| 105 | 105 |
| 106 WavReader noise_file(FLAGS_noise_file); | 106 WavReader noise_file(FLAGS_noise_file); |
| 107 std::vector<float> noise_fpcm(samples); | 107 std::vector<float> noise_fpcm(samples); |
| 108 noise_file.ReadSamples(samples, &noise_fpcm[0]); | 108 noise_file.ReadSamples(samples, &noise_fpcm[0]); |
| 109 | 109 |
| 110 // Run intelligibility enhancement. | 110 // Run intelligibility enhancement. |
| 111 | 111 |
| 112 IntelligibilityEnhancer enh( | 112 IntelligibilityEnhancer enh( |
| 113 kErbResolution, FLAGS_sample_rate, kNumChannels, FLAGS_clear_type, | 113 kErbResolution, FLAGS_sample_rate, kNumChannels, FLAGS_clear_type, |
| 114 static_cast<float>(FLAGS_clear_alpha), FLAGS_clear_window, FLAGS_ana_rate, | 114 static_cast<float>(FLAGS_clear_alpha), |
| 115 FLAGS_var_rate, FLAGS_gain_limit); | 115 static_cast<size_t>(FLAGS_clear_window), FLAGS_ana_rate, FLAGS_var_rate, |
| 116 FLAGS_gain_limit); |
| 116 | 117 |
| 117 // Slice the input into smaller chunks, as the APM would do, and feed them | 118 // Slice the input into smaller chunks, as the APM would do, and feed them |
| 118 // through the enhancer. | 119 // through the enhancer. |
| 119 float* clear_cursor = &in_fpcm[0]; | 120 float* clear_cursor = &in_fpcm[0]; |
| 120 float* noise_cursor = &noise_fpcm[0]; | 121 float* noise_cursor = &noise_fpcm[0]; |
| 121 | 122 |
| 122 for (size_t i = 0; i < samples; i += fragment_size) { | 123 for (size_t i = 0; i < samples; i += fragment_size) { |
| 123 enh.ProcessCaptureAudio(&noise_cursor); | 124 enh.ProcessCaptureAudio(&noise_cursor); |
| 124 enh.ProcessRenderAudio(&clear_cursor); | 125 enh.ProcessRenderAudio(&clear_cursor); |
| 125 clear_cursor += fragment_size; | 126 clear_cursor += fragment_size; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 141 } | 142 } |
| 142 } | 143 } |
| 143 | 144 |
| 144 } // namespace | 145 } // namespace |
| 145 } // namespace webrtc | 146 } // namespace webrtc |
| 146 | 147 |
| 147 int main(int argc, char* argv[]) { | 148 int main(int argc, char* argv[]) { |
| 148 webrtc::void_main(argc, argv); | 149 webrtc::void_main(argc, argv); |
| 149 return 0; | 150 return 0; |
| 150 } | 151 } |
| OLD | NEW |