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

◆ rms()

float fl::AudioSample::rms ( ) const

Definition at line 128 of file audio.cpp.

128 {
129 if (!isValid()) {
130 return 0.0f;
131 }
132 fl::u64 sum_sq = 0;
133 const int N = size();
134 for (int i = 0; i < N; ++i) {
135 fl::i32 x32 = fl::i32(pcm()[i]);
136 sum_sq += x32 * x32;
137 }
138 float rms = sqrtf(float(sum_sq) / N);
139 return rms;
140}
const VectorPCM & pcm() const
Definition audio.cpp:62
fl::size size() const
Definition audio.cpp:75
bool isValid() const
Definition audio.h:36
float rms() const
Definition audio.cpp:128

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: