FastLED 3.9.15
Loading...
Searching...
No Matches
audio_batch.cpp.hpp
Go to the documentation of this file.
3
4namespace fl {
5
7 fl::lock_guard<fl::mutex> lock(mMutex);
8 if (mPeaksComputed) {
9 return;
10 }
11 for (const AudioFrame &af : mFrames) {
12 if (af.bass > mPeaks.bass)
13 mPeaks.bass = af.bass;
14 if (af.mid > mPeaks.mid)
15 mPeaks.mid = af.mid;
16 if (af.treble > mPeaks.treble)
17 mPeaks.treble = af.treble;
18 if (af.volume > mPeaks.volume)
19 mPeaks.volume = af.volume;
20 mPeaks.beat = mPeaks.beat || af.beat;
21 }
22 mPeaksComputed = true;
23}
24
26 fl::lock_guard<fl::mutex> lock(mMutex);
27 if (!mVibeComputed) {
28 if (mProc) {
29 mVibe.bass = mProc->getVibeBass();
30 mVibe.mid = mProc->getVibeMid();
31 mVibe.treb = mProc->getVibeTreb();
32 mVibe.vol = mProc->getVibeVol();
33 mVibe.bassSpike = mProc->isVibeBassSpike();
34 mVibe.midSpike = mProc->isVibeMidSpike();
35 mVibe.trebSpike = mProc->isVibeTrebSpike();
36 }
37 mVibeComputed = true;
38 }
39 return mVibe;
40}
41
43 fl::lock_guard<fl::mutex> lock(mMutex);
44 if (!mEqComputed) {
45 if (mProc) {
46 mEq.bass = mProc->getEqBass();
47 mEq.mid = mProc->getEqMid();
48 mEq.treble = mProc->getEqTreble();
49 mEq.volume = mProc->getEqVolume();
50 mEq.dominantFreqHz = mProc->getEqDominantFreqHz();
51 mEq.isSilence = mProc->getEqIsSilence();
52 for (int i = 0; i < EqLevels::kNumBins; ++i) {
53 mEq.bins[i] = mProc->getEqBin(i);
54 }
55 }
56 mEqComputed = true;
57 }
58 return mEq;
59}
60
62 fl::lock_guard<fl::mutex> lock(mMutex);
63 if (!mPercComputed) {
64 if (mProc) {
65 mPerc.kick = mProc->isKick();
66 mPerc.snare = mProc->isSnare();
67 mPerc.hihat = mProc->isHiHat();
68 mPerc.tom = mProc->isTom();
69 }
70 mPercComputed = true;
71 }
72 return mPerc;
73}
74
75} // namespace fl
void ensurePeaks() const
PercussionState mPerc
VibeLevels mVibe
audio::Processor * mProc
fl::span< const AudioFrame > mFrames
Definition audio_batch.h:99
const EqLevels & equalizer() const
AudioFrame mPeaks
const PercussionState & percussion() const
fl::mutex mMutex
const VibeLevels & vibe() const
Base definition for an LED controller.
Definition crgb.hpp:179
Snapshot of self-normalizing MilkDrop-style vibe levels.
Definition audio_batch.h:21
Snapshot of percussion detection state.
Definition audio_batch.h:47
Lightweight snapshot of pre-computed audio analysis for one audio sample.
Definition audio_frame.h:10
static constexpr int kNumBins
Definition audio_batch.h:36
Snapshot of 16-bin normalized spectrum.
Definition audio_batch.h:35