You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
4.7KB

  1. #include "XF.hpp"
  2. namespace rack_plugin_SubmarineFree {
  3. struct XF_104 : XF {
  4. static const int deviceCount = 4;
  5. enum ParamIds {
  6. PARAM_CV_1, PARAM_CV_2, PARAM_CV_3, PARAM_CV_4,
  7. PARAM_MODE_1, PARAM_MODE_2, PARAM_MODE_3, PARAM_MODE_4,
  8. PARAM_FADE_1, PARAM_FADE_2, PARAM_FADE_3, PARAM_FADE_4,
  9. PARAM_LINK_1, PARAM_LINK_2,
  10. NUM_PARAMS
  11. };
  12. enum InputIds {
  13. INPUT_A_1, INPUT_A_2, INPUT_A_3, INPUT_A_4,
  14. INPUT_B_1, INPUT_B_2, INPUT_B_3, INPUT_B_4,
  15. INPUT_CV_1, INPUT_CV_2, INPUT_CV_3, INPUT_CV_4,
  16. NUM_INPUTS
  17. };
  18. enum OutputIds {
  19. OUTPUT_1, OUTPUT_2, OUTPUT_3, OUTPUT_4,
  20. NUM_OUTPUTS
  21. };
  22. enum LightIds {
  23. LIGHT_LIN_1, LIGHT_LIN_2, LIGHT_LIN_3, LIGHT_LIN_4,
  24. LIGHT_LOG_1, LIGHT_LOG_2, LIGHT_LOG_3, LIGHT_LOG_4,
  25. LIGHT_AUTO_1, LIGHT_INV_1, LIGHT_AUTO_2, LIGHT_INV_2, LIGHT_AUTO_3, LIGHT_INV_3, LIGHT_AUTO_4, LIGHT_INV_4,
  26. NUM_LIGHTS
  27. };
  28. XF_Correlator correlators[deviceCount];
  29. XF_Controls controls[(int)(deviceCount * 1.5f)];
  30. XF_104() : XF(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {
  31. for (int i = 0; i < deviceCount; i++) {
  32. controls[i].a = INPUT_A_1 + i;
  33. controls[i].ar = 0;
  34. controls[i].b = INPUT_B_1 + i;
  35. controls[i].br = 0;
  36. controls[i].fader = PARAM_FADE_1 + i;
  37. controls[i].cv = INPUT_CV_1 + i;
  38. controls[i].out = OUTPUT_1 + i;
  39. controls[i].outr = 0;
  40. controls[i].polar = PARAM_CV_1 + i;
  41. controls[i].mode = PARAM_MODE_1 + i;
  42. controls[i].light1 = LIGHT_LIN_1 + i;
  43. controls[i].light2 = LIGHT_LOG_1 + i;
  44. controls[i].light3 = LIGHT_AUTO_1 + i * 2;
  45. controls[i].correlator = &correlators[i];
  46. }
  47. for (int i = 0; i < deviceCount / 2; i++) {
  48. int x = i * 2;
  49. controls[i + deviceCount].a = INPUT_A_1 + x;
  50. controls[i + deviceCount].ar = INPUT_A_2 + x;
  51. controls[i + deviceCount].b = INPUT_B_1 + x;
  52. controls[i + deviceCount].br = INPUT_B_2 + x;
  53. controls[i + deviceCount].fader = PARAM_FADE_1 + x;
  54. controls[i + deviceCount].cv = INPUT_CV_1 + x;
  55. controls[i + deviceCount].out = OUTPUT_1 + x;
  56. controls[i + deviceCount].outr = OUTPUT_2 + x;
  57. controls[i + deviceCount].polar = PARAM_CV_1 + x;
  58. controls[i + deviceCount].mode = PARAM_MODE_1 + x;
  59. controls[i + deviceCount].light1 = LIGHT_LIN_1 + x;
  60. controls[i + deviceCount].light2 = LIGHT_LOG_1 + x;
  61. controls[i + deviceCount].light3 = LIGHT_AUTO_1 + x * 2;
  62. controls[i + deviceCount].correlator = &correlators[x];
  63. }
  64. }
  65. void step() override;
  66. };
  67. void XF_104::step() {
  68. if (params[PARAM_LINK_1].value > 0.5f) {
  69. crossFade(&controls[4]);
  70. }
  71. else {
  72. crossFade(&controls[0]);
  73. crossFade(&controls[1]);
  74. }
  75. if (params[PARAM_LINK_2].value > 0.5f) {
  76. crossFade(&controls[5]);
  77. }
  78. else {
  79. crossFade(&controls[2]);
  80. crossFade(&controls[3]);
  81. }
  82. }
  83. struct XF104 : ModuleWidget {
  84. XF104(XF_104 *module) : ModuleWidget(module) {
  85. XF_LightKnob *fader;
  86. setPanel(SVG::load(assetPlugin(plugin, "res/XF-104.svg")));
  87. for (int i = 0; i < XF_104::deviceCount; i++) {
  88. int offset = 88 * i;
  89. addInput(Port::create<SilverPort>(Vec(27.5,18 + offset), Port::INPUT, module, XF_104::INPUT_A_1 + i));
  90. addInput(Port::create<SilverPort>(Vec(127.5,18 + offset), Port::INPUT, module, XF_104::INPUT_B_1 + i));
  91. addInput(Port::create<SilverPort>(Vec(27.5,74 + offset), Port::INPUT, module, XF_104::INPUT_CV_1 + i));
  92. addOutput(Port::create<SilverPort>(Vec(127.5,74 + offset), Port::OUTPUT, module, XF_104::OUTPUT_1 + i));
  93. addParam(ParamWidget::create<sub_sw_2>(Vec(41, 46 + offset), module, XF_104::PARAM_CV_1 + i, 0.0f, 1.0f, 0.0f));
  94. addParam(ParamWidget::create<sub_sw_3>(Vec(125, 43.5 + offset), module, XF_104::PARAM_MODE_1 + i, 0.0f, 2.0f, 0.0f));
  95. fader = ParamWidget::create<XF_LightKnob>(Vec(63, 31 + offset), module, XF_104::PARAM_FADE_1 + i, 0.0f, 10.0f, 5.0f);
  96. fader->cv = XF_104::INPUT_CV_1 + i;
  97. switch (i) {
  98. case 0:
  99. case 2:
  100. fader->link = 0;
  101. break;
  102. case 1:
  103. fader->link = XF_104::PARAM_LINK_1;
  104. break;
  105. case 3:
  106. fader->link = XF_104::PARAM_LINK_2;
  107. break;
  108. }
  109. addParam(fader);
  110. addChild(ModuleLightWidget::create<TinyLight<BlueLight>>(Vec(141, 47 + offset), module, XF_104::LIGHT_LIN_1 + i));
  111. addChild(ModuleLightWidget::create<TinyLight<BlueLight>>(Vec(141, 57 + offset), module, XF_104::LIGHT_LOG_1 + i));
  112. addChild(ModuleLightWidget::create<TinyLight<BlueRedLight>>(Vec(141, 67 + offset), module, XF_104::LIGHT_AUTO_1 + i * 2));
  113. }
  114. addParam(ParamWidget::create<sub_btn>(Vec(90, 94.5), module, XF_104::PARAM_LINK_1, 0.0f, 1.0f, 0.0f));
  115. addParam(ParamWidget::create<sub_btn>(Vec(90, 270.5), module, XF_104::PARAM_LINK_2, 0.0f, 1.0f, 0.0f));
  116. }
  117. };
  118. } // namespace rack_plugin_SubmarineFree
  119. using namespace rack_plugin_SubmarineFree;
  120. RACK_PLUGIN_MODEL_INIT(SubmarineFree, XF104) {
  121. Model *modelXF104 = Model::create<XF_104, XF104>("Submarine (Free)", "XF-104", "XF-104 Quad Mono Cross Fader", MIXER_TAG, QUAD_TAG);
  122. return modelXF104;
  123. }