FastLED 3.9.15
Loading...
Searching...
No Matches

◆ findBestPeakLag() [2/2]

int fl::audio::detector::Pitch::findBestPeakLag ( const vector< float > & autocorr) const
private

Definition at line 151 of file pitch.cpp.hpp.

151 {
152 // Find the lag with maximum autocorrelation value
153 // (excluding lag 0, which is always maximum by definition)
154
155 float maxValue = -1.0f;
156 int bestLag = 0;
157
158 for (int lag = mMinPeriod; lag <= mMaxPeriod && lag < static_cast<int>(autocorr.size()); lag++) {
159 float value = autocorr[static_cast<size>(lag)];
160
161 // Look for positive peaks
162 if (value > maxValue && value > 0.0f) {
163 maxValue = value;
164 bestLag = lag;
165 }
166 }
167
168 return bestLag;
169}
constexpr int type_rank< T >::value

References mMinPeriod, fl::vector_basic::size(), and fl::type_rank< T >::value.

Referenced by calculateAutocorrelation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: