|
|
@@ -1,10 +1,15 @@
|
|
|
#include "plugin.hpp"
|
|
|
#include <componentlibrary.hpp>
|
|
|
|
|
|
-#define NUM_DISPLAYS 9
|
|
|
-struct SSI2164_Mixer1 : Module {
|
|
|
+#define NUM_DISPLAYS 12
|
|
|
+#define MIN_ATT 1.85
|
|
|
+#define SILENT_ATT 1.8
|
|
|
+
|
|
|
+struct SSI2164_Mixer1 : Module
|
|
|
+{
|
|
|
float disp[NUM_DISPLAYS];
|
|
|
- enum ParamId {
|
|
|
+ enum ParamId
|
|
|
+ {
|
|
|
CH1_AUX1_PARAM,
|
|
|
CH1_AUX2_PARAM,
|
|
|
CH1_PAN_PARAM,
|
|
|
@@ -12,7 +17,8 @@ struct SSI2164_Mixer1 : Module {
|
|
|
CH1_FAD_PARAM,
|
|
|
PARAMS_LEN
|
|
|
};
|
|
|
- enum InputId {
|
|
|
+ enum InputId
|
|
|
+ {
|
|
|
CH1_IN_INPUT,
|
|
|
CH1_PAN_INPUT,
|
|
|
AUX2_RETURN_R_INPUT,
|
|
|
@@ -20,7 +26,8 @@ struct SSI2164_Mixer1 : Module {
|
|
|
AUX1_RETURN_INPUT,
|
|
|
INPUTS_LEN
|
|
|
};
|
|
|
- enum OutputId {
|
|
|
+ enum OutputId
|
|
|
+ {
|
|
|
AUX2_SEND_L_OUTPUT,
|
|
|
AUX1_SEND_OUTPUT,
|
|
|
AUX2_SEND_R_OUTPUT,
|
|
|
@@ -28,18 +35,20 @@ struct SSI2164_Mixer1 : Module {
|
|
|
MASTER_OUT_R_OUTPUT,
|
|
|
OUTPUTS_LEN
|
|
|
};
|
|
|
- enum LightId {
|
|
|
+ enum LightId
|
|
|
+ {
|
|
|
CH1_LEVEL_LIGHT,
|
|
|
MASTER_LED_L_LIGHT,
|
|
|
MASTER_LED_R_LIGHT,
|
|
|
LIGHTS_LEN
|
|
|
};
|
|
|
|
|
|
- SSI2164_Mixer1() {
|
|
|
+ SSI2164_Mixer1()
|
|
|
+ {
|
|
|
config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
|
|
|
configParam(CH1_AUX1_PARAM, 0.f, 1.f, 0.f, "Aux 1");
|
|
|
configParam(CH1_AUX2_PARAM, 0.f, 1.f, 0.f, "Aux 2");
|
|
|
- configParam(CH1_PAN_PARAM, -1.f, 1.f, .0f, "Pan", "mV");
|
|
|
+ configParam(CH1_PAN_PARAM, -1.f, 1.f, .0f, "Pan");
|
|
|
configParam(CH1_MUTE_PARAM, 0.f, 1.f, 0.f, "Mute");
|
|
|
configParam(CH1_FAD_PARAM, 0.f, 1.f, 0.f, "Fader");
|
|
|
configInput(CH1_IN_INPUT, "Ch1");
|
|
|
@@ -57,26 +66,40 @@ struct SSI2164_Mixer1 : Module {
|
|
|
configOutput(MASTER_OUT_R_OUTPUT, "Master R");
|
|
|
}
|
|
|
|
|
|
- void process(const ProcessArgs &args) override {
|
|
|
+ float ssi2164_conversion(float iin, float cv)
|
|
|
+ {
|
|
|
+ cv = fmax(0, cv);
|
|
|
+ if (cv < SILENT_ATT)
|
|
|
+ return iin * pow(2, -5.0505 * cv);
|
|
|
+ else
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ void process(const ProcessArgs &args) override
|
|
|
+ {
|
|
|
float aux1_cv, aux2_l_cv, aux2_r_cv, master_l_cv, master_r_cv;
|
|
|
- float aux1_control, aux2_control, pan_control, pan_cv_in, fad_control;
|
|
|
+ float aux1_control, aux2_control, pan_control, pan_cv_in, fad_control, mute_control;
|
|
|
|
|
|
float pan_cv, pan_l_control, pan_r_control;
|
|
|
|
|
|
- aux1_control = params[CH1_AUX1_PARAM].getValue();
|
|
|
- aux2_control = params[CH1_AUX2_PARAM].getValue();
|
|
|
+ aux1_control = (1 - params[CH1_AUX1_PARAM].getValue()) * MIN_ATT;
|
|
|
+ aux2_control = (1 - params[CH1_AUX2_PARAM].getValue()) * MIN_ATT;
|
|
|
pan_control = params[CH1_PAN_PARAM].getValue();
|
|
|
pan_cv_in = inputs[CH1_PAN_INPUT].getVoltage();
|
|
|
- fad_control = params[CH1_FAD_PARAM].getValue();
|
|
|
+ fad_control = (1 - params[CH1_FAD_PARAM].getValue()) * MIN_ATT;
|
|
|
+ mute_control = params[CH1_MUTE_PARAM].getValue();
|
|
|
|
|
|
// Normalize pan voltages to +-1 and do calculations based on that
|
|
|
- pan_cv = pan_control + pan_cv_in / 5;
|
|
|
- pan_l_control = fmax(.0f, pan_cv * (2.5));
|
|
|
- pan_r_control = fmax(.0f, pan_cv * (-2.5));
|
|
|
+ pan_cv = (pan_control + pan_cv_in / 5);
|
|
|
+ pan_l_control = fmax(.0f, pan_cv * (MIN_ATT) + 0.033);
|
|
|
+ pan_r_control = fmax(.0f, pan_cv * (-MIN_ATT) + 0.033);
|
|
|
|
|
|
disp[0] = pan_cv;
|
|
|
disp[1] = pan_l_control;
|
|
|
disp[2] = pan_r_control;
|
|
|
+ disp[3] = fad_control;
|
|
|
+ disp[4] = aux1_control;
|
|
|
+ disp[5] = aux2_control;
|
|
|
|
|
|
aux1_cv = fad_control + aux1_control;
|
|
|
aux2_l_cv = fad_control + pan_l_control + aux2_control;
|
|
|
@@ -84,76 +107,96 @@ struct SSI2164_Mixer1 : Module {
|
|
|
master_l_cv = fad_control + pan_l_control;
|
|
|
master_r_cv = fad_control + pan_r_control;
|
|
|
|
|
|
+ disp[6] = aux1_cv;
|
|
|
+ disp[7] = aux2_l_cv;
|
|
|
+ disp[8] = aux2_r_cv;
|
|
|
+ disp[9] = master_l_cv;
|
|
|
+ disp[10] = master_r_cv;
|
|
|
+ disp[11] = mute_control;
|
|
|
|
|
|
- float ssi2164_cv = .0f, ssi2164_in = .0f, ssi2164_out = .0f;
|
|
|
- float ch1_in = inputs[CH1_IN_INPUT].getVoltage();
|
|
|
-
|
|
|
- float master_l = .0f;
|
|
|
- float master_r = .0f;
|
|
|
- float aux1_out = .0f;
|
|
|
-
|
|
|
- ssi2164_cv += 2.1 - params[CH1_FAD_PARAM].getValue() * 2.1;
|
|
|
- ssi2164_in += ch1_in;
|
|
|
- if (ssi2164_cv < 2)
|
|
|
- ssi2164_out = ssi2164_in * pow(2, -5.0505 * ssi2164_cv);
|
|
|
- else
|
|
|
- ssi2164_out = 0;
|
|
|
- aux1_out += ssi2164_out;
|
|
|
-
|
|
|
- master_l += ch1_in * params[CH1_FAD_PARAM].getValue();
|
|
|
- master_r += ch1_in * pow(100, params[CH1_FAD_PARAM].getValue()) / 100;
|
|
|
+ float ch1_in = 0;
|
|
|
+ if (mute_control < 0.1)
|
|
|
+ ch1_in = inputs[CH1_IN_INPUT].getVoltage();
|
|
|
|
|
|
// https://www.dr-lex.be/info-stuff/volumecontrols.html
|
|
|
- outputs[MASTER_OUT_L_OUTPUT].setVoltage(master_l);
|
|
|
- outputs[MASTER_OUT_R_OUTPUT].setVoltage(master_r);
|
|
|
+ outputs[AUX1_SEND_OUTPUT].setVoltage(ssi2164_conversion(ch1_in, aux1_cv));
|
|
|
+
|
|
|
+ outputs[AUX2_SEND_L_OUTPUT].setVoltage(ssi2164_conversion(ch1_in, aux2_l_cv));
|
|
|
+ outputs[AUX2_SEND_R_OUTPUT].setVoltage(ssi2164_conversion(ch1_in, aux2_r_cv));
|
|
|
|
|
|
- outputs[AUX1_SEND_OUTPUT].setVoltage(aux1_out);
|
|
|
+ outputs[MASTER_OUT_L_OUTPUT].setVoltage(ssi2164_conversion(ch1_in, master_l_cv));
|
|
|
+ outputs[MASTER_OUT_R_OUTPUT].setVoltage(ssi2164_conversion(ch1_in, master_r_cv));
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-struct KnobPenis : RoundKnob {
|
|
|
- KnobPenis() {
|
|
|
+struct KnobPenis : RoundKnob
|
|
|
+{
|
|
|
+ KnobPenis()
|
|
|
+ {
|
|
|
setSvg(contextGet()->window->loadSvg(
|
|
|
asset::plugin(pluginInstance, "res/KnobPenis.svg")));
|
|
|
box.size = Vec(19, 19);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-struct numberBox : TransparentWidget {
|
|
|
+struct numberBox : TransparentWidget
|
|
|
+{
|
|
|
float *val[NUM_DISPLAYS];
|
|
|
- void draw(const DrawArgs &args) override {
|
|
|
|
|
|
- std::string fontPath = asset::system("res/fonts/DejaVuSans.ttf");
|
|
|
- std::shared_ptr<Font> font = APP->window->loadFont(fontPath);
|
|
|
-
|
|
|
- if (font) {
|
|
|
- nvgFillColor(args.vg, nvgRGBf(0.0, 0.0, 0.0));
|
|
|
- nvgBeginPath(args.vg);
|
|
|
- nvgRect(args.vg, 0.0, 0.0, box.size.x, box.size.y);
|
|
|
- nvgFill(args.vg);
|
|
|
- std::string texts[NUM_DISPLAYS];
|
|
|
+ numberBox() : TransparentWidget()
|
|
|
+ {
|
|
|
+ for (int i = 0; i < NUM_DISPLAYS; i++)
|
|
|
+ {
|
|
|
+ val[i] = nullptr;
|
|
|
+ }
|
|
|
+ box.size.y = 20 * NUM_DISPLAYS;
|
|
|
+ box.size.x = 100;
|
|
|
+ }
|
|
|
|
|
|
- for (int i = 0; i < NUM_DISPLAYS; i++)
|
|
|
- {
|
|
|
- texts[i] = string::f("%6.2f V", *val[i]);
|
|
|
- }
|
|
|
+ void draw(const DrawArgs &args) override
|
|
|
+ {
|
|
|
+ nvgFillColor(args.vg, nvgRGBf(0.0, 0.0, 0.0));
|
|
|
+ nvgBeginPath(args.vg);
|
|
|
+ nvgRect(args.vg, 0.0, 0.0, box.size.x, box.size.y);
|
|
|
+ nvgFill(args.vg);
|
|
|
+ }
|
|
|
|
|
|
- //text1 = "Yoman!";
|
|
|
+ void drawLayer(const DrawArgs &args, int layer) override
|
|
|
+ {
|
|
|
+ if (layer == 1)
|
|
|
+ {
|
|
|
+ std::string fontPath = asset::system("res/fonts/DejaVuSans.ttf");
|
|
|
+ std::shared_ptr<Font> font = APP->window->loadFont(fontPath);
|
|
|
|
|
|
- NVGcolor textColor = nvgRGB(0xf0, 0x00, 0x00);
|
|
|
- nvgFillColor(args.vg, textColor);
|
|
|
- for (int i = 0; i < NUM_DISPLAYS; i++)
|
|
|
+ if (font)
|
|
|
{
|
|
|
- nvgText(args.vg, 0, 15+i*20, texts[i].c_str(), NULL);
|
|
|
+ std::string texts[NUM_DISPLAYS];
|
|
|
+
|
|
|
+ for (int i = 0; i < NUM_DISPLAYS; i++)
|
|
|
+ {
|
|
|
+ if (val[i] != nullptr)
|
|
|
+ {
|
|
|
+ texts[i] = string::f("%6.2f V", *val[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // text1 = "Yoman!";
|
|
|
+
|
|
|
+ NVGcolor textColor = nvgRGB(0xf0, 0x00, 0x00);
|
|
|
+ nvgFillColor(args.vg, textColor);
|
|
|
+ for (int i = 0; i < NUM_DISPLAYS; i++)
|
|
|
+ {
|
|
|
+ nvgText(args.vg, 0, 15 + i * 20, texts[i].c_str(), NULL);
|
|
|
+ }
|
|
|
}
|
|
|
- } else {
|
|
|
- exit(0);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-struct SSI2164_Mixer1Widget : ModuleWidget {
|
|
|
- SSI2164_Mixer1Widget(SSI2164_Mixer1 *module) {
|
|
|
+struct SSI2164_Mixer1Widget : ModuleWidget
|
|
|
+{
|
|
|
+ SSI2164_Mixer1Widget(SSI2164_Mixer1 *module)
|
|
|
+ {
|
|
|
setModule(module);
|
|
|
setPanel(
|
|
|
createPanel(asset::plugin(pluginInstance, "res/SSI2164-Mixer1.svg")));
|
|
|
@@ -183,14 +226,16 @@ struct SSI2164_Mixer1Widget : ModuleWidget {
|
|
|
addParam(createParamCentered<VCVSlider>(mm2px(Vec(12, 101)), module,
|
|
|
SSI2164_Mixer1::CH1_FAD_PARAM));
|
|
|
|
|
|
- numberBox *myDisp = new numberBox;
|
|
|
- myDisp->setSize(Vec(100, 100));
|
|
|
- myDisp->box.pos = Vec(80, 50);
|
|
|
- for (int i = 0; i < NUM_DISPLAYS; i++)
|
|
|
+ if (module)
|
|
|
{
|
|
|
- myDisp->val[i] = &module->disp[i];
|
|
|
+ numberBox *myDisp = new numberBox;
|
|
|
+ myDisp->box.pos = Vec(80, 50);
|
|
|
+ for (int i = 0; i < NUM_DISPLAYS; i++)
|
|
|
+ {
|
|
|
+ myDisp->val[i] = &module->disp[i];
|
|
|
+ }
|
|
|
+ addChild(myDisp);
|
|
|
}
|
|
|
- addChild(myDisp);
|
|
|
|
|
|
addOutput(createOutputCentered<ThemedPJ301MPort>(
|
|
|
mm2px(Vec(141, 13)), module, SSI2164_Mixer1::AUX1_SEND_OUTPUT));
|