BogaudioModules

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

commit 72ee64b9a5486aa8d96fa9f12dde51adced9f4da
parent c9976c440cf54a15bc87ea4ce8758c48689260c4
Author: Matt Demanett <matt@demanett.net>
Date:   Thu, 12 Sep 2019 22:23:45 -0400

Poly: AM/RM.

Diffstat:
Msrc/AMRM.cpp | 24+++++++++++++++---------
Msrc/AMRM.hpp | 4+++-
2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/AMRM.cpp b/src/AMRM.cpp @@ -1,34 +1,40 @@ #include "AMRM.hpp" -void AMRM::processChannel(const ProcessArgs& args, int _c) { - if (!(outputs[OUT_OUTPUT].isConnected() || outputs[RECTIFY_OUTPUT].isConnected())) { - return; - } +bool AMRM::active() { + return outputs[OUT_OUTPUT].isConnected() || outputs[RECTIFY_OUTPUT].isConnected(); +} + +int AMRM::channels() { + return std::max(inputs[MODULATOR_INPUT].getChannels(), inputs[CARRIER_INPUT].getChannels()); +} +void AMRM::processChannel(const ProcessArgs& args, int c) { float rectify = params[RECTIFY_PARAM].getValue(); if (inputs[RECTIFY_INPUT].isConnected()) { - rectify = clamp(rectify + inputs[RECTIFY_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f); + rectify = clamp(rectify + inputs[RECTIFY_INPUT].getPolyVoltage(c) / 10.0f, 0.0f, 1.0f); } rectify = 1.0f - rectify; float depth = params[DRYWET_PARAM].getValue(); if (inputs[DRYWET_INPUT].isConnected()) { - depth = clamp(depth + inputs[DRYWET_INPUT].getVoltage() / 10.0f, 0.0f, 1.0f); + depth = clamp(depth + inputs[DRYWET_INPUT].getPolyVoltage(c) / 10.0f, 0.0f, 1.0f); } - float modulator = inputs[MODULATOR_INPUT].getVoltageSum(); + float modulator = inputs[MODULATOR_INPUT].getPolyVoltage(c); if (rectify < 1.0f) { rectify *= -5.0f; if (modulator < rectify) { modulator = rectify - (modulator - rectify); } } - outputs[RECTIFY_OUTPUT].setVoltage(modulator); + outputs[RECTIFY_OUTPUT].setChannels(_channels); + outputs[RECTIFY_OUTPUT].setVoltage(modulator, c); modulator *= depth; modulator += (1.0f - depth) * 5.0f; - outputs[OUT_OUTPUT].setVoltage(_saturator.next(modulator * inputs[CARRIER_INPUT].getVoltageSum() * 0.2f)); + outputs[OUT_OUTPUT].setChannels(_channels); + outputs[OUT_OUTPUT].setVoltage(_saturator.next(modulator * inputs[CARRIER_INPUT].getPolyVoltage(c) * 0.2f), c); } struct AMRMWidget : ModuleWidget { diff --git a/src/AMRM.hpp b/src/AMRM.hpp @@ -42,7 +42,9 @@ struct AMRM : BGModule { configParam(DRYWET_PARAM, 0.0f, 1.0f, 1.0f, "Wet mix", "%", 0.0f, 100.0f); } - void processChannel(const ProcessArgs& args, int _c) override; + bool active() override; + int channels() override; + void processChannel(const ProcessArgs& args, int c) override; }; } // namespace bogaudio