Jonatan Gezelius 2 лет назад
Родитель
Сommit
7e132dc058
1 измененных файлов с 51 добавлено и 55 удалено
  1. 51 55
      src/SSI2164-Mixer1.cpp

+ 51 - 55
src/SSI2164-Mixer1.cpp

@@ -1,11 +1,10 @@
 #include "plugin.hpp"
 #include <componentlibrary.hpp>
 
-struct SSI2164_Mixer1 : Module
-{
-  float disp1, disp2, disp3;
-  enum ParamId
-  {
+#define NUM_DISPLAYS 9
+struct SSI2164_Mixer1 : Module {
+  float disp[NUM_DISPLAYS];
+  enum ParamId {
     CH1_AUX1_PARAM,
     CH1_AUX2_PARAM,
     CH1_PAN_PARAM,
@@ -13,8 +12,7 @@ struct SSI2164_Mixer1 : Module
     CH1_FAD_PARAM,
     PARAMS_LEN
   };
-  enum InputId
-  {
+  enum InputId {
     CH1_IN_INPUT,
     CH1_PAN_INPUT,
     AUX2_RETURN_R_INPUT,
@@ -22,8 +20,7 @@ struct SSI2164_Mixer1 : Module
     AUX1_RETURN_INPUT,
     INPUTS_LEN
   };
-  enum OutputId
-  {
+  enum OutputId {
     AUX2_SEND_L_OUTPUT,
     AUX1_SEND_OUTPUT,
     AUX2_SEND_R_OUTPUT,
@@ -31,20 +28,18 @@ 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, 0.f, 2100.f, .0f, "Pan", "mV");
+    configParam(CH1_PAN_PARAM, -1.f, 1.f, .0f, "Pan", "mV");
     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");
@@ -62,8 +57,7 @@ struct SSI2164_Mixer1 : Module
     configOutput(MASTER_OUT_R_OUTPUT, "Master R");
   }
 
-  void process(const ProcessArgs &args) override
-  {
+  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;
 
@@ -80,8 +74,9 @@ struct SSI2164_Mixer1 : Module
     pan_l_control = fmax(.0f, pan_cv * (2.5));
     pan_r_control = fmax(.0f, pan_cv * (-2.5));
 
-    disp1 = pan_l_control;
-    disp2 = pan_r_control;
+    disp[0] = pan_cv;
+    disp[1] = pan_l_control;
+    disp[2] = pan_r_control;
 
     aux1_cv = fad_control + aux1_control;
     aux2_l_cv = fad_control + pan_l_control + aux2_control;
@@ -89,6 +84,7 @@ struct SSI2164_Mixer1 : Module
     master_l_cv = fad_control + pan_l_control;
     master_r_cv = fad_control + pan_r_control;
 
+
     float ssi2164_cv = .0f, ssi2164_in = .0f, ssi2164_out = .0f;
     float ch1_in = inputs[CH1_IN_INPUT].getVoltage();
 
@@ -115,50 +111,49 @@ struct SSI2164_Mixer1 : Module
   }
 };
 
-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
-{
-  float *val1, *val2, *val3;
-  void draw(const DrawArgs &args) override
-  {
-    nvgFillColor(args.vg, nvgRGBf(1.0, 1.0, 0.0));
-    nvgBeginPath(args.vg);
-    nvgRect(args.vg, 0.0, 0.0, box.size.x, box.size.y);
-    nvgFill(args.vg);
+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)
-    {
-      std::string text1 = string::f("%6.2f V", *val1);
-      std::string text2 = string::f("%6.2f V", *val2);
-      std::string text3 = string::f("%6.2f V", *val3);
-
-      text1 = "Yoman!";
-
-      nvgFontFaceId(args.vg, font->handle);
-      nvgFontSize(args.vg, 16.0);
-      nvgTextAlign(args.vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE);
-      nvgStrokeColor(args.vg, nvgRGBf(0.0, 0.0, 0.0));
-      nvgText(args.vg, 10,10, text1.c_str(), NULL);
+    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];
+
+      for (int i = 0; i < NUM_DISPLAYS; i++)
+      {
+        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")));
@@ -175,10 +170,10 @@ struct SSI2164_Mixer1Widget : ModuleWidget
         mm2px(Vec(12, 17)), module, SSI2164_Mixer1::CH1_IN_INPUT));
     addInput(createInputCentered<ThemedPJ301MPort>(
         mm2px(Vec(12, 28)), module, SSI2164_Mixer1::CH1_PAN_INPUT));
-    addParam(createParamCentered<RoundBlackKnob>(
-        mm2px(Vec(12, 38)), module, SSI2164_Mixer1::CH1_AUX1_PARAM));
-    addParam(createParamCentered<RoundBlackKnob>(
-        mm2px(Vec(12, 49)), module, SSI2164_Mixer1::CH1_AUX2_PARAM));
+    addParam(createParamCentered<KnobPenis>(mm2px(Vec(12, 38)), module,
+                                            SSI2164_Mixer1::CH1_AUX1_PARAM));
+    addParam(createParamCentered<KnobPenis>(mm2px(Vec(12, 49)), module,
+                                            SSI2164_Mixer1::CH1_AUX2_PARAM));
     addParam(createParamCentered<KnobPenis>(mm2px(Vec(12, 59)), module,
                                             SSI2164_Mixer1::CH1_PAN_PARAM));
     addParam(createParamCentered<VCVLatch>(mm2px(Vec(12, 68)), module,
@@ -191,9 +186,10 @@ struct SSI2164_Mixer1Widget : ModuleWidget
     numberBox *myDisp = new numberBox;
     myDisp->setSize(Vec(100, 100));
     myDisp->box.pos = Vec(80, 50);
-    myDisp->val1 = &module->disp1;
-    myDisp->val2 = &module->disp2;
-    myDisp->val3 = &module->disp3;
+    for (int i = 0; i < NUM_DISPLAYS; i++)
+    {
+      myDisp->val[i] = &module->disp[i];
+    }
     addChild(myDisp);
 
     addOutput(createOutputCentered<ThemedPJ301MPort>(