Added Math Class
Added Rainbow Line Visual Added Delta-Timing to Visuals Cleanup Code Structure
This commit is contained in:
parent
238e22caf6
commit
dd06aa3e35
19 changed files with 244 additions and 34 deletions
10
headers/VUtils/Math.h
Normal file
10
headers/VUtils/Math.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
namespace VUtils {
|
||||
struct Math {
|
||||
static double clamp (double value, double min, double max);
|
||||
static double lerp(double a, double b, double f);
|
||||
static double bezierBlend(double t);
|
||||
static double easeIn(double ratio);
|
||||
};
|
||||
}
|
||||
8
headers/VulcanoLE/Colors/ColorHelper.h
Normal file
8
headers/VulcanoLE/Colors/ColorHelper.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
#include <VulcanoLE/Colors/Type.h>
|
||||
|
||||
namespace Color {
|
||||
struct Generator {
|
||||
static rgba rgbFromRatio(double ratio, int16_t alpha);
|
||||
};
|
||||
}
|
||||
10
headers/VulcanoLE/Colors/Type.h
Normal file
10
headers/VulcanoLE/Colors/Type.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
typedef struct rgba_type {
|
||||
int16_t r{};
|
||||
int16_t g{};
|
||||
int16_t b{};
|
||||
int16_t a = 255;
|
||||
} rgba;
|
||||
|
|
@ -1,18 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <VulcanoLE/API/HIDHelper.h>
|
||||
#include <VulcanoLE/Colors/Type.h>
|
||||
|
||||
#define NUM_KEYS 144
|
||||
#define NUM_ROWS 6
|
||||
#define NUM_COLS 21
|
||||
|
||||
typedef struct rgba_type {
|
||||
int16_t r{};
|
||||
int16_t g{};
|
||||
int16_t b{};
|
||||
int16_t a = 255;
|
||||
} rgba;
|
||||
|
||||
typedef struct subArray {
|
||||
int count = 0;
|
||||
int *index = nullptr; // will init in code! and returned
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace VIZ {
|
|||
Loudness(AudioGrabber *pGrabber, Vulcan121 *pVulcan121);
|
||||
~Loudness() override = default;
|
||||
void on_setup() override;
|
||||
void on_tick() override;
|
||||
void on_tick(float delta) override;
|
||||
float lastVal = 0;
|
||||
const char *name() override;
|
||||
std::string m_name = "Loudness Meter";
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
#include <VulcanoLE/Visual/VIZ.h>
|
||||
|
||||
namespace VIZ {
|
||||
class WeirdSpec : public VIZ {
|
||||
class PoliceLike : public VIZ {
|
||||
protected:
|
||||
int decayRate = 10;
|
||||
double lastPeak = -1;
|
||||
double threshold = 15;
|
||||
public:
|
||||
WeirdSpec(AudioGrabber *pGrabber, Vulcan121 *pVulcan121);
|
||||
~WeirdSpec() override = default;
|
||||
PoliceLike(AudioGrabber *pGrabber, Vulcan121 *pVulcan121);
|
||||
~PoliceLike() override = default;
|
||||
void on_setup() override;
|
||||
void on_tick() override;
|
||||
void on_tick(float delta) override;
|
||||
void switchOnPeak(double);
|
||||
int tick = 0;
|
||||
bool left = true;
|
||||
26
headers/VulcanoLE/Scripts/RainbowLine.h
Normal file
26
headers/VulcanoLE/Scripts/RainbowLine.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include <VulcanoLE/Visual/VIZ.h>
|
||||
|
||||
namespace VIZ {
|
||||
class RainbowLine : public VIZ {
|
||||
int currentColumn = 0;
|
||||
double deltaNeeded = 100000.0;
|
||||
double deltaElapsed = 0;
|
||||
rgba *colours = nullptr;
|
||||
double lastValue = 0;
|
||||
double decayValue = 0;
|
||||
double ratios[4] = {1.3,1.2,1.3,1.4};
|
||||
public:
|
||||
RainbowLine(AudioGrabber *pGrabber, Vulcan121 *vulcan);
|
||||
~RainbowLine() override;
|
||||
void on_setup() override;
|
||||
void on_tick(float delta) override;
|
||||
void calcNextDelta(double ratio);
|
||||
void updateMap(double factor);
|
||||
const char *name() override;
|
||||
std::string m_name = "Rainbow Line";
|
||||
led_map *data = Vulcan121::createEmptyLEDMap();
|
||||
bool firstUnder = true;
|
||||
};
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ namespace VIZ {
|
|||
Spectrum(AudioGrabber *pGrabber, Vulcan121 *pVulcan121);
|
||||
~Spectrum() override = default;
|
||||
void on_setup() override;
|
||||
void on_tick() override;
|
||||
void on_tick(float delta) override;
|
||||
double lastVal = 0;
|
||||
const char *name() override;
|
||||
std::string m_name = "Spectrum One";
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace VIZ {
|
|||
VIZ(AudioGrabber *pGrabber, Vulcan121 *pVulcan121) : grabber(pGrabber), keyboard(pVulcan121) {}
|
||||
virtual ~VIZ() = default;
|
||||
virtual void on_setup() = 0;
|
||||
virtual void on_tick() = 0;
|
||||
virtual void on_tick(float delta) = 0;
|
||||
Vulcan121 *keyboard{};
|
||||
Vulcan121::DATA keyboardData = Vulcan121::DATA{};
|
||||
AudioGrabber *grabber{};
|
||||
|
|
|
|||
|
|
@ -3,23 +3,26 @@
|
|||
#include <vector>
|
||||
#include <VulcanoLE/Scripts/Spectrum.h>
|
||||
|
||||
#define VIZSIZE 3
|
||||
#define VIZSIZE 4
|
||||
|
||||
using micro = std::chrono::duration<double, std::micro>;
|
||||
|
||||
namespace VIZ {
|
||||
struct VisPlugins {
|
||||
int mode = 0;
|
||||
void init(HIDHelper *, AudioGrabber*);
|
||||
void init(HIDHelper *, AudioGrabber *);
|
||||
void on_startup();
|
||||
void on_tick();
|
||||
void on_shutdown();
|
||||
void setCurrentMode(int);
|
||||
~VisPlugins();
|
||||
VUtils::Environment *env;
|
||||
VUtils::Environment *env{};
|
||||
protected:
|
||||
VIZ *viz[VIZSIZE]{};
|
||||
VIZ *currentVis;
|
||||
Vulcan121 *keyboard;
|
||||
AudioGrabber *grabber;
|
||||
VIZ *currentVis{};
|
||||
Vulcan121 *keyboard{};
|
||||
AudioGrabber *grabber{};
|
||||
std::chrono::time_point<std::chrono::system_clock, micro> start;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue