commit d094f63cc6798792234b0790bc7715f2fa287fa6
parent 9088751a5dd5afb93ea0e4cfbfb7814592c3b25b
Author: Matt Demanett <matt@demanett.net>
Date: Fri, 7 Aug 2020 00:33:10 -0400
PEQ6, PEQ14: add option where if a band direct output is in use, that band is excluded from the mix output (including even and odd mixes for PEQ14). #130
Diffstat:
6 files changed, 76 insertions(+), 13 deletions(-)
diff --git a/src/PEQ14.cpp b/src/PEQ14.cpp
@@ -86,17 +86,35 @@ void PEQ14::processAlways(const ProcessArgs& args) {
void PEQ14::processChannel(const ProcessArgs& args, int c) {
PEQEngine& e = *_engines[c];
float out = e.next(inputs[IN_INPUT].getVoltage(c), _rmsSums);
- outputs[OUT_OUTPUT].setVoltage(out, c);
-
float oddOut = 0.0f;
float evenOut = 0.0f;
+ float beOut = 0.0f;
+ float beOddOut = 0.0f;
+ float beEvenOut = 0.0f;
for (int i = 0; i < 14; ++i) {
- oddOut += e.outs[i] * (float)(i % 2 == 0 || (i == 13 && _highMode == MultimodeFilter::HIGHPASS_MODE));
- evenOut += e.outs[i] * (float)(i % 2 == 1 || (i == 0 && _lowMode == MultimodeFilter::LOWPASS_MODE));
- outputs[OUT1_OUTPUT + i].setVoltage(e.outs[i], c);
+ float odd = e.outs[i] * (float)(i % 2 == 0 || (i == 13 && _highMode == MultimodeFilter::HIGHPASS_MODE));
+ oddOut += odd;
+ float even = e.outs[i] * (float)(i % 2 == 1 || (i == 0 && _lowMode == MultimodeFilter::LOWPASS_MODE));
+ evenOut += even;
+ if (outputs[OUT1_OUTPUT + i].isConnected()) {
+ outputs[OUT1_OUTPUT + i].setVoltage(e.outs[i], c);
+ }
+ else {
+ beOut += e.outs[i];
+ beOddOut += odd;
+ beEvenOut += even;
+ }
+ }
+ if (_bandExclude) {
+ outputs[OUT_OUTPUT].setVoltage(beOut, c);
+ outputs[ODDS_OUTPUT].setVoltage(beOddOut, c);
+ outputs[EVENS_OUTPUT].setVoltage(beEvenOut, c);
+ }
+ else {
+ outputs[OUT_OUTPUT].setVoltage(out, c);
+ outputs[ODDS_OUTPUT].setVoltage(oddOut, c);
+ outputs[EVENS_OUTPUT].setVoltage(evenOut, c);
}
- outputs[ODDS_OUTPUT].setVoltage(oddOut, c);
- outputs[EVENS_OUTPUT].setVoltage(evenOut, c);
if (expanderConnected()) {
auto m = toExpander();
@@ -118,7 +136,7 @@ void PEQ14::postProcessAlways(const ProcessArgs& args) {
lights[FMOD_FULL_LIGHT].value = _fullFrequencyMode;
}
-struct PEQ14Widget : BGModuleWidget {
+struct PEQ14Widget : BandExcludeModuleWidget {
static constexpr int hp = 46;
PEQ14Widget(PEQ14* module) {
diff --git a/src/PEQ14.hpp b/src/PEQ14.hpp
@@ -4,7 +4,7 @@
namespace bogaudio {
-struct PEQ14 : ExpandableModule<PEQ14ExpanderMessage, BGModule> {
+struct PEQ14 : ExpandableModule<PEQ14ExpanderMessage, BandExcludeModule> {
enum ParamsIds {
FREQUENCY_CV_PARAM,
BANDWIDTH_PARAM,
diff --git a/src/PEQ6.cpp b/src/PEQ6.cpp
@@ -79,9 +79,20 @@ void PEQ6::processAlways(const ProcessArgs& args) {
void PEQ6::processChannel(const ProcessArgs& args, int c) {
PEQEngine& e = *_engines[c];
float out = e.next(inputs[IN_INPUT].getVoltage(c), _rmsSums);
- outputs[OUT_OUTPUT].setVoltage(out, c);
+ float beOut = 0.0f;
for (int i = 0; i < 6; ++i) {
- outputs[OUT1_OUTPUT + i].setVoltage(e.outs[i], c);
+ if (outputs[OUT1_OUTPUT + i].isConnected()) {
+ outputs[OUT1_OUTPUT + i].setVoltage(e.outs[i], c);
+ }
+ else {
+ beOut += e.outs[i];
+ }
+ }
+ if (_bandExclude) {
+ outputs[OUT_OUTPUT].setVoltage(beOut, c);
+ }
+ else {
+ outputs[OUT_OUTPUT].setVoltage(out, c);
}
if (_expanderMessage) {
@@ -100,7 +111,7 @@ void PEQ6::postProcessAlways(const ProcessArgs& args) {
lights[FMOD_FULL_LIGHT].value = _fullFrequencyMode;
}
-struct PEQ6Widget : BGModuleWidget {
+struct PEQ6Widget : BandExcludeModuleWidget {
static constexpr int hp = 21;
PEQ6Widget(PEQ6* module) {
diff --git a/src/PEQ6.hpp b/src/PEQ6.hpp
@@ -4,7 +4,7 @@
namespace bogaudio {
-struct PEQ6 : ExpandableModule<PEQ6ExpanderMessage, BGModule> {
+struct PEQ6 : ExpandableModule<PEQ6ExpanderMessage, BandExcludeModule> {
enum ParamsIds {
FREQUENCY_CV_PARAM,
BANDWIDTH_PARAM,
diff --git a/src/parametric_eq.cpp b/src/parametric_eq.cpp
@@ -126,3 +126,26 @@ float PEQXFBase::scaleEF(float ef, float frequency, float bandwidth) {
scale = sqrtf(scale); // FIXME: someday prove this is correct.
return 2.0f * scale * ef;
}
+
+
+#define BAND_EXCLUDE "band_exclude"
+
+json_t* BandExcludeModule::toJson(json_t* root) {
+ json_object_set_new(root, BAND_EXCLUDE, json_boolean(_bandExclude));
+ return root;
+}
+
+void BandExcludeModule::fromJson(json_t* root) {
+ json_t* be = json_object_get(root, BAND_EXCLUDE);
+ if (be) {
+ _bandExclude = json_is_true(be);
+ }
+}
+
+
+void BandExcludeModuleWidget::contextMenu(Menu* menu) {
+ auto m = dynamic_cast<BandExcludeModule*>(module);
+ assert(m);
+ menu->addChild(new MenuLabel());
+ menu->addChild(new BoolOptionMenuItem("Exclude direct-output bands from mix", [m]() { return &m->_bandExclude; }));
+}
diff --git a/src/parametric_eq.hpp b/src/parametric_eq.hpp
@@ -149,4 +149,15 @@ struct PEQXFBase : FollowerBase {
float scaleEF(float ef, float frequency, float bandwidth);
};
+struct BandExcludeModule : BGModule {
+ bool _bandExclude = false;
+
+ json_t* toJson(json_t* root) override;
+ void fromJson(json_t* root) override;
+};
+
+struct BandExcludeModuleWidget : BGModuleWidget {
+ void contextMenu(Menu* menu) override;
+};
+
} // namespace bogaudio