BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

commit 41ca53ba6ef8202f9e9eaf4d799ef9ee5ff653e3
parent fa7cfc161d6a299bfab4ca6eeb048dbd6e7c82ab
Author: Matt Demanett <matt@demanett.net>
Date:   Mon, 27 Sep 2021 23:19:43 -0400

LVCO, LLFO: fix wave selection when module is unpatched.

Diffstat:
Msrc/LLFO.cpp | 11+++++++----
Msrc/LLFO.hpp | 1+
Msrc/LVCO.cpp | 10++++++----
Msrc/LVCO.hpp | 1+
Msrc/module.cpp | 13+++++++++----
Msrc/module.hpp | 1+
6 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/src/LLFO.cpp b/src/LLFO.cpp @@ -62,10 +62,7 @@ void LLFO::addChannel(int c) { } } -void LLFO::modulate() { - _slowMode = params[SLOW_PARAM].getValue() > 0.5f; - - _invert = false; +void LLFO::modulateAlways() { Wave wave = (Wave)(1 + (int)params[WAVE_PARAM].getValue()); if (_wave != wave) { _wave = wave; @@ -75,6 +72,12 @@ void LLFO::modulate() { } } } +} + +void LLFO::modulate() { + _slowMode = params[SLOW_PARAM].getValue() > 0.5f; + + _invert = false; switch (_wave) { case UNINITIALIZED_WAVE: case SINE_WAVE: { diff --git a/src/LLFO.hpp b/src/LLFO.hpp @@ -100,6 +100,7 @@ struct LLFO : LFOBase { bool active() override; int channels() override; void addChannel(int c) override; + void modulateAlways() override; void modulate() override; void modulateChannel(int c) override; void processAlways(const ProcessArgs& args) override; diff --git a/src/LVCO.cpp b/src/LVCO.cpp @@ -36,10 +36,7 @@ bool LVCO::active() { return outputs[OUT_OUTPUT].isConnected(); } -void LVCO::modulate() { - _slowMode = params[SLOW_PARAM].getValue() > 0.5f; - _fmDepth = params[FM_DEPTH_PARAM].getValue(); - +void LVCO::modulateAlways() { Wave wave = (Wave)(1 + (int)params[WAVE_PARAM].getValue()); if (_wave != wave) { _wave = wave; @@ -51,6 +48,11 @@ void LVCO::modulate() { } } +void LVCO::modulate() { + _slowMode = params[SLOW_PARAM].getValue() > 0.5f; + _fmDepth = params[FM_DEPTH_PARAM].getValue(); +} + void LVCO::modulateChannel(int c) { VCOBase::modulateChannel(c); Engine& e = *_engines[c]; diff --git a/src/LVCO.hpp b/src/LVCO.hpp @@ -70,6 +70,7 @@ struct LVCO : VCOBase { json_t* saveToJson(json_t* root) override; void loadFromJson(json_t* root) override; bool active() override; + void modulateAlways() override; void modulate() override; void modulateChannel(int c) override; void processAlways(const ProcessArgs& args) override; diff --git a/src/module.cpp b/src/module.cpp @@ -46,12 +46,17 @@ void BGModule::process(const ProcessArgs& args) { onSampleRateChange(); } + bool modulateNow = false; + ++_steps; + if (_steps >= _modulationSteps) { + _steps = 0; + modulateNow = true; + modulateAlways(); + } + processAlways(args); if (active()) { - ++_steps; - if (_steps >= _modulationSteps) { - _steps = 0; - + if (modulateNow) { int channelsBefore = _channels; int channelsNow = std::max(1, channels()); if (channelsBefore != channelsNow) { diff --git a/src/module.hpp b/src/module.hpp @@ -50,6 +50,7 @@ struct BGModule : Module { virtual void channelsChanged(int before, int after) {} virtual void addChannel(int c) {} virtual void removeChannel(int c) {} + virtual void modulateAlways() {} virtual void processAlways(const ProcessArgs& args) {} // called before modulate()! virtual void modulate() {} virtual void modulateChannel(int c) {}