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

◆ rms()

float fl::AudioSample::rms ( ) const

Definition at line 83 of file audio.cpp.

83 {
84 if (!isValid()) {
85 return 0.0f;
86 }
87 fl::u64 sum_sq = 0;
88 const int N = size();
89 for (int i = 0; i < N; ++i) {
90 fl::i32 x32 = fl::i32(pcm()[i]);
91 sum_sq += x32 * x32;
92 }
93 float rms = sqrtf(float(sum_sq) / N);
94 return rms;
95}
const VectorPCM & pcm() const
Definition audio.cpp:17
fl::size size() const
Definition audio.cpp:30
bool isValid() const
Definition audio.h:29
float rms() const
Definition audio.cpp:83

References isValid(), pcm(), rms(), and size().

Referenced by loop(), rms(), and fl::AudioReactive::updateVolumeAndPeak().

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