commit c9976c440cf54a15bc87ea4ce8758c48689260c4
parent 05483153c17d079e001cac77b2f64025ebdcc69a
Author: Matt Demanett <matt@demanett.net>
Date: Thu, 12 Sep 2019 22:12:48 -0400
Poly: UMIX and MATRIX88.
Diffstat:
4 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/src/Matrix88.cpp b/src/Matrix88.cpp
@@ -1,14 +1,23 @@
#include "Matrix88.hpp"
-void Matrix88::processChannel(const ProcessArgs& args, int _c) {
+int Matrix88::channels() {
+ int max = 0;
+ for (int i = 0; i < 8; ++i) {
+ max = std::max(max, inputs[IN1_INPUT + i].getChannels());
+ }
+ return max;
+}
+
+void Matrix88::processChannel(const ProcessArgs& args, int c) {
for (int i = 0; i < 8; ++i) {
int paramOffset = MIX11_PARAM + i * 8;
float out = 0.0f;
for (int j = 0; j < 8; ++j) {
- out += inputs[IN1_INPUT + j].getVoltageSum() * params[paramOffset + j].getValue();
+ out += inputs[IN1_INPUT + j].getPolyVoltage(c) * params[paramOffset + j].getValue();
}
- outputs[OUT1_OUTPUT + i].setVoltage(_saturators[i].next(params[LEVEL_PARAM].getValue() * out));
+ outputs[OUT1_OUTPUT + i].setChannels(_channels);
+ outputs[OUT1_OUTPUT + i].setVoltage(_saturators[c][i].next(params[LEVEL_PARAM].getValue() * out), c);
}
}
diff --git a/src/Matrix88.hpp b/src/Matrix88.hpp
@@ -107,7 +107,7 @@ struct Matrix88 : BGModule {
NUM_LIGHTS
};
- Saturator _saturators[8];
+ Saturator _saturators[maxChannels][8];
Matrix88() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
@@ -178,7 +178,8 @@ struct Matrix88 : BGModule {
configParam(LEVEL_PARAM, 0.0f, 1.0f, 1.0f, "Level", "%", 0.0f, 100.0f);
}
- void processChannel(const ProcessArgs& args, int _c) override;
+ int channels() override;
+ void processChannel(const ProcessArgs& args, int c) override;
};
} // namespace bogaudio
diff --git a/src/UMix.cpp b/src/UMix.cpp
@@ -23,21 +23,32 @@ void UMix::dataFromJson(json_t* root) {
}
}
-void UMix::processChannel(const ProcessArgs& args, int _c) {
- if (!outputs[OUT_OUTPUT].isConnected()) {
- return;
+bool UMix::active() {
+ return outputs[OUT_OUTPUT].isConnected();
+}
+
+int UMix::channels() {
+ int max = 0;
+ for (int i = 0; i < 8; ++i) {
+ max = std::max(max, inputs[IN1_INPUT + i].getChannels());
}
+ return max;
+}
+
+void UMix::processChannel(const ProcessArgs& args, int c) {
+ outputs[OUT_OUTPUT].setChannels(_channels);
+
if (_sum) {
float out = 0.0f;
for (int i = 0; i < 8; ++i) {
- out += inputs[IN1_INPUT + i].getVoltageSum();
+ out += inputs[IN1_INPUT + i].getPolyVoltage(c);
}
out *= params[LEVEL_PARAM].getValue();
if (_cvMode) {
- outputs[OUT_OUTPUT].setVoltage(clamp(out, -12.0f, 12.0f));
+ outputs[OUT_OUTPUT].setVoltage(clamp(out, -12.0f, 12.0f), c);
}
else {
- outputs[OUT_OUTPUT].setVoltage(_saturator.next(out));
+ outputs[OUT_OUTPUT].setVoltage(_saturator[c].next(out), c);
}
}
else {
@@ -45,7 +56,7 @@ void UMix::processChannel(const ProcessArgs& args, int _c) {
int active = 0;
for (int i = 0; i < 8; ++i) {
if (inputs[IN1_INPUT + i].isConnected()) {
- out += inputs[IN1_INPUT + i].getVoltageSum();
+ out += inputs[IN1_INPUT + i].getPolyVoltage(c);
++active;
}
}
@@ -53,14 +64,14 @@ void UMix::processChannel(const ProcessArgs& args, int _c) {
out /= (float)active;
out *= params[LEVEL_PARAM].getValue();
if (_cvMode) {
- outputs[OUT_OUTPUT].setVoltage(clamp(out, -12.0f, 12.0f));
+ outputs[OUT_OUTPUT].setVoltage(clamp(out, -12.0f, 12.0f), c);
}
else {
- outputs[OUT_OUTPUT].setVoltage(_saturator.next(out));
+ outputs[OUT_OUTPUT].setVoltage(_saturator[c].next(out), c);
}
}
else {
- outputs[OUT_OUTPUT].setVoltage(0.0f);
+ outputs[OUT_OUTPUT].setVoltage(0.0f, c);
}
}
}
diff --git a/src/UMix.hpp b/src/UMix.hpp
@@ -38,7 +38,7 @@ struct UMix : BGModule {
bool _sum = true;
bool _cvMode = false;
- Saturator _saturator;
+ Saturator _saturator[maxChannels];
UMix() {
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
@@ -47,7 +47,9 @@ struct UMix : BGModule {
json_t* dataToJson() override;
void dataFromJson(json_t* root) override;
- void processChannel(const ProcessArgs& args, int _c) override;
+ bool active() override;
+ int channels() override;
+ void processChannel(const ProcessArgs& args, int c) override;
};
} // namespace bogaudio