1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_SEARCH_H_ 12 #define MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_SEARCH_H_ 13 14 #include <memory> 15 #include <vector> 16 17 #include "api/array_view.h" 18 #include "modules/audio_processing/agc2/cpu_features.h" 19 #include "modules/audio_processing/agc2/rnn_vad/auto_correlation.h" 20 #include "modules/audio_processing/agc2/rnn_vad/common.h" 21 #include "modules/audio_processing/agc2/rnn_vad/pitch_search_internal.h" 22 #include "rtc_base/gtest_prod_util.h" 23 24 namespace webrtc { 25 namespace rnn_vad { 26 27 // Pitch estimator. 28 class PitchEstimator { 29 public: 30 explicit PitchEstimator(const AvailableCpuFeatures& cpu_features); 31 PitchEstimator(const PitchEstimator&) = delete; 32 PitchEstimator& operator=(const PitchEstimator&) = delete; 33 ~PitchEstimator(); 34 // Returns the estimated pitch period at 48 kHz. 35 int Estimate(rtc::ArrayView<const float, kBufSize24kHz> pitch_buffer); 36 37 private: 38 FRIEND_TEST_ALL_PREFIXES(RnnVadTest, PitchSearchWithinTolerance); GetLastPitchStrengthForTesting()39 float GetLastPitchStrengthForTesting() const { 40 return last_pitch_48kHz_.strength; 41 } 42 43 const AvailableCpuFeatures cpu_features_; 44 PitchInfo last_pitch_48kHz_{}; 45 AutoCorrelationCalculator auto_corr_calculator_; 46 std::vector<float> y_energy_24kHz_; 47 std::vector<float> pitch_buffer_12kHz_; 48 std::vector<float> auto_correlation_12kHz_; 49 }; 50 51 } // namespace rnn_vad 52 } // namespace webrtc 53 54 #endif // MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_SEARCH_H_ 55