| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 // Prepare detect file. | 47 // Prepare detect file. |
| 48 std::stringstream detect_file_name; | 48 std::stringstream detect_file_name; |
| 49 detect_file_name << "audio_processing/transient/detect" | 49 detect_file_name << "audio_processing/transient/detect" |
| 50 << (sample_rate_hz / 1000) << "kHz"; | 50 << (sample_rate_hz / 1000) << "kHz"; |
| 51 | 51 |
| 52 std::unique_ptr<FileWrapper> detect_file(FileWrapper::Create()); | 52 std::unique_ptr<FileWrapper> detect_file(FileWrapper::Create()); |
| 53 | 53 |
| 54 detect_file->OpenFile( | 54 detect_file->OpenFile( |
| 55 test::ResourcePath(detect_file_name.str(), "dat").c_str(), | 55 test::ResourcePath(detect_file_name.str(), "dat").c_str(), |
| 56 true, // Read only. | 56 true); // Read only. |
| 57 false, // No loop. | |
| 58 false); // No text. | |
| 59 | 57 |
| 60 bool file_opened = detect_file->Open(); | 58 bool file_opened = detect_file->is_open(); |
| 61 ASSERT_TRUE(file_opened) << "File could not be opened.\n" | 59 ASSERT_TRUE(file_opened) << "File could not be opened.\n" |
| 62 << detect_file_name.str().c_str(); | 60 << detect_file_name.str().c_str(); |
| 63 | 61 |
| 64 // Prepare audio file. | 62 // Prepare audio file. |
| 65 std::stringstream audio_file_name; | 63 std::stringstream audio_file_name; |
| 66 audio_file_name << "audio_processing/transient/audio" | 64 audio_file_name << "audio_processing/transient/audio" |
| 67 << (sample_rate_hz / 1000) << "kHz"; | 65 << (sample_rate_hz / 1000) << "kHz"; |
| 68 | 66 |
| 69 std::unique_ptr<FileWrapper> audio_file(FileWrapper::Create()); | 67 std::unique_ptr<FileWrapper> audio_file(FileWrapper::Create()); |
| 70 | 68 |
| 71 audio_file->OpenFile( | 69 audio_file->OpenFile( |
| 72 test::ResourcePath(audio_file_name.str(), "pcm").c_str(), | 70 test::ResourcePath(audio_file_name.str(), "pcm").c_str(), |
| 73 true, // Read only. | 71 true); // Read only. |
| 74 false, // No loop. | |
| 75 false); // No text. | |
| 76 | 72 |
| 77 // Create detector. | 73 // Create detector. |
| 78 TransientDetector detector(sample_rate_hz); | 74 TransientDetector detector(sample_rate_hz); |
| 79 | 75 |
| 80 const size_t buffer_length = sample_rate_hz * ts::kChunkSizeMs / 1000; | 76 const size_t buffer_length = sample_rate_hz * ts::kChunkSizeMs / 1000; |
| 81 std::unique_ptr<float[]> buffer(new float[buffer_length]); | 77 std::unique_ptr<float[]> buffer(new float[buffer_length]); |
| 82 | 78 |
| 83 const float kTolerance = 0.02f; | 79 const float kTolerance = 0.02f; |
| 84 | 80 |
| 85 size_t frames_read = 0; | 81 size_t frames_read = 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 99 EXPECT_NEAR(file_value, detector_value, kTolerance) << "Frame: " | 95 EXPECT_NEAR(file_value, detector_value, kTolerance) << "Frame: " |
| 100 << frames_read; | 96 << frames_read; |
| 101 } | 97 } |
| 102 | 98 |
| 103 detect_file->CloseFile(); | 99 detect_file->CloseFile(); |
| 104 audio_file->CloseFile(); | 100 audio_file->CloseFile(); |
| 105 } | 101 } |
| 106 } | 102 } |
| 107 | 103 |
| 108 } // namespace webrtc | 104 } // namespace webrtc |
| OLD | NEW |