MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / Effect

Method Effect

sources/effects/Effect.cpp:42–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40#include <effects/AnimationBaseMusic.h>
41
42Effect::Effect(HyperHdrInstance* hyperhdr, int visiblePriority, int priority, int timeout, const EffectDefinition& effect)
43 : QObject()
44 , _visiblePriority(visiblePriority)
45 , _priority(priority)
46 , _timeout(timeout)
47 , _instanceIndex(hyperhdr->getInstanceIndex())
48 , _name(QString::fromStdString(effect.name))
49 , _effect(effect.factory())
50 , _soundHandle(0)
51 , _soundCapture(nullptr)
52 , _endTime(-1)
53 , _interrupt(false)
54 , _image(hyperhdr->getLedGridSize().width(), hyperhdr->getLedGridSize().height())
55 , _timer(this)
56 , _ledCount(hyperhdr->getLedCount())
57{
58 _log = Logger::getInstance(QString("EFFECT%1(%2)").arg(_instanceIndex).arg((_name.length() > 9) ? _name.left(6) + "..." : _name));
59
60 _colors.resize(_ledCount);
61 _colors.fill(ColorRgb::BLACK);
62
63 _timer.setTimerType(Qt::PreciseTimer);
64 connect(&_timer, &QTimer::timeout, this, &Effect::run);
65
66 _isSoundEffect = _effect->isSoundEffect();
67
68 if (_isSoundEffect)
69 {
70 emit GlobalSignals::getInstance()->SignalGetSoundCapture(_soundCapture);
71 if (_soundCapture == nullptr)
72 {
73 Error(_log, "Could not access the sound grabber");
74 requestInterruption();
75 }
76 else
77 {
78 auto musicEffect = dynamic_cast<AnimationBaseMusic*>(_effect);
79 if (musicEffect != nullptr)
80 {
81 musicEffect->hasResult = [&](AnimationBaseMusic* effect, uint32_t& lastIndex, bool* newAverage, bool* newSlow, bool* newFast, int* isMulti){
82 return _soundCapture->hasResult(effect, lastIndex, newAverage, newSlow, newFast, isMulti);
83 };
84 }
85 else
86 {
87 Error(_log, "Could not cast the object as music effect. The effect definition is incorrect");
88 requestInterruption();
89 }
90 SAFE_CALL_0_RET(_soundCapture.get(), open, uint32_t, _soundHandle);
91 }
92 }
93}
94
95Effect::~Effect()
96{

Callers

nothing calls this directly

Calls 10

getInstanceIndexMethod · 0.80
getLedGridSizeMethod · 0.80
fillMethod · 0.80
hasResultMethod · 0.80
widthMethod · 0.45
heightMethod · 0.45
getLedCountMethod · 0.45
resizeMethod · 0.45
isSoundEffectMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected