-
Notifications
You must be signed in to change notification settings - Fork 4
/
VU2.cpp
32 lines (28 loc) · 811 Bytes
/
VU2.cpp
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
#include "VU2.h"
VU2::VU2(Strip *strip, AudioChannel *audioChannel, uint16_t size, double elasticConstant, CRGB color) : Fx(strip, audioChannel) {
this->size = size;
this->elasticConstant = elasticConstant;
this->color = color;
peak.setup(strip);
reset();
}
void VU2::reset() {
clear();
resetPeak();
}
void VU2::resetPeak() {
peak.reset()
.setColor(color)
.setElasticConstant(elasticConstant)
.setCriticalDamping()
.setLowerBound(0)
.setRange(0, max(0, size - 1))
.setPosition(strip->fromNormalizedPosition(audioChannel->peakSmooth))
.setShowWhenStable(false);
}
void VU2::loop() {
strip->fade(20);
peak
.setFixedPointPosition(strip->fromNormalizedPosition(audioChannel->peakSmooth))
.loop();
}