DONT KNOW :D
This commit is contained in:
parent
4152ee0413
commit
8505032307
44 changed files with 1357 additions and 272 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,4 +1,6 @@
|
|||
.cache/
|
||||
/build/
|
||||
/build-debug/
|
||||
/helper/
|
||||
/cmake-build-debug/
|
||||
.idea/
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@ cmake_minimum_required(VERSION 3.17)
|
|||
project(VulcanoLE)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(udev REQUIRED)
|
||||
find_package(HIDAPI REQUIRED)
|
||||
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package(JACK REQUIRED)
|
||||
|
||||
|
|
@ -27,14 +28,21 @@ set(SOURCE_FILES
|
|||
src/VulcanoLE/Scripts/RainbowLine.cpp
|
||||
src/VulcanoLE/Scripts/Random.cpp
|
||||
src/VulcanoLE/Scripts/RainbowMap.cpp
|
||||
src/VulcanoLE/Scripts/Spectral.cpp
|
||||
src/VulcanoLE/Scripts/BassHistory.cpp
|
||||
src/VulcanoLE/Scripts/TheUnknown.cpp
|
||||
src/VulcanoLE/Scripts/Strobo.cpp
|
||||
src/VulcanoLE/Audio/Filter.cpp
|
||||
)
|
||||
set(UTILS_FILES
|
||||
src/VUtils/Logging.cpp
|
||||
src/VUtils/FileHandler.cpp
|
||||
src/VUtils/Pool.cpp
|
||||
src/VUtils/Environment.cpp
|
||||
src/VUtils/Random.cpp
|
||||
src/VUtils/StringUtils.cpp
|
||||
src/VUtils/Math.cpp
|
||||
src/VUtils/SimplexNoise.cpp
|
||||
)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/headers/)
|
||||
add_executable(
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ find_path(HIDAPI_INCLUDE_DIR
|
|||
${PC_HIDAPI_HIDRAW_INCLUDE_DIRS}
|
||||
${PC_HIDAPI_LIBUSB_INCLUDE_DIRS})
|
||||
|
||||
find_package(Threads QUIET)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
###
|
||||
# Compute the "I don't care which backend" library
|
||||
|
|
|
|||
|
|
@ -1,19 +1,49 @@
|
|||
# Copyright (c) 2015 Andrew Kelley
|
||||
# This file is MIT licensed.
|
||||
# See http://opensource.org/licenses/MIT
|
||||
|
||||
# JACK_FOUND
|
||||
# JACK_INCLUDE_DIR
|
||||
# JACK_LIBRARY
|
||||
|
||||
find_path(JACK_INCLUDE_DIR NAMES jack/jack.h)
|
||||
|
||||
find_library(JACK_LIBRARY NAMES jack)
|
||||
|
||||
include(CheckLibraryExists)
|
||||
check_library_exists(jack "jack_set_port_rename_callback" "${JACK_LIBRARY}" HAVE_jack_set_port_rename_callback)
|
||||
# Try to find JACK
|
||||
# This will define the following variables:
|
||||
#
|
||||
# JACK_FOUND - Whether Jack was found.
|
||||
# JACK_INCLUDE_DIRS - Jack include directories.
|
||||
# JACK_LIBRARIES - Jack libraries.
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(JACK DEFAULT_MSG JACK_LIBRARY JACK_INCLUDE_DIR HAVE_jack_set_port_rename_callback)
|
||||
|
||||
mark_as_advanced(JACK_INCLUDE_DIR JACK_LIBRARY)
|
||||
if(JACK_LIBRARIES AND JACK_INCLUDE_DIRS)
|
||||
|
||||
# in cache already
|
||||
set(JACK_FOUND TRUE)
|
||||
|
||||
else()
|
||||
|
||||
find_package(PkgConfig)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(_JACK jack)
|
||||
endif(PKG_CONFIG_FOUND)
|
||||
|
||||
find_path(JACK_INCLUDE_DIR
|
||||
NAMES
|
||||
jack/jack.h
|
||||
PATHS
|
||||
${_JACK_INCLUDEDIR}
|
||||
)
|
||||
|
||||
find_library(JACK_LIBRARY
|
||||
NAMES
|
||||
jack
|
||||
PATHS
|
||||
${_JACK_LIBDIR}
|
||||
)
|
||||
|
||||
set(JACK_INCLUDE_DIRS
|
||||
${JACK_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(JACK_LIBRARIES
|
||||
${JACK_LIBRARY}
|
||||
)
|
||||
|
||||
find_package_handle_standard_args(JACK DEFAULT_MSG JACK_LIBRARIES JACK_INCLUDE_DIRS)
|
||||
|
||||
# show the JACK_INCLUDE_DIRS and JACK_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(JACK_INCLUDE_DIR JACK_LIBRARY JACK_INCLUDE_DIRS JACK_LIBRARIES)
|
||||
|
||||
endif()
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
namespace VUtils {
|
||||
class Environment {
|
||||
|
|
@ -20,7 +20,7 @@ namespace VUtils {
|
|||
void set(const char* name, const char *value);
|
||||
void setNumber(const char* name, double value);
|
||||
protected:
|
||||
std::unordered_map<std::string, std::string> m_env;
|
||||
std::map<std::string, std::string> m_env;
|
||||
std::string m_prefix = "VENV_";
|
||||
std::string m_filename;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,5 +7,6 @@ namespace VUtils {
|
|||
static double bezierBlend(double t);
|
||||
static double easeIn(double ratio);
|
||||
static double map(double x, double in_min, double in_max, double out_min, double out_max);
|
||||
static double cubicInterpolate (double y0, double y1, double y2, double y3, double factor);
|
||||
};
|
||||
}
|
||||
23
headers/VUtils/Random.h
Normal file
23
headers/VUtils/Random.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include <random>
|
||||
|
||||
namespace VUtils {
|
||||
|
||||
class Random {
|
||||
public:
|
||||
static Random& the() {
|
||||
static Random _instance;
|
||||
return _instance;
|
||||
}
|
||||
Random();
|
||||
static double generate(double min, double max);
|
||||
double get(double min, double max);
|
||||
void setDist(double min, double max);
|
||||
double getFast();
|
||||
private:
|
||||
std::random_device m_rd;
|
||||
std::mt19937 m_mt;
|
||||
std::uniform_real_distribution<double> m_dist;
|
||||
};
|
||||
}
|
||||
55
headers/VUtils/SimplexNoise.h
Normal file
55
headers/VUtils/SimplexNoise.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* @file SimplexNoise.h
|
||||
* @brief A Perlin Simplex Noise C++ Implementation (1D, 2D, 3D).
|
||||
*
|
||||
* Copyright (c) 2014-2018 Sebastien Rombauts (sebastien.rombauts@gmail.com)
|
||||
*
|
||||
* Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
|
||||
* or copy at http://opensource.org/licenses/MIT)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // size_t
|
||||
|
||||
/**
|
||||
* @brief A Perlin Simplex Noise C++ Implementation (1D, 2D, 3D, 4D).
|
||||
*/
|
||||
class SimplexNoise {
|
||||
public:
|
||||
// 1D Perlin simplex noise
|
||||
static float noise(float x);
|
||||
// 2D Perlin simplex noise
|
||||
static float noise(float x, float y);
|
||||
// 3D Perlin simplex noise
|
||||
static float noise(float x, float y, float z);
|
||||
|
||||
// Fractal/Fractional Brownian Motion (fBm) noise summation
|
||||
float fractal(size_t octaves, float x) const;
|
||||
float fractal(size_t octaves, float x, float y) const;
|
||||
float fractal(size_t octaves, float x, float y, float z) const;
|
||||
|
||||
/**
|
||||
* Constructor of to initialize a fractal noise summation
|
||||
*
|
||||
* @param[in] frequency Frequency ("width") of the first octave of noise (default to 1.0)
|
||||
* @param[in] amplitude Amplitude ("height") of the first octave of noise (default to 1.0)
|
||||
* @param[in] lacunarity Lacunarity specifies the frequency multiplier between successive octaves (default to 2.0).
|
||||
* @param[in] persistence Persistence is the loss of amplitude between successive octaves (usually 1/lacunarity)
|
||||
*/
|
||||
explicit SimplexNoise(float frequency = 1.0f,
|
||||
float amplitude = 1.0f,
|
||||
float lacunarity = 2.0f,
|
||||
float persistence = 0.5f) :
|
||||
mFrequency(frequency),
|
||||
mAmplitude(amplitude),
|
||||
mLacunarity(lacunarity),
|
||||
mPersistence(persistence) {
|
||||
}
|
||||
|
||||
private:
|
||||
// Parameters of Fractional Brownian Motion (fBm) : sum of N "octaves" of noise
|
||||
float mFrequency; ///< Frequency ("width") of the first octave of noise (default to 1.0)
|
||||
float mAmplitude; ///< Amplitude ("height") of the first octave of noise (default to 1.0)
|
||||
float mLacunarity; ///< Lacunarity specifies the frequency multiplier between successive octaves (default to 2.0).
|
||||
float mPersistence; ///< Persistence is the loss of amplitude between successive octaves (usually 1/lacunarity)
|
||||
};
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
#include <VUtils/Environment.h>
|
||||
#include <VulcanoLE/Audio/FFT.h>
|
||||
#include <VulcanoLE/Audio/Types.h>
|
||||
#include <VulcanoLE/Audio/Filter.h>
|
||||
|
||||
class AudioGrabber {
|
||||
public:
|
||||
|
|
@ -14,19 +15,22 @@ public:
|
|||
FFT = 0,
|
||||
RMS = 1,
|
||||
PEAK = 2,
|
||||
ALL = 3
|
||||
FILTER = 3,
|
||||
ALL = 4
|
||||
};
|
||||
AudioGrabber();
|
||||
~AudioGrabber();
|
||||
bool read(stereoSample *buffer, uint32_t bufferSize);
|
||||
static AudioGrabber* createAudioGrabber();
|
||||
void init();
|
||||
Audio::FilterHelper& getFilter();
|
||||
FFT fft;
|
||||
ReqMode requestMode = ReqMode::FFT;
|
||||
stereoSampleFrame loudness = {0.0, 0.0};
|
||||
stereoSampleFrame getLoudness();
|
||||
bool work();
|
||||
VUtils::Environment *env = nullptr;
|
||||
double getBass();
|
||||
private:
|
||||
std::mutex m_mtx;
|
||||
stereoSample *m_buffer{};
|
||||
|
|
@ -34,4 +38,5 @@ private:
|
|||
void calculatePEAK(stereoSample *pFrame);
|
||||
double m_scale = 1.0;
|
||||
int availableData = 0;
|
||||
Audio::FilterHelper m_filter;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public:
|
|||
outputSample *getData();
|
||||
bool prepareInput(stereoSample *buffer, uint32_t sampleSize, double scale);
|
||||
double hannWindow[BUFFER_SIZE]{};
|
||||
int size = BUFFER_SIZE;
|
||||
protected:
|
||||
fftw_complex *m_fftwInputLeft{};
|
||||
fftw_complex *m_fftwInputRight{};
|
||||
|
|
@ -25,4 +26,5 @@ protected:
|
|||
static double valueToAmp(double value);
|
||||
double times;
|
||||
static double limit;
|
||||
|
||||
};
|
||||
|
|
|
|||
30
headers/VulcanoLE/Audio/Filter.h
Normal file
30
headers/VulcanoLE/Audio/Filter.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "Types.h"
|
||||
#include <vector>
|
||||
|
||||
#define FILTER_LIMIT 0.25
|
||||
namespace Audio {
|
||||
class Filter {
|
||||
public:
|
||||
Filter();
|
||||
float process(float input, float cut, float);
|
||||
|
||||
protected:
|
||||
float output = 0.0;
|
||||
int m_counter = 0;
|
||||
float m_feedback[4][16]{};
|
||||
float m_filterOutput[4]{};
|
||||
};
|
||||
|
||||
struct FilterHelper {
|
||||
Filter filter_right{};
|
||||
Filter filter_left{};
|
||||
float cutoff{};
|
||||
float scale{1.0};
|
||||
std::vector<stereoSample> output;
|
||||
stereoSampleFrame work(stereoSample *buffer, int size);
|
||||
protected:
|
||||
double m_limit = FILTER_LIMIT;
|
||||
int overshot_times = 0;
|
||||
stereoSampleFrame doLimit(double, double);
|
||||
};
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
#define FFT_SIZE 512
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
struct stereoSampleFrame {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
#include <VulcanoLE/Colors/Type.h>
|
||||
|
||||
namespace Color {
|
||||
struct Generator {
|
||||
static rgba rgbFromRatio(double ratio, int16_t alpha);
|
||||
};
|
||||
}
|
||||
struct Generator {
|
||||
static rgba rgbFromRatio(double ratio, int16_t alpha);
|
||||
static rgb rgbFromHSV(hsv in);
|
||||
};
|
||||
} // namespace Color
|
||||
|
|
|
|||
|
|
@ -3,8 +3,20 @@
|
|||
#include <cstdint>
|
||||
|
||||
typedef struct rgba_type {
|
||||
int16_t r{};
|
||||
int16_t g{};
|
||||
int16_t b{};
|
||||
int16_t a = 255;
|
||||
} rgba;
|
||||
int16_t r = 0;
|
||||
int16_t g = 0;
|
||||
int16_t b = 0;
|
||||
int16_t a = 0;
|
||||
} rgba;
|
||||
|
||||
typedef struct {
|
||||
double r; // a fraction between 0 and 1
|
||||
double g; // a fraction between 0 and 1
|
||||
double b; // a fraction between 0 and 1
|
||||
} rgb;
|
||||
|
||||
typedef struct {
|
||||
double h; // angle in degrees
|
||||
double s; // a fraction between 0 and 1
|
||||
double v; // a fraction between 0 and 1
|
||||
} hsv;
|
||||
|
|
|
|||
|
|
@ -20,13 +20,12 @@ class Vulcan121 {
|
|||
public:
|
||||
explicit Vulcan121(HIDHelper *helper);
|
||||
~Vulcan121();
|
||||
int sendLedMap(led_map *src, bool deleteMap = false);
|
||||
int sendLedMap(led_map& src);
|
||||
int sendToLEDs(rgba rgb);
|
||||
bool sendInitSequence();
|
||||
bool queryCtrlReport(unsigned char id);
|
||||
bool sendCtrlReport(unsigned char id);
|
||||
bool waitForCtrlDev();
|
||||
static led_map *createEmptyLEDMap();
|
||||
struct DATA {
|
||||
int num_rows = NUM_ROWS;
|
||||
int num_cols = NUM_COLS;
|
||||
|
|
@ -39,8 +38,10 @@ public:
|
|||
int getIndex(int row, int col);
|
||||
// PLEASE MAKE SURE YOU KNOW THE LIMITS!
|
||||
int getIndexNoCheck(int row, int col);
|
||||
static void fadeOutMap(led_map* map, double factor);
|
||||
void fadeOutMapColumn(led_map* map, double factor);
|
||||
static void fadeOutMap(led_map& map, double factor);
|
||||
static void setColor(led_map& map, rgba color);
|
||||
static void setColorNoBrightness(led_map& map, rgba color);
|
||||
void fadeOutMapColumn(led_map& map, double factor);
|
||||
protected:
|
||||
void setupMap();
|
||||
// we need some mapping feature! rows and cols dont have the same amount of keys. so the struct needs
|
||||
|
|
|
|||
20
headers/VulcanoLE/Scripts/BassHistory.h
Normal file
20
headers/VulcanoLE/Scripts/BassHistory.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <VulcanoLE/Visual/VIZ.h>
|
||||
#include <VulcanoLE/Audio/AudioGrabber.h>
|
||||
#include <queue>
|
||||
|
||||
namespace VIZ {
|
||||
struct BassHistory : public VIZ {
|
||||
BassHistory(AudioGrabber *pGrabber, Vulcan121 *pVulcan121);
|
||||
~BassHistory() override = default;
|
||||
void onSetup() override;
|
||||
void onTick(float delta) override;
|
||||
const char *name() override;
|
||||
std::string m_name = "Bass History";
|
||||
led_map map{};
|
||||
std::vector<double> m_history;
|
||||
void pushNew(double val);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -13,8 +13,11 @@ namespace VIZ {
|
|||
void onTick(float delta) override;
|
||||
void setForChannel(float value, int channel);
|
||||
void drawFrame(int toRow);
|
||||
void drawSetup(float val);
|
||||
const char *name() override;
|
||||
std::string m_name = "Loudness Meter";
|
||||
bool isSetup = true;
|
||||
double frameWidth = 0;
|
||||
protected:
|
||||
rgba colours[3] = {
|
||||
{ 0, 0, 255, 80 },
|
||||
|
|
@ -22,7 +25,7 @@ namespace VIZ {
|
|||
{ 255, 0, 0, 40 }
|
||||
};
|
||||
double tailFactor = 0;
|
||||
led_map *data = Vulcan121::createEmptyLEDMap();
|
||||
led_map data{};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
namespace VIZ {
|
||||
class RainbowLine : public VIZ {
|
||||
int currentColumn = 0;
|
||||
double deltaNeeded = 100000.0;
|
||||
double deltaNeeded = 0.0;
|
||||
double deltaElapsed = 0;
|
||||
rgba *colours = nullptr;
|
||||
int maxCols = 0;
|
||||
double lastValue = 0;
|
||||
double decayValue = 0;
|
||||
double tailFactor = 0.3;
|
||||
double tailFactor = 0.5;
|
||||
public:
|
||||
RainbowLine(AudioGrabber *pGrabber, Vulcan121 *vulcan);
|
||||
~RainbowLine() override;
|
||||
|
|
@ -20,7 +20,7 @@ namespace VIZ {
|
|||
void calcNextDelta(double ratio);
|
||||
const char *name() override;
|
||||
std::string m_name = "Rainbow Line";
|
||||
led_map *data = Vulcan121::createEmptyLEDMap();
|
||||
led_map data{};
|
||||
bool firstUnder = true;
|
||||
double deltaMove(double val);
|
||||
void moveLine(double val, double d);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace VIZ {
|
|||
void calcNextDelta(double ratio);
|
||||
const char *name() override;
|
||||
std::string m_name = "Rainbow Map";
|
||||
led_map *data = Vulcan121::createEmptyLEDMap();
|
||||
led_map data{};
|
||||
bool firstUnder = true;
|
||||
double deltaMove(double val);
|
||||
void moveRainbow(double d);
|
||||
|
|
|
|||
|
|
@ -4,23 +4,18 @@
|
|||
#include <VulcanoLE/Keyboards/Vulcan121.h>
|
||||
#include <VulcanoLE/Visual/VIZ.h>
|
||||
#include <vector>
|
||||
#include "VUtils/Random.h"
|
||||
|
||||
namespace VIZ {
|
||||
class Random : public VIZ {
|
||||
protected:
|
||||
led_map *map = nullptr;
|
||||
bool isReverse{ false };
|
||||
bool emptyTicks{ false };
|
||||
led_map map{};
|
||||
VUtils::Random m_random;
|
||||
double m_angle{0.0};
|
||||
public:
|
||||
Random(AudioGrabber *pGrabber, Vulcan121 *vulcan);
|
||||
~Random() override;
|
||||
void onSetup() override;
|
||||
void onTick(float delta) override;
|
||||
const char *name() override;
|
||||
float deltaElapsed;
|
||||
float deltaNeeded{ 80000 };
|
||||
int row;
|
||||
int columnCount{0}; // for last selected row all previous draw full
|
||||
int ticks;
|
||||
};
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue