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.

96 lines
5.1KB

  1. #include "plugin.hpp"
  2. struct Split : Module {
  3. enum ParamIds {
  4. NUM_PARAMS
  5. };
  6. enum InputIds {
  7. POLY_INPUT,
  8. NUM_INPUTS
  9. };
  10. enum OutputIds {
  11. ENUMS(MONO_OUTPUTS, 16),
  12. NUM_OUTPUTS
  13. };
  14. enum LightIds {
  15. ENUMS(CHANNEL_LIGHTS, 16),
  16. NUM_LIGHTS
  17. };
  18. dsp::ClockDivider lightDivider;
  19. Split() {
  20. config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
  21. lightDivider.setDivision(512);
  22. }
  23. void process(const ProcessArgs &args) override {
  24. for (int c = 0; c < 16; c++) {
  25. float v = inputs[POLY_INPUT].getVoltage(c);
  26. // To allow users to debug buggy modules, don't assume that undefined channel voltages are 0V.
  27. outputs[MONO_OUTPUTS + c].setVoltage(v);
  28. }
  29. // Set channel lights infrequently
  30. if (lightDivider.process()) {
  31. for (int c = 0; c < 16; c++) {
  32. bool active = (c < inputs[POLY_INPUT].getChannels());
  33. lights[CHANNEL_LIGHTS + c].setBrightness(active);
  34. }
  35. }
  36. }
  37. };
  38. struct SplitWidget : ModuleWidget {
  39. SplitWidget(Split *module) {
  40. setModule(module);
  41. setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Split.svg")));
  42. addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
  43. addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
  44. addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  45. addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  46. addInput(createInputCentered<PJ301MPort>(mm2px(Vec(6.77, 21.347)), module, Split::POLY_INPUT));
  47. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(6.771, 37.02)), module, Split::MONO_OUTPUTS + 0));
  48. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(6.771, 48.02)), module, Split::MONO_OUTPUTS + 1));
  49. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(6.77, 59.02)), module, Split::MONO_OUTPUTS + 2));
  50. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(6.77, 70.02)), module, Split::MONO_OUTPUTS + 3));
  51. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(6.77, 81.02)), module, Split::MONO_OUTPUTS + 4));
  52. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(6.77, 92.02)), module, Split::MONO_OUTPUTS + 5));
  53. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(6.771, 103.02)), module, Split::MONO_OUTPUTS + 6));
  54. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(6.771, 114.02)), module, Split::MONO_OUTPUTS + 7));
  55. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.275, 37.02)), module, Split::MONO_OUTPUTS + 8));
  56. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.275, 48.02)), module, Split::MONO_OUTPUTS + 9));
  57. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.274, 59.02)), module, Split::MONO_OUTPUTS + 10));
  58. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.274, 70.02)), module, Split::MONO_OUTPUTS + 11));
  59. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.274, 81.02)), module, Split::MONO_OUTPUTS + 12));
  60. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.274, 92.02)), module, Split::MONO_OUTPUTS + 13));
  61. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.275, 103.02)), module, Split::MONO_OUTPUTS + 14));
  62. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(18.275, 114.02)), module, Split::MONO_OUTPUTS + 15));
  63. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(15.276, 17.775)), module, Split::CHANNEL_LIGHTS + 0));
  64. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(17.275, 17.775)), module, Split::CHANNEL_LIGHTS + 1));
  65. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(19.275, 17.775)), module, Split::CHANNEL_LIGHTS + 2));
  66. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(21.275, 17.775)), module, Split::CHANNEL_LIGHTS + 3));
  67. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(15.276, 19.775)), module, Split::CHANNEL_LIGHTS + 4));
  68. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(17.275, 19.775)), module, Split::CHANNEL_LIGHTS + 5));
  69. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(19.275, 19.775)), module, Split::CHANNEL_LIGHTS + 6));
  70. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(21.275, 19.775)), module, Split::CHANNEL_LIGHTS + 7));
  71. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(15.276, 21.775)), module, Split::CHANNEL_LIGHTS + 8));
  72. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(17.275, 21.775)), module, Split::CHANNEL_LIGHTS + 9));
  73. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(19.275, 21.775)), module, Split::CHANNEL_LIGHTS + 10));
  74. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(21.276, 21.775)), module, Split::CHANNEL_LIGHTS + 11));
  75. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(15.276, 23.775)), module, Split::CHANNEL_LIGHTS + 12));
  76. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(17.275, 23.775)), module, Split::CHANNEL_LIGHTS + 13));
  77. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(19.275, 23.775)), module, Split::CHANNEL_LIGHTS + 14));
  78. addChild(createLightCentered<TinyLight<BlueLight>>(mm2px(Vec(21.276, 23.775)), module, Split::CHANNEL_LIGHTS + 15));
  79. }
  80. };
  81. Model *modelSplit = createModel<Split, SplitWidget>("Split");