60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#include <VulcanoLE/Visual/VisPlugins.h>
|
|
#include <VulcanoLE/Scripts/Spectrum.h>
|
|
#include <VulcanoLE/Scripts/Loudness.h>
|
|
#include <VulcanoLE/Scripts/WeirdSpec.h>
|
|
#include <VUtils/Logging.h>
|
|
|
|
namespace VIZ {
|
|
void VisPlugins::init(HIDHelper *hidHelper, AudioGrabber *audioGrabber) {
|
|
grabber = audioGrabber;
|
|
keyboard = new Vulcan121(hidHelper);
|
|
viz[0] = new Spectrum(grabber, keyboard);
|
|
viz[1] = new Loudness(grabber, keyboard);
|
|
viz[2] = new WeirdSpec(grabber, keyboard);
|
|
currentVis = viz[mode];
|
|
}
|
|
|
|
void VisPlugins::on_startup() {
|
|
if (!keyboard->send_init_sequence()) {
|
|
ERR("FAILED TO INIT KEYBOARD")
|
|
exit(1);
|
|
}
|
|
currentVis->on_setup();
|
|
}
|
|
|
|
void VisPlugins::on_tick() {
|
|
currentVis->on_tick();
|
|
usleep(1000);
|
|
}
|
|
|
|
void VisPlugins::on_shutdown() {
|
|
int16_t r = env->getAsInt("shutdown_color_red", 0);
|
|
int16_t g = env->getAsInt("shutdown_color_green", 0);
|
|
int16_t b = env->getAsInt("shutdown_color_blue", 150);
|
|
int16_t a = env->getAsInt("shutdown_brightness", 100);
|
|
keyboard->send_led_to({ r, g, b, a });
|
|
}
|
|
|
|
VisPlugins::~VisPlugins() {
|
|
delete grabber;
|
|
delete keyboard;
|
|
for (auto &i : viz) {
|
|
delete i;
|
|
}
|
|
}
|
|
|
|
void VisPlugins::setCurrentMode(int m) {
|
|
if (m == 0 || m > VIZSIZE) {
|
|
ERR("Mode Setting Failed >> Mode is not in the available range 1 - %d", VIZSIZE)
|
|
return;
|
|
}
|
|
grabber->env->setNumber("visual_mode", m);
|
|
m -= 1;
|
|
currentVis = viz[m];
|
|
LOG("Now Using: %s", currentVis->name());
|
|
currentVis->on_setup();
|
|
mode = m;
|
|
}
|
|
}
|
|
|