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.

99 lines
3.5KB

  1. #include "XF.hpp"
  2. namespace rack_plugin_SubmarineFree {
  3. struct XF_202 : 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. NUM_PARAMS
  10. };
  11. enum InputIds {
  12. INPUT_A_1, INPUT_A_2,
  13. INPUT_AR_1, INPUT_AR_2,
  14. INPUT_B_1, INPUT_B_2,
  15. INPUT_BR_1, INPUT_BR_2,
  16. INPUT_CV_1, INPUT_CV_2,
  17. NUM_INPUTS
  18. };
  19. enum OutputIds {
  20. OUTPUT_1, OUTPUT_2,
  21. OUTPUTR_1, OUTPUTR_2,
  22. NUM_OUTPUTS
  23. };
  24. enum LightIds {
  25. LIGHT_LIN_1, LIGHT_LIN_2,
  26. LIGHT_LOG_1, LIGHT_LOG_2,
  27. LIGHT_AUTO_1, LIGHT_INV_1, LIGHT_AUTO_2, LIGHT_INV_2,
  28. NUM_LIGHTS
  29. };
  30. XF_Correlator correlators[deviceCount];
  31. XF_Controls controls[deviceCount];
  32. XF_202() : XF(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {
  33. for (int i = 0; i < deviceCount; i++) {
  34. controls[i].a = INPUT_A_1 + i;
  35. controls[i].ar = INPUT_AR_1 + i;
  36. controls[i].b = INPUT_B_1 + i;
  37. controls[i].br = INPUT_BR_1 + i;
  38. controls[i].fader = PARAM_FADE_1 + i;
  39. controls[i].cv = INPUT_CV_1 + i;
  40. controls[i].out = OUTPUT_1 + i;
  41. controls[i].outr = OUTPUTR_1 + i;
  42. controls[i].polar = PARAM_CV_1 + i;
  43. controls[i].mode = PARAM_MODE_1 + i;
  44. controls[i].light1 = LIGHT_LIN_1 + i;
  45. controls[i].light2 = LIGHT_LOG_1 + i;
  46. controls[i].light3 = LIGHT_AUTO_1 + i * 2;
  47. controls[i].correlator = &correlators[i];
  48. }
  49. }
  50. void step() override;
  51. };
  52. void XF_202::step() {
  53. crossFade(&controls[0]);
  54. crossFade(&controls[1]);
  55. }
  56. struct XF202 : ModuleWidget {
  57. XF202(XF_202 *module) : ModuleWidget(module) {
  58. XF_LightKnob *fader;
  59. setPanel(SVG::load(assetPlugin(plugin, "res/XF-202.svg")));
  60. for (int i = 0; i < XF_202::deviceCount; i++) {
  61. int offset = 176 * i;
  62. addInput(Port::create<sub_port>(Vec(3,18 + offset), Port::INPUT, module, XF_202::INPUT_A_1 + i));
  63. addInput(Port::create<sub_port_red>(Vec(3,45 + offset), Port::INPUT, module, XF_202::INPUT_AR_1 + i));
  64. addInput(Port::create<sub_port>(Vec(92,18 + offset), Port::INPUT, module, XF_202::INPUT_B_1 + i));
  65. addInput(Port::create<sub_port_red>(Vec(92,45 + offset), Port::INPUT, module, XF_202::INPUT_BR_1 + i));
  66. addInput(Port::create<sub_port>(Vec(3,120 + offset), Port::INPUT, module, XF_202::INPUT_CV_1 + i));
  67. addOutput(Port::create<sub_port>(Vec(92,93 + offset), Port::OUTPUT, module, XF_202::OUTPUT_1 + i));
  68. addOutput(Port::create<sub_port_red>(Vec(92,120 + offset), Port::OUTPUT, module, XF_202::OUTPUTR_1 + i));
  69. addParam(ParamWidget::create<sub_sw_2>(Vec(28, 154.5 + offset), module, XF_202::PARAM_CV_1 + i, 0.0f, 1.0f, 0.0f));
  70. addParam(ParamWidget::create<sub_sw_3>(Vec(65, 152 + offset), module, XF_202::PARAM_MODE_1 + i, 0.0f, 2.0f, 0.0f));
  71. fader = ParamWidget::create<XF_LightKnob>(Vec(33, 51 + offset), module, XF_202::PARAM_FADE_1 + i, 0.0f, 10.0f, 5.0f);
  72. fader->cv = XF_202::INPUT_CV_1 + i;
  73. fader->link = 0;
  74. addParam(fader);
  75. addChild(ModuleLightWidget::create<TinyLight<BlueLight>>(Vec(81, 156 + offset), module, XF_202::LIGHT_LIN_1 + i));
  76. addChild(ModuleLightWidget::create<TinyLight<BlueLight>>(Vec(81, 166 + offset), module, XF_202::LIGHT_LOG_1 + i));
  77. addChild(ModuleLightWidget::create<TinyLight<BlueRedLight>>(Vec(81, 176 + offset), module, XF_202::LIGHT_AUTO_1 + i * 2));
  78. }
  79. }
  80. };
  81. } // namespace rack_plugin_SubmarineFree
  82. using namespace rack_plugin_SubmarineFree;
  83. RACK_PLUGIN_MODEL_INIT(SubmarineFree, XF202) {
  84. Model *modelXF202 = Model::create<XF_202, XF202>("SubmarineFree", "XF-202", "XF-202 Dual Stereo Cross Fader", MIXER_TAG, DUAL_TAG);
  85. return modelXF202;
  86. }