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

Side by Side Diff: webrtc/modules/audio_processing/vad/vad_audio_proc_unittest.cc

Issue 1211563003: Pull the Voice Activity Detector out from the AGC (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 // We don't test the value of pitch gain and lags as they are created by iSAC 11 // We don't test the value of pitch gain and lags as they are created by iSAC
12 // routines. However, interpolation of pitch-gain and lags is in a separate 12 // routines. However, interpolation of pitch-gain and lags is in a separate
13 // class and has its own unit-test. 13 // class and has its own unit-test.
14 14
15 #include "webrtc/modules/audio_processing/agc/agc_audio_proc.h" 15 #include "webrtc/modules/audio_processing/vad/vad_audio_proc.h"
16 16
17 #include <math.h> 17 #include <math.h>
18 #include <stdio.h> 18 #include <stdio.h>
19 19
20 #include "gtest/gtest.h" 20 #include <string>
21 #include "webrtc/modules/audio_processing/agc/common.h" 21
22 #include "testing/gtest/include/gtest/gtest.h"
23 #include "webrtc/modules/audio_processing/vad/common.h"
22 #include "webrtc/modules/interface/module_common_types.h" 24 #include "webrtc/modules/interface/module_common_types.h"
23 #include "webrtc/test/testsupport/fileutils.h" 25 #include "webrtc/test/testsupport/fileutils.h"
24 26
25 namespace webrtc { 27 namespace webrtc {
26 28
27 TEST(AudioProcessingTest, DISABLED_ComputingFirstSpectralPeak) { 29 TEST(AudioProcessingTest, DISABLED_ComputingFirstSpectralPeak) {
28 AgcAudioProc audioproc; 30 VadAudioProc audioproc;
29 31
30 std::string peak_file_name = 32 std::string peak_file_name =
31 test::ResourcePath("audio_processing/agc/agc_spectral_peak", "dat"); 33 test::ResourcePath("audio_processing/agc/agc_spectral_peak", "dat");
32 FILE* peak_file = fopen(peak_file_name.c_str(), "rb"); 34 FILE* peak_file = fopen(peak_file_name.c_str(), "rb");
33 ASSERT_TRUE(peak_file != NULL); 35 ASSERT_TRUE(peak_file != NULL);
34 36
35 std::string pcm_file_name = 37 std::string pcm_file_name =
36 test::ResourcePath("audio_processing/agc/agc_audio", "pcm"); 38 test::ResourcePath("audio_processing/agc/agc_audio", "pcm");
37 FILE* pcm_file = fopen(pcm_file_name.c_str(), "rb"); 39 FILE* pcm_file = fopen(pcm_file_name.c_str(), "rb");
38 ASSERT_TRUE(pcm_file != NULL); 40 ASSERT_TRUE(pcm_file != NULL);
39 41
40 // Read 10 ms audio in each iteration. 42 // Read 10 ms audio in each iteration.
41 const size_t kDataLength = kLength10Ms; 43 const size_t kDataLength = kLength10Ms;
42 int16_t data[kDataLength] = { 0 }; 44 int16_t data[kDataLength] = {0};
43 AudioFeatures features; 45 AudioFeatures features;
44 double sp[kMaxNumFrames]; 46 double sp[kMaxNumFrames];
45 while (fread(data, sizeof(int16_t), kDataLength, pcm_file) == kDataLength) { 47 while (fread(data, sizeof(int16_t), kDataLength, pcm_file) == kDataLength) {
46 audioproc.ExtractFeatures(data, kDataLength, &features); 48 audioproc.ExtractFeatures(data, kDataLength, &features);
47 if (features.num_frames > 0) { 49 if (features.num_frames > 0) {
48 ASSERT_LT(features.num_frames, kMaxNumFrames); 50 ASSERT_LT(features.num_frames, kMaxNumFrames);
49 // Read reference values. 51 // Read reference values.
50 const size_t num_frames = features.num_frames; 52 const size_t num_frames = features.num_frames;
51 ASSERT_EQ(num_frames, fread(sp, sizeof(sp[0]), num_frames, peak_file)); 53 ASSERT_EQ(num_frames, fread(sp, sizeof(sp[0]), num_frames, peak_file));
52 for (int n = 0; n < features.num_frames; n++) 54 for (int n = 0; n < features.num_frames; n++)
53 EXPECT_NEAR(features.spectral_peak[n], sp[n], 3); 55 EXPECT_NEAR(features.spectral_peak[n], sp[n], 3);
54 } 56 }
55 } 57 }
56 58
57 fclose(peak_file); 59 fclose(peak_file);
58 fclose(pcm_file); 60 fclose(pcm_file);
59 } 61 }
60 62
61 } // namespace webrtc 63 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698