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/rnn_vad/auto_correlation.h" 19 #include "modules/audio_processing/agc2/rnn_vad/common.h" 20 #include "modules/audio_processing/agc2/rnn_vad/pitch_info.h" 21 #include "modules/audio_processing/agc2/rnn_vad/pitch_search_internal.h" 22 23 namespace webrtc { 24 namespace rnn_vad { 25 26 // Pitch estimator. 27 class PitchEstimator { 28 public: 29 PitchEstimator(); 30 PitchEstimator(const PitchEstimator&) = delete; 31 PitchEstimator& operator=(const PitchEstimator&) = delete; 32 ~PitchEstimator(); 33 // Estimates the pitch period and gain. Returns the pitch estimation data for 34 // 48 kHz. 35 PitchInfo Estimate(rtc::ArrayView<const float, kBufSize24kHz> pitch_buf); 36 37 private: 38 PitchInfo last_pitch_48kHz_; 39 AutoCorrelationCalculator auto_corr_calculator_; 40 std::vector<float> pitch_buf_decimated_; 41 rtc::ArrayView<float, kBufSize12kHz> pitch_buf_decimated_view_; 42 std::vector<float> auto_corr_; 43 rtc::ArrayView<float, kNumInvertedLags12kHz> auto_corr_view_; 44 }; 45 46 } // namespace rnn_vad 47 } // namespace webrtc 48 49 #endif // MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_SEARCH_H_ 50