Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: webrtc/modules/audio_processing/intelligibility/test/intelligibility_proc.cc

Issue 1708353002: Drop support for playing output through aplay in intelligibility_proc (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove suppression for audio_processing_tests Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_tests.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 // 11 //
12 // Command line tool for speech intelligibility enhancement. Provides for 12 // Command line tool for speech intelligibility enhancement. Provides for
13 // running and testing intelligibility_enhancer as an independent process. 13 // running and testing intelligibility_enhancer as an independent process.
14 // Use --help for options. 14 // Use --help for options.
15 // 15 //
16 16
17 #include <stdint.h>
18 #include <stdlib.h>
19 #include <sys/stat.h> 17 #include <sys/stat.h>
20 #include <sys/types.h>
21 #include <string>
22 18
23 #include "gflags/gflags.h" 19 #include "gflags/gflags.h"
24 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
25 #include "webrtc/base/checks.h"
26 #include "webrtc/base/criticalsection.h" 21 #include "webrtc/base/criticalsection.h"
27 #include "webrtc/common_audio/include/audio_util.h" 22 #include "webrtc/common_audio/include/audio_util.h"
28 #include "webrtc/common_audio/real_fourier.h"
29 #include "webrtc/common_audio/wav_file.h" 23 #include "webrtc/common_audio/wav_file.h"
30 #include "webrtc/modules/audio_processing/audio_buffer.h" 24 #include "webrtc/modules/audio_processing/audio_buffer.h"
31 #include "webrtc/modules/audio_processing/include/audio_processing.h"
32 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc er.h" 25 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc er.h"
33 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_utils. h"
34 #include "webrtc/modules/audio_processing/noise_suppression_impl.h" 26 #include "webrtc/modules/audio_processing/noise_suppression_impl.h"
35 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
36 #include "webrtc/test/testsupport/fileutils.h"
37 27
38 using std::complex; 28 using std::complex;
39 29
40 namespace webrtc { 30 namespace webrtc {
41 namespace { 31 namespace {
42 32
43 DEFINE_double(clear_alpha, 0.9, "Power decay factor for clear data."); 33 DEFINE_double(clear_alpha, 0.9, "Power decay factor for clear data.");
44 DEFINE_int32(sample_rate, 34 DEFINE_int32(sample_rate,
45 16000, 35 16000,
46 "Audio sample rate used in the input and output files."); 36 "Audio sample rate used in the input and output files.");
47 DEFINE_int32(ana_rate, 37 DEFINE_int32(ana_rate,
48 60, 38 60,
49 "Analysis rate; gains recalculated every N blocks."); 39 "Analysis rate; gains recalculated every N blocks.");
50 DEFINE_double(gain_limit, 1000.0, "Maximum gain change in one block."); 40 DEFINE_double(gain_limit, 1000.0, "Maximum gain change in one block.");
51 41
52 DEFINE_string(clear_file, "speech.wav", "Input file with clear speech."); 42 DEFINE_string(clear_file, "speech.wav", "Input file with clear speech.");
53 DEFINE_string(noise_file, "noise.wav", "Input file with noise data."); 43 DEFINE_string(noise_file, "noise.wav", "Input file with noise data.");
54 DEFINE_string(out_file, 44 DEFINE_string(out_file, "proc_enhanced.wav", "Enhanced output file.");
55 "proc_enhanced.wav",
56 "Enhanced output. Use '-' to "
57 "play through aplay immediately.");
58 45
59 const size_t kNumChannels = 1; 46 const size_t kNumChannels = 1;
60 47
61 // void function for gtest 48 // void function for gtest
62 void void_main(int argc, char* argv[]) { 49 void void_main(int argc, char* argv[]) {
63 google::SetUsageMessage( 50 google::SetUsageMessage(
64 "\n\nInput files must be little-endian 16-bit signed raw PCM.\n"); 51 "\n\nInput files must be little-endian 16-bit signed raw PCM.\n");
65 google::ParseCommandLineFlags(&argc, &argv, true); 52 google::ParseCommandLineFlags(&argc, &argv, true);
66 53
67 size_t samples; // Number of samples in input PCM file 54 size_t samples; // Number of samples in input PCM file
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 ns.AnalyzeCaptureAudio(&capture_audio); 108 ns.AnalyzeCaptureAudio(&capture_audio);
122 ns.ProcessCaptureAudio(&capture_audio); 109 ns.ProcessCaptureAudio(&capture_audio);
123 enh.SetCaptureNoiseEstimate(ns.NoiseEstimate()); 110 enh.SetCaptureNoiseEstimate(ns.NoiseEstimate());
124 enh.ProcessRenderAudio(&clear_cursor, FLAGS_sample_rate, kNumChannels); 111 enh.ProcessRenderAudio(&clear_cursor, FLAGS_sample_rate, kNumChannels);
125 clear_cursor += fragment_size; 112 clear_cursor += fragment_size;
126 noise_cursor += fragment_size; 113 noise_cursor += fragment_size;
127 } 114 }
128 115
129 FloatToFloatS16(&in_fpcm[0], samples, &in_fpcm[0]); 116 FloatToFloatS16(&in_fpcm[0], samples, &in_fpcm[0]);
130 117
131 if (FLAGS_out_file.compare("-") == 0) { 118 WavWriter out_file(FLAGS_out_file, FLAGS_sample_rate, kNumChannels);
132 const std::string temp_out_filename = 119 out_file.WriteSamples(&in_fpcm[0], samples);
133 test::TempFilename(test::WorkingDir(), "temp_wav_file");
134 {
135 WavWriter out_file(temp_out_filename, FLAGS_sample_rate, kNumChannels);
136 out_file.WriteSamples(&in_fpcm[0], samples);
137 }
138 system(("aplay " + temp_out_filename).c_str());
139 system(("rm " + temp_out_filename).c_str());
140 } else {
141 WavWriter out_file(FLAGS_out_file, FLAGS_sample_rate, kNumChannels);
142 out_file.WriteSamples(&in_fpcm[0], samples);
143 }
144 } 120 }
145 121
146 } // namespace 122 } // namespace
147 } // namespace webrtc 123 } // namespace webrtc
148 124
149 int main(int argc, char* argv[]) { 125 int main(int argc, char* argv[]) {
150 webrtc::void_main(argc, argv); 126 webrtc::void_main(argc, argv);
151 return 0; 127 return 0;
152 } 128 }
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/audio_processing_tests.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698