#include #include #include namespace VIZ { Strobo::Strobo(AudioGrabber *pGrabber, Vulcan121 *pVulcan121) : VIZ(pGrabber, pVulcan121) {} void Strobo::onSetup() { keyboard->sendToLEDs({0, 0, 0, 0}); grabber->requestMode = AudioGrabber::ReqMode::FFT; int16_t r = (int16_t)grabber->env->getAsInt("strobo.color.r", 25); int16_t g = (int16_t)grabber->env->getAsInt("strobo.color.g", 0); int16_t b = (int16_t)grabber->env->getAsInt("strobo.color.b", 150); m_color = {r, g, b, 255}; m_isStanding = false; } void Strobo::onTick(float delta) { led_map map{}; auto bass = grabber->getBass(); auto val = bass / 255.0; m_isStanding = bass < 5; if (m_isStanding) { m_color.a += 5; if (m_color.a > 255) { m_color.a = 255; } } else { m_sinPoint += val * val; if (m_sinPoint > 360) m_sinPoint -= 360; auto v = (std::sin(m_sinPoint) + 1) * 0.5; m_color.a = (v * v) * 255; } for (int key = 0; key < keyboardData.num_keys; ++key) { map.key[key] = m_color; } keyboard->sendLedMap(map); } const char *Strobo::name() { return m_name.c_str(); } } // namespace VIZ