OLD | NEW |
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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 #include "webrtc/modules/include/module_common_types.h" | 27 #include "webrtc/modules/include/module_common_types.h" |
28 | 28 |
29 namespace webrtc { | 29 namespace webrtc { |
30 | 30 |
31 // The following structures are declared anonymous in iSAC's structs.h. To | 31 // The following structures are declared anonymous in iSAC's structs.h. To |
32 // forward declare them, we use this derived class trick. | 32 // forward declare them, we use this derived class trick. |
33 struct VadAudioProc::PitchAnalysisStruct : public ::PitchAnalysisStruct {}; | 33 struct VadAudioProc::PitchAnalysisStruct : public ::PitchAnalysisStruct {}; |
34 struct VadAudioProc::PreFiltBankstr : public ::PreFiltBankstr {}; | 34 struct VadAudioProc::PreFiltBankstr : public ::PreFiltBankstr {}; |
35 | 35 |
36 static const float kFrequencyResolution = | 36 static constexpr float kFrequencyResolution = |
37 kSampleRateHz / static_cast<float>(VadAudioProc::kDftSize); | 37 kSampleRateHz / static_cast<float>(VadAudioProc::kDftSize); |
38 static const int kSilenceRms = 5; | 38 static constexpr int kSilenceRms = 5; |
39 | 39 |
40 // TODO(turajs): Make a Create or Init for VadAudioProc. | 40 // TODO(turajs): Make a Create or Init for VadAudioProc. |
41 VadAudioProc::VadAudioProc() | 41 VadAudioProc::VadAudioProc() |
42 : audio_buffer_(), | 42 : audio_buffer_(), |
43 num_buffer_samples_(kNumPastSignalSamples), | 43 num_buffer_samples_(kNumPastSignalSamples), |
44 log_old_gain_(-2), | 44 log_old_gain_(-2), |
45 old_lag_(50), // Arbitrary but valid as pitch-lag (in samples). | 45 old_lag_(50), // Arbitrary but valid as pitch-lag (in samples). |
46 pitch_analysis_handle_(new PitchAnalysisStruct), | 46 pitch_analysis_handle_(new PitchAnalysisStruct), |
47 pre_filter_handle_(new PreFiltBankstr), | 47 pre_filter_handle_(new PreFiltBankstr), |
48 high_pass_filter_(PoleZeroFilter::Create(kCoeffNumerator, | 48 high_pass_filter_(PoleZeroFilter::Create(kCoeffNumerator, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 size_t offset = kNumPastSignalSamples; | 267 size_t offset = kNumPastSignalSamples; |
268 for (size_t i = 0; i < kNum10msSubframes; i++) { | 268 for (size_t i = 0; i < kNum10msSubframes; i++) { |
269 rms[i] = 0; | 269 rms[i] = 0; |
270 for (size_t n = 0; n < kNumSubframeSamples; n++, offset++) | 270 for (size_t n = 0; n < kNumSubframeSamples; n++, offset++) |
271 rms[i] += audio_buffer_[offset] * audio_buffer_[offset]; | 271 rms[i] += audio_buffer_[offset] * audio_buffer_[offset]; |
272 rms[i] = sqrt(rms[i] / kNumSubframeSamples); | 272 rms[i] = sqrt(rms[i] / kNumSubframeSamples); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 } // namespace webrtc | 276 } // namespace webrtc |
OLD | NEW |