forked from FastLED/FastLED
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio_batch.cpp.hpp
More file actions
75 lines (69 loc) · 2.16 KB
/
audio_batch.cpp.hpp
File metadata and controls
75 lines (69 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "fl/audio/audio_batch.h"
#include "fl/audio/audio_processor.h"
namespace fl {
void AudioBatch::ensurePeaks() const {
fl::lock_guard<fl::mutex> lock(mMutex);
if (mPeaksComputed) {
return;
}
for (const AudioFrame &af : mFrames) {
if (af.bass > mPeaks.bass)
mPeaks.bass = af.bass;
if (af.mid > mPeaks.mid)
mPeaks.mid = af.mid;
if (af.treble > mPeaks.treble)
mPeaks.treble = af.treble;
if (af.volume > mPeaks.volume)
mPeaks.volume = af.volume;
mPeaks.beat = mPeaks.beat || af.beat;
}
mPeaksComputed = true;
}
const VibeLevels &AudioBatch::vibe() const {
fl::lock_guard<fl::mutex> lock(mMutex);
if (!mVibeComputed) {
if (mProc) {
mVibe.bass = mProc->getVibeBass();
mVibe.mid = mProc->getVibeMid();
mVibe.treb = mProc->getVibeTreb();
mVibe.vol = mProc->getVibeVol();
mVibe.bassSpike = mProc->isVibeBassSpike();
mVibe.midSpike = mProc->isVibeMidSpike();
mVibe.trebSpike = mProc->isVibeTrebSpike();
}
mVibeComputed = true;
}
return mVibe;
}
const EqLevels &AudioBatch::equalizer() const {
fl::lock_guard<fl::mutex> lock(mMutex);
if (!mEqComputed) {
if (mProc) {
mEq.bass = mProc->getEqBass();
mEq.mid = mProc->getEqMid();
mEq.treble = mProc->getEqTreble();
mEq.volume = mProc->getEqVolume();
mEq.dominantFreqHz = mProc->getEqDominantFreqHz();
mEq.isSilence = mProc->getEqIsSilence();
for (int i = 0; i < EqLevels::kNumBins; ++i) {
mEq.bins[i] = mProc->getEqBin(i);
}
}
mEqComputed = true;
}
return mEq;
}
const PercussionState &AudioBatch::percussion() const {
fl::lock_guard<fl::mutex> lock(mMutex);
if (!mPercComputed) {
if (mProc) {
mPerc.kick = mProc->isKick();
mPerc.snare = mProc->isSnare();
mPerc.hihat = mProc->isHiHat();
mPerc.tom = mProc->isTom();
}
mPercComputed = true;
}
return mPerc;
}
} // namespace fl