| @@ -3,7 +3,6 @@ ALL_OBJ= \ | |||||
| src/BPMLFO2.o \ | src/BPMLFO2.o \ | ||||
| src/CDCSeriouslySlowLFO.o \ | src/CDCSeriouslySlowLFO.o \ | ||||
| src/DamianLillard.o \ | src/DamianLillard.o \ | ||||
| src/dsp/noise.o \ | |||||
| src/dsp-filter/third-party/falco/DspFilter.o \ | src/dsp-filter/third-party/falco/DspFilter.o \ | ||||
| src/dsp-filter/utils/AudioMath.o \ | src/dsp-filter/utils/AudioMath.o \ | ||||
| src/dsp-noise/noise.o \ | src/dsp-noise/noise.o \ | ||||
| @@ -103,7 +103,7 @@ struct LowFrequencyOscillator { | |||||
| SchmittTrigger clockTrigger,resetTrigger,holdTrigger; | 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}; | 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"}; | 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 time = 0.0; | ||||
| float duration = 0; | float duration = 0; | ||||
| bool holding = false; | bool holding = false; | ||||
| @@ -231,7 +231,6 @@ struct BPMLFOProgressDisplay : TransparentWidget { | |||||
| nvgFontSize(vg, 28); | nvgFontSize(vg, 28); | ||||
| nvgFontFaceId(vg, font->handle); | nvgFontFaceId(vg, font->handle); | ||||
| nvgTextLetterSpacing(vg, -2); | nvgTextLetterSpacing(vg, -2); | ||||
| nvgFillColor(vg, nvgRGBA(0x00, 0xff, 0x00, 0xff)); | nvgFillColor(vg, nvgRGBA(0x00, 0xff, 0x00, 0xff)); | ||||
| char text[128]; | char text[128]; | ||||
| snprintf(text, sizeof(text), "%s", module->divisionNames[division]); | snprintf(text, sizeof(text), "%s", module->divisionNames[division]); | ||||
| @@ -239,7 +238,6 @@ struct BPMLFOProgressDisplay : TransparentWidget { | |||||
| } | } | ||||
| void draw(NVGcontext *vg) override { | void draw(NVGcontext *vg) override { | ||||
| drawProgress(vg,module->oscillator.progress()); | drawProgress(vg,module->oscillator.progress()); | ||||
| drawDivision(vg, Vec(0, box.size.y - 153), module->division); | drawDivision(vg, Vec(0, box.size.y - 153), module->division); | ||||
| } | } | ||||
| @@ -251,7 +249,7 @@ struct BPMLFOWidget : ModuleWidget { | |||||
| BPMLFOWidget::BPMLFOWidget(BPMLFO *module) : ModuleWidget(module) { | BPMLFOWidget::BPMLFOWidget(BPMLFO *module) : ModuleWidget(module) { | ||||
| box.size = Vec(15*10, RACK_GRID_HEIGHT); | box.size = Vec(15*10, RACK_GRID_HEIGHT); | ||||
| { | { | ||||
| SVGPanel *panel = new SVGPanel(); | SVGPanel *panel = new SVGPanel(); | ||||
| panel->box.size = box.size; | panel->box.size = box.size; | ||||
| @@ -108,7 +108,7 @@ struct LowFrequencyOscillator { | |||||
| SchmittTrigger clockTrigger,resetTrigger,holdTrigger; | 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}; | 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"}; | 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 time = 0.0; | ||||
| float duration = 0; | float duration = 0; | ||||
| float waveshape = 0; | float waveshape = 0; | ||||
| @@ -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 | |||||
| @@ -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(); | |||||
| }; | |||||
| @@ -1,78 +0,0 @@ | |||||
| #pragma once | |||||
| #include <random> | |||||
| #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<float> _uniform; | |||||
| WhiteNoiseGenerator() : _uniform(-1.0, 1.0) {} | |||||
| virtual float _next() override { | |||||
| return _uniform(_generator); | |||||
| } | |||||
| }; | |||||
| template<typename G> | |||||
| 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<WhiteNoiseGenerator> {}; | |||||
| struct RedNoiseGenerator : BasePinkNoiseGenerator<PinkNoiseGenerator> {}; | |||||
| struct GaussianNoiseGenerator : NoiseGenerator { | |||||
| std::normal_distribution<float> _normal; | |||||
| GaussianNoiseGenerator() : _normal(0, 1.0) {} | |||||
| virtual float _next() override { | |||||
| return _normal(_generator); | |||||
| } | |||||
| }; | |||||
| } // namespace dsp | |||||
| } // namespace frozenwasteland | |||||