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.

117 lines
4.1KB

  1. #include "XF.hpp"
  2. namespace rack_plugin_SubmarineFree {
  3. struct XF_102 : XF {
  4. static const int deviceCount = 2;
  5. enum ParamIds {
  6. PARAM_CV_1, PARAM_CV_2,
  7. PARAM_MODE_1, PARAM_MODE_2,
  8. PARAM_FADE_1, PARAM_FADE_2,
  9. PARAM_LINK_1,
  10. NUM_PARAMS
  11. };
  12. enum InputIds {
  13. INPUT_A_1, INPUT_A_2,
  14. INPUT_B_1, INPUT_B_2,
  15. INPUT_CV_1, INPUT_CV_2,
  16. NUM_INPUTS
  17. };
  18. enum OutputIds {
  19. OUTPUT_1, OUTPUT_2,
  20. NUM_OUTPUTS
  21. };
  22. enum LightIds {
  23. LIGHT_LIN_1, LIGHT_LIN_2,
  24. LIGHT_LOG_1, LIGHT_LOG_2,
  25. LIGHT_AUTO_1, LIGHT_INV_1, LIGHT_AUTO_2, LIGHT_INV_2,
  26. NUM_LIGHTS
  27. };
  28. XF_Correlator correlators[deviceCount];
  29. XF_Controls controls[(int)(deviceCount * 1.5f)];
  30. XF_102() : 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_102::step() {
  68. if (params[PARAM_LINK_1].value > 0.5f) {
  69. crossFade(&controls[2]);
  70. }
  71. else {
  72. crossFade(&controls[0]);
  73. crossFade(&controls[1]);
  74. }
  75. }
  76. struct XF102 : ModuleWidget {
  77. XF102(XF_102 *module) : ModuleWidget(module) {
  78. XF_LightKnob *fader;
  79. setPanel(SVG::load(assetPlugin(plugin, "res/XF-102.svg")));
  80. for (int i = 0; i < XF_102::deviceCount; i++) {
  81. int offset = 88 * i;
  82. addInput(Port::create<sub_port>(Vec(27.5,18 + offset), Port::INPUT, module, XF_102::INPUT_A_1 + i));
  83. addInput(Port::create<sub_port>(Vec(127.5,18 + offset), Port::INPUT, module, XF_102::INPUT_B_1 + i));
  84. addInput(Port::create<sub_port>(Vec(27.5,74 + offset), Port::INPUT, module, XF_102::INPUT_CV_1 + i));
  85. addOutput(Port::create<sub_port>(Vec(127.5,74 + offset), Port::OUTPUT, module, XF_102::OUTPUT_1 + i));
  86. addParam(ParamWidget::create<sub_sw_2>(Vec(41, 46 + offset), module, XF_102::PARAM_CV_1 + i, 0.0f, 1.0f, 0.0f));
  87. addParam(ParamWidget::create<sub_sw_3>(Vec(125, 43.5 + offset), module, XF_102::PARAM_MODE_1 + i, 0.0f, 2.0f, 0.0f));
  88. fader = ParamWidget::create<XF_LightKnob>(Vec(63, 31 + offset), module, XF_102::PARAM_FADE_1 + i, 0.0f, 10.0f, 5.0f);
  89. fader->cv = XF_102::INPUT_CV_1 + i;
  90. fader->link = i?XF_102::PARAM_LINK_1:0;
  91. addParam(fader);
  92. addChild(ModuleLightWidget::create<TinyLight<BlueLight>>(Vec(141, 47 + offset), module, XF_102::LIGHT_LIN_1 + i));
  93. addChild(ModuleLightWidget::create<TinyLight<BlueLight>>(Vec(141, 57 + offset), module, XF_102::LIGHT_LOG_1 + i));
  94. addChild(ModuleLightWidget::create<TinyLight<BlueRedLight>>(Vec(141, 67 + offset), module, XF_102::LIGHT_AUTO_1 + i * 2));
  95. }
  96. addParam(ParamWidget::create<sub_btn>(Vec(90, 94.5), module, XF_102::PARAM_LINK_1, 0.0f, 1.0f, 0.0f));
  97. }
  98. };
  99. } // namespace rack_plugin_SubmarineFree
  100. using namespace rack_plugin_SubmarineFree;
  101. RACK_PLUGIN_MODEL_INIT(SubmarineFree, XF102) {
  102. Model *modelXF102 = Model::create<XF_102, XF102>("SubmarineFree", "XF-102", "XF-102 Dual Mono Cross Fader", MIXER_TAG, DUAL_TAG);
  103. return modelXF102;
  104. }