From 3d2532bde88f3044149033e7a5bf92ac2b01af96 Mon Sep 17 00:00:00 2001 From: bsp2 Date: Tue, 7 May 2019 21:03:13 +0200 Subject: [PATCH] fix crash in FrozenWasteland.BPMLFO + BPMLFO2 --- .../repos/FrozenWasteland/make.objects | 1 - .../repos/FrozenWasteland/src/BPMLFO.cpp | 6 +- .../repos/FrozenWasteland/src/BPMLFO2.cpp | 2 +- .../repos/FrozenWasteland/src/dsp/base.hpp | 24 ------ .../repos/FrozenWasteland/src/dsp/noise.cpp | 23 ------ .../repos/FrozenWasteland/src/dsp/noise.hpp | 78 ------------------- 6 files changed, 3 insertions(+), 131 deletions(-) delete mode 100644 plugins/community/repos/FrozenWasteland/src/dsp/base.hpp delete mode 100644 plugins/community/repos/FrozenWasteland/src/dsp/noise.cpp delete mode 100644 plugins/community/repos/FrozenWasteland/src/dsp/noise.hpp diff --git a/plugins/community/repos/FrozenWasteland/make.objects b/plugins/community/repos/FrozenWasteland/make.objects index 0f49aef5..caf04845 100644 --- a/plugins/community/repos/FrozenWasteland/make.objects +++ b/plugins/community/repos/FrozenWasteland/make.objects @@ -3,7 +3,6 @@ ALL_OBJ= \ src/BPMLFO2.o \ src/CDCSeriouslySlowLFO.o \ src/DamianLillard.o \ - src/dsp/noise.o \ src/dsp-filter/third-party/falco/DspFilter.o \ src/dsp-filter/utils/AudioMath.o \ src/dsp-noise/noise.o \ diff --git a/plugins/community/repos/FrozenWasteland/src/BPMLFO.cpp b/plugins/community/repos/FrozenWasteland/src/BPMLFO.cpp index 805e17f8..1ba3cc7a 100644 --- a/plugins/community/repos/FrozenWasteland/src/BPMLFO.cpp +++ b/plugins/community/repos/FrozenWasteland/src/BPMLFO.cpp @@ -103,7 +103,7 @@ struct LowFrequencyOscillator { SchmittTrigger clockTrigger,resetTrigger,holdTrigger; float divisions[DIVISIONS] = {1/64.0f,1/32.0f,1/16.0f,1/13.0f,1/11.0f,1/8.0f,1/7.0f,1/6.0f,1/5.0f,1/4.0f,1/3.0f,1/2.0f,1/1.5f,1,1.5,2,3,4,5,6,7,8,11,13,16,32,64}; const char* divisionNames[DIVISIONS] = {"/64","/32","/16","/13","/11","/8","/7","/6","/5","/4","/3","/2","/1.5","x 1","x 1.5","x 2","x 3","x 4","x 5","x 6","x 7","x 8","x 11","x 13","x 16","x 32","x 64"}; - int division; + int division = 0; float time = 0.0; float duration = 0; bool holding = false; @@ -231,7 +231,6 @@ struct BPMLFOProgressDisplay : TransparentWidget { nvgFontSize(vg, 28); nvgFontFaceId(vg, font->handle); nvgTextLetterSpacing(vg, -2); - nvgFillColor(vg, nvgRGBA(0x00, 0xff, 0x00, 0xff)); char text[128]; snprintf(text, sizeof(text), "%s", module->divisionNames[division]); @@ -239,7 +238,6 @@ struct BPMLFOProgressDisplay : TransparentWidget { } void draw(NVGcontext *vg) override { - drawProgress(vg,module->oscillator.progress()); drawDivision(vg, Vec(0, box.size.y - 153), module->division); } @@ -251,7 +249,7 @@ struct BPMLFOWidget : ModuleWidget { BPMLFOWidget::BPMLFOWidget(BPMLFO *module) : ModuleWidget(module) { box.size = Vec(15*10, RACK_GRID_HEIGHT); - + { SVGPanel *panel = new SVGPanel(); panel->box.size = box.size; diff --git a/plugins/community/repos/FrozenWasteland/src/BPMLFO2.cpp b/plugins/community/repos/FrozenWasteland/src/BPMLFO2.cpp index 4304850b..e24812d0 100644 --- a/plugins/community/repos/FrozenWasteland/src/BPMLFO2.cpp +++ b/plugins/community/repos/FrozenWasteland/src/BPMLFO2.cpp @@ -108,7 +108,7 @@ struct LowFrequencyOscillator { SchmittTrigger clockTrigger,resetTrigger,holdTrigger; float divisions[DIVISIONS] = {1/64.0f,1/32.0f,1/16.0f,1/13.0f,1/11.0f,1/8.0f,1/7.0f,1/6.0f,1/5.0f,1/4.0f,1/3.0f,1/2.0f,1/1.5f,1,1.5f,2,3,4,5,6,7,8,11,13,16,32,64}; const char* divisionNames[DIVISIONS] = {"/64","/32","/16","/13","/11","/8","/7","/6","/5","/4","/3","/2","/1.5","x 1","x 1.5","x 2","x 3","x 4","x 5","x 6","x 7","x 8","x 11","x 13","x 16","x 32","x 64"}; - int division; + int division = 0; float time = 0.0; float duration = 0; float waveshape = 0; diff --git a/plugins/community/repos/FrozenWasteland/src/dsp/base.hpp b/plugins/community/repos/FrozenWasteland/src/dsp/base.hpp deleted file mode 100644 index 3e405daa..00000000 --- a/plugins/community/repos/FrozenWasteland/src/dsp/base.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -namespace frozenwasteland { -namespace dsp { - -struct Generator { - float _current = 0.0; - - Generator() {} - virtual ~Generator() {} - - float current() { - return _current; - } - - float next() { - return _current = _next(); - } - - virtual float _next() = 0; -}; - -} // namespace dsp -} // namespace frozenwasteland diff --git a/plugins/community/repos/FrozenWasteland/src/dsp/noise.cpp b/plugins/community/repos/FrozenWasteland/src/dsp/noise.cpp deleted file mode 100644 index 477a4d60..00000000 --- a/plugins/community/repos/FrozenWasteland/src/dsp/noise.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -#include "noise.hpp" - -using namespace frozenwasteland::dsp; - - -Seeds::Seeds() { - std::random_device rd; - _generator.seed(rd()); -} - -unsigned int Seeds::_next() { - return _generator(); -} - -Seeds& Seeds::getInstance() { - static Seeds instance; - return instance; -} - -unsigned int Seeds::next() { - return getInstance()._next(); -}; diff --git a/plugins/community/repos/FrozenWasteland/src/dsp/noise.hpp b/plugins/community/repos/FrozenWasteland/src/dsp/noise.hpp deleted file mode 100644 index d8618733..00000000 --- a/plugins/community/repos/FrozenWasteland/src/dsp/noise.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#include - -#include "base.hpp" - -namespace frozenwasteland { -namespace dsp { - -class Seeds { -private: - std::mt19937 _generator; - Seeds(); - unsigned int _next(); - -public: - Seeds(const Seeds&) = delete; - void operator=(const Seeds&) = delete; - static Seeds& getInstance(); - - static unsigned int next(); -}; - -struct NoiseGenerator : Generator { - std::minstd_rand _generator; // one of the faster options. - - NoiseGenerator() : _generator(Seeds::next()) {} -}; - -struct WhiteNoiseGenerator : NoiseGenerator { - std::uniform_real_distribution _uniform; - - WhiteNoiseGenerator() : _uniform(-1.0, 1.0) {} - - virtual float _next() override { - return _uniform(_generator); - } -}; - -template -struct BasePinkNoiseGenerator : NoiseGenerator { - static const int _n = 7; - G _g; - G _gs[_n]; - uint32_t _count = _g.next(); - - virtual float _next() override { - // See: http://www.firstpr.com.au/dsp/pink-noise/ - float sum = _g.next(); - for (int i = 0, bit = 1; i < _n; ++i, bit <<= 1) { - if (_count & bit) { - sum += _gs[i].next(); - } - else { - sum += _gs[i].current(); - } - } - ++_count; - return sum / (float)(_n + 1); - } -}; - -struct PinkNoiseGenerator : BasePinkNoiseGenerator {}; - -struct RedNoiseGenerator : BasePinkNoiseGenerator {}; - -struct GaussianNoiseGenerator : NoiseGenerator { - std::normal_distribution _normal; - - GaussianNoiseGenerator() : _normal(0, 1.0) {} - - virtual float _next() override { - return _normal(_generator); - } -}; - -} // namespace dsp -} // namespace frozenwasteland