pitch_search.h (1835B)
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 <vector> 15 16 #include "api/array_view.h" 17 #include "modules/audio_processing/agc2/cpu_features.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_search_internal.h" 21 #include "rtc_base/gtest_prod_util.h" 22 23 namespace webrtc { 24 namespace rnn_vad { 25 26 // Pitch estimator. 27 class PitchEstimator { 28 public: 29 explicit PitchEstimator(const AvailableCpuFeatures& cpu_features); 30 PitchEstimator(const PitchEstimator&) = delete; 31 PitchEstimator& operator=(const PitchEstimator&) = delete; 32 ~PitchEstimator(); 33 // Returns the estimated pitch period at 48 kHz. 34 int Estimate(ArrayView<const float, kBufSize24kHz> pitch_buffer); 35 36 private: 37 FRIEND_TEST_ALL_PREFIXES(RnnVadTest, PitchSearchWithinTolerance); 38 float GetLastPitchStrengthForTesting() const { 39 return last_pitch_48kHz_.strength; 40 } 41 42 const AvailableCpuFeatures cpu_features_; 43 PitchInfo last_pitch_48kHz_{}; 44 AutoCorrelationCalculator auto_corr_calculator_; 45 std::vector<float> y_energy_24kHz_; 46 std::vector<float> pitch_buffer_12kHz_; 47 std::vector<float> auto_correlation_12kHz_; 48 }; 49 50 } // namespace rnn_vad 51 } // namespace webrtc 52 53 #endif // MODULES_AUDIO_PROCESSING_AGC2_RNN_VAD_PITCH_SEARCH_H_