Fixes
This commit is contained in:
parent
8505032307
commit
bbd208aacf
6 changed files with 238 additions and 224 deletions
|
|
@ -33,6 +33,12 @@ cmake -DCMAKE_BUILD_TYPE=Debug ..
|
|||
make -DCMAKE_BUILD_TYPE=Release ..
|
||||
```
|
||||
|
||||
## UDEV
|
||||
```udev
|
||||
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1e7d", ATTRS{idProduct}=="307a", MODE="660", GROUP="wheel"
|
||||
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="1e7d", ATTRS{idProduct}=="3098", MODE="660", GROUP="wheel"
|
||||
```
|
||||
|
||||
## RUN
|
||||
`./anyVulcanoLE`
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace VUtils {
|
||||
class StringUtils {
|
||||
public:
|
||||
class StringUtils {
|
||||
public:
|
||||
static void leftTrim(std::string &s);
|
||||
|
||||
static void rightTrim(std::string &s);
|
||||
|
|
@ -18,14 +19,16 @@ namespace VUtils {
|
|||
|
||||
static std::string trimCopy(std::string s);
|
||||
|
||||
static std::vector<std::string> split(const std::string &s, const std::string &delimiter);
|
||||
static std::vector<std::string> split(const std::string &s,
|
||||
const std::string &delimiter);
|
||||
|
||||
static std::string urlDecode(const std::string &url);
|
||||
|
||||
static std::string urlEncode(const std::string &url);
|
||||
|
||||
static std::string join(const std::vector<std::string>& vector, const std::string& delimiter);
|
||||
static std::string join(const std::vector<std::string> &vector,
|
||||
const std::string &delimiter);
|
||||
|
||||
static bool hasNullByte(int size, const char string[1024]);
|
||||
};
|
||||
}// namespace VUtils
|
||||
};
|
||||
} // namespace VUtils
|
||||
|
|
|
|||
|
|
@ -2,41 +2,44 @@
|
|||
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
namespace VUtils {
|
||||
void StringUtils::leftTrim(std::string &s) {
|
||||
s.erase(s.begin(), std::find_if(s.begin(), s.end(),
|
||||
void StringUtils::leftTrim(std::string &s) {
|
||||
s.erase(s.begin(),
|
||||
std::find_if(s.begin(), s.end(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||
}
|
||||
}
|
||||
|
||||
void StringUtils::rightTrim(std::string &s) {
|
||||
void StringUtils::rightTrim(std::string &s) {
|
||||
s.erase(std::find_if(s.rbegin(), s.rend(),
|
||||
std::not1(std::ptr_fun<int, int>(std::isspace)))
|
||||
.base(),
|
||||
s.end());
|
||||
}
|
||||
}
|
||||
|
||||
void StringUtils::trim(std::string &s) {
|
||||
void StringUtils::trim(std::string &s) {
|
||||
leftTrim(s);
|
||||
rightTrim(s);
|
||||
}
|
||||
}
|
||||
|
||||
std::string StringUtils::leftTrimCopy(std::string s) {
|
||||
std::string StringUtils::leftTrimCopy(std::string s) {
|
||||
leftTrim(s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
std::string StringUtils::rightTrimCopy(std::string s) {
|
||||
std::string StringUtils::rightTrimCopy(std::string s) {
|
||||
rightTrim(s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
std::string StringUtils::trimCopy(std::string s) {
|
||||
std::string StringUtils::trimCopy(std::string s) {
|
||||
trim(s);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> StringUtils::split(const std::string &s, const std::string &delimiter) {
|
||||
std::vector<std::string> StringUtils::split(const std::string &s,
|
||||
const std::string &delimiter) {
|
||||
size_t pos_start = 0, pos_end, delim_len = delimiter.length();
|
||||
std::string token;
|
||||
std::vector<std::string> res;
|
||||
|
|
@ -49,26 +52,26 @@ namespace VUtils {
|
|||
|
||||
res.push_back(s.substr(pos_start));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
std::string StringUtils::urlDecode(const std::string &val) {
|
||||
std::string StringUtils::urlDecode(const std::string &val) {
|
||||
std::string ret;
|
||||
char ch;
|
||||
int i, ii;
|
||||
for (i = 0; i < val.length(); i++) {
|
||||
if (int(val[ i ]) == 37) {
|
||||
if (int(val[i]) == 37) {
|
||||
sscanf(val.substr(i + 1, 2).c_str(), "%x", &ii);
|
||||
ch = static_cast<char>(ii);
|
||||
ret += ch;
|
||||
i = i + 2;
|
||||
} else {
|
||||
ret += val[ i ];
|
||||
ret += val[i];
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
}
|
||||
|
||||
std::string StringUtils::urlEncode(const std::string &value) {
|
||||
std::string StringUtils::urlEncode(const std::string &value) {
|
||||
std::ostringstream escaped;
|
||||
escaped.fill('0');
|
||||
escaped << std::hex;
|
||||
|
|
@ -79,28 +82,28 @@ namespace VUtils {
|
|||
continue;
|
||||
}
|
||||
escaped << std::uppercase;
|
||||
escaped << '%' << std::setw(2) << int((unsigned char) c);
|
||||
escaped << '%' << std::setw(2) << int((unsigned char)c);
|
||||
escaped << std::nouppercase;
|
||||
}
|
||||
|
||||
return escaped.str();
|
||||
}
|
||||
std::string StringUtils::join(const std::vector<std::string> &vector, const std::string &delimiter) {
|
||||
}
|
||||
std::string StringUtils::join(const std::vector<std::string> &vector,
|
||||
const std::string &delimiter) {
|
||||
std::stringstream string;
|
||||
for (int i = 0; i < vector.size(); ++i) {
|
||||
if (i != 0)
|
||||
string << delimiter;
|
||||
string << vector[ i ];
|
||||
|
||||
string << vector[i];
|
||||
}
|
||||
return string.str();
|
||||
}
|
||||
bool StringUtils::hasNullByte(int size, const char *string) {
|
||||
}
|
||||
bool StringUtils::hasNullByte(int size, const char *string) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (string[ i ] == '\0') {
|
||||
if (string[i] == '\0') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}// namespace VUtils
|
||||
}
|
||||
} // namespace VUtils
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include <cmath>
|
||||
#include <VulcanoLE/Audio/AudioGrabber.h>
|
||||
#include <VUtils/Logging.h>
|
||||
#include <VulcanoLE/Audio/JackClient.h>
|
||||
#include "VUtils/Math.h"
|
||||
|
||||
#include <VUtils/Logging.h>
|
||||
#include <VulcanoLE/Audio/AudioGrabber.h>
|
||||
#include <VulcanoLE/Audio/JackClient.h>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
AudioGrabber::AudioGrabber() = default;
|
||||
AudioGrabber::~AudioGrabber() = default;
|
||||
|
|
@ -25,12 +25,13 @@ AudioGrabber *AudioGrabber::createAudioGrabber() {
|
|||
}
|
||||
|
||||
void AudioGrabber::init() {
|
||||
m_buffer = static_cast<stereoSample *>(calloc(BUFFER_SIZE, sizeof(stereoSample)));
|
||||
m_buffer =
|
||||
static_cast<stereoSample *>(calloc(BUFFER_SIZE, sizeof(stereoSample)));
|
||||
if (env != nullptr)
|
||||
m_scale = env->getAsDouble("audio_scale", 1.0);
|
||||
m_filter.scale = 1.0;
|
||||
DBG("SET Audio Scale: %.3f", m_scale)
|
||||
loudness = { 0.0, 0.0 };
|
||||
loudness = {0.0, 0.0};
|
||||
}
|
||||
|
||||
void AudioGrabber::calculateRMS(stereoSample *pFrame) {
|
||||
|
|
@ -40,16 +41,16 @@ void AudioGrabber::calculateRMS(stereoSample *pFrame) {
|
|||
squareL += std::pow(pFrame[i].l * m_scale, 2);
|
||||
squareR += std::pow(pFrame[i].r * m_scale, 2);
|
||||
}
|
||||
meanL = (squareL / (float) (availableData));
|
||||
meanR = (squareR / (float) (availableData));
|
||||
loudness = { (float) std::sqrt(meanL), (float) std::sqrt(meanR) };
|
||||
meanL = (squareL / (float)(availableData));
|
||||
meanR = (squareR / (float)(availableData));
|
||||
loudness = {(float)std::sqrt(meanL), (float)std::sqrt(meanR)};
|
||||
}
|
||||
|
||||
void AudioGrabber::calculatePEAK(stereoSample *pFrame) {
|
||||
stereoSampleFrame max = { 0, 0 };
|
||||
stereoSampleFrame max = {0, 0};
|
||||
for (int i = 0; i < availableData; i++) {
|
||||
auto left = (float) std::abs(pFrame[i].l * m_scale);
|
||||
auto right = (float) std::abs(pFrame[i].r * m_scale);
|
||||
auto left = (float)std::abs(pFrame[i].l * m_scale);
|
||||
auto right = (float)std::abs(pFrame[i].r * m_scale);
|
||||
if (left > max.l)
|
||||
max.l = left;
|
||||
if (right > max.r)
|
||||
|
|
@ -90,9 +91,7 @@ bool AudioGrabber::work() {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
Audio::FilterHelper &AudioGrabber::getFilter() {
|
||||
return m_filter;
|
||||
}
|
||||
Audio::FilterHelper &AudioGrabber::getFilter() { return m_filter; }
|
||||
double AudioGrabber::getBass() {
|
||||
auto fftData = fft.getData();
|
||||
auto val = 0.0;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ bool FFT::prepareInput(stereoSample *buffer, uint32_t sampleSize, double scale)
|
|||
for (size_t i = 0; i < sampleSize; ++i) {
|
||||
m_fftwInputLeft[i][0] = VUtils::Math::clamp(buffer[i].r * scale, -1, 1) * hannWindow[i];
|
||||
m_fftwInputRight[i][0] = VUtils::Math::clamp(buffer[i].r * scale, -1, 1) * hannWindow[i];
|
||||
m_fftwInputLeft[i][1] = 0;
|
||||
m_fftwInputRight[i][1] = 0;
|
||||
if (is_silent && (m_fftwInputLeft[i][0] != 0 || m_fftwInputRight[i][0] != 0)) is_silent = false;
|
||||
}
|
||||
return is_silent;
|
||||
|
|
|
|||
|
|
@ -1,21 +1,24 @@
|
|||
#include <VulcanoLE/Scripts/TheUknown.h>
|
||||
#include <VUtils/SimplexNoise.h>
|
||||
#include <VulcanoLE/Scripts/TheUknown.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace VIZ {
|
||||
TheUnknown::TheUnknown(AudioGrabber *pGrabber, Vulcan121 *vulcan) : VIZ(pGrabber, vulcan) {
|
||||
TheUnknown::TheUnknown(AudioGrabber *pGrabber, Vulcan121 *vulcan)
|
||||
: VIZ(pGrabber, vulcan) {
|
||||
m_random.setDist(0, 128);
|
||||
for (int i = 0; i < NUM_KEYS; i++) {
|
||||
m_keyHeightMap[i] = std::abs(SimplexNoise::noise(i + 1.0f)) * 0.1;
|
||||
m_keyOffset[i] = m_random.getFast();
|
||||
}
|
||||
m_random.setDist(0.005, 0.01);
|
||||
}
|
||||
void TheUnknown::onSetup() {
|
||||
keyboard->sendToLEDs({ 0, 0, 0, 0 });
|
||||
Vulcan121::setColor(map, { 202, 35, 13, 255 });
|
||||
}
|
||||
void TheUnknown::onSetup() {
|
||||
keyboard->sendToLEDs({0, 0, 0, 0});
|
||||
Vulcan121::setColor(map, {202, 35, 13, 255});
|
||||
grabber->requestMode = AudioGrabber::ReqMode::PEAK;
|
||||
}
|
||||
void TheUnknown::onTick(float delta) {
|
||||
}
|
||||
void TheUnknown::onTick(float delta) {
|
||||
auto loudness = grabber->getLoudness();
|
||||
auto factor = (((loudness.r + loudness.l) / 2.0) * 0.9) + 0.05;
|
||||
for (size_t i = 0; i < keyboardData.num_keys; i++) {
|
||||
|
|
@ -34,8 +37,6 @@ namespace VIZ {
|
|||
m_angle -= 1;
|
||||
}
|
||||
keyboard->sendLedMap(map);
|
||||
}
|
||||
const char *TheUnknown::name() {
|
||||
return "TheUnknown";
|
||||
}
|
||||
}
|
||||
const char *TheUnknown::name() { return "TheUnknown"; }
|
||||
} // namespace VIZ
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue