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.

285 lines
7.6KB

  1. #include "Squinky.hpp"
  2. #ifdef _SUPER
  3. #include "WidgetComposite.h"
  4. #include "ctrl/SqWidgets.h"
  5. #include "ctrl/SqMenuItem.h"
  6. #include "Super.h"
  7. #include "ctrl/ToggleButton.h"
  8. #include "ctrl/SemitoneDisplay.h"
  9. #include "IMWidgets.hpp"
  10. #include <sstream>
  11. /**
  12. */
  13. struct SuperModule : Module
  14. {
  15. public:
  16. SuperModule();
  17. /**
  18. *
  19. * Overrides of Module functions
  20. */
  21. void step() override;
  22. void onSampleRateChange() override;
  23. Super<WidgetComposite> super;
  24. };
  25. void SuperModule::onSampleRateChange()
  26. {
  27. }
  28. SuperModule::SuperModule()
  29. : Module(super.NUM_PARAMS,
  30. super.NUM_INPUTS,
  31. super.NUM_OUTPUTS,
  32. super.NUM_LIGHTS),
  33. super(this)
  34. {
  35. onSampleRateChange();
  36. super.init();
  37. }
  38. void SuperModule::step()
  39. {
  40. super.step();
  41. }
  42. ////////////////////
  43. // module widget
  44. ////////////////////
  45. struct superWidget : ModuleWidget
  46. {
  47. superWidget(SuperModule *);
  48. Label* addLabel(const Vec& v, const char* str, const NVGcolor& color = COLOR_BLACK)
  49. {
  50. Label* label = new Label();
  51. label->box.pos = v;
  52. label->text = str;
  53. label->color = color;
  54. addChild(label);
  55. return label;
  56. }
  57. void step() override
  58. {
  59. semitoneDisplay.step();
  60. ModuleWidget::step();
  61. }
  62. void addPitchKnobs(SuperModule *);
  63. void addOtherKnobs(SuperModule *);
  64. void addJacks(SuperModule *);
  65. // Menu* createContextMenu() override;
  66. SemitoneDisplay semitoneDisplay;
  67. };
  68. // inline Menu* superWidget::createContextMenu()
  69. // {
  70. // Menu* theMenu = ModuleWidget::createContextMenu();
  71. // ManualMenuItem* manual = new ManualMenuItem(
  72. // "https://github.com/squinkylabs/SquinkyVCV/blob/master/docs/saws.md");
  73. // theMenu->addChild(manual);
  74. // return theMenu;
  75. // }
  76. const float col1 = 40;
  77. const float col2 = 110;
  78. const float row1 = 71;
  79. const float row2 = 134;
  80. const float row3 = 220;
  81. const float row4 = 250;
  82. const float jackRow1 = 290;
  83. const float jackRow2 = 332;
  84. const float labelOffsetBig = -40;
  85. const float labelOffsetSmall = -32;
  86. void superWidget::addPitchKnobs(SuperModule *)
  87. {
  88. // Octave
  89. auto oct = createParamCentered<Rogan1PSBlue>(
  90. Vec(col1, row1), module, Super<WidgetComposite>::OCTAVE_PARAM, -5, 4, 0);
  91. oct->snap = true;
  92. oct->smooth = false;
  93. addParam(oct);
  94. Label* l = addLabel(
  95. Vec(col1 - 23, row1 + labelOffsetBig),
  96. "Oct");
  97. semitoneDisplay.setOctLabel(l, Super<WidgetComposite>::OCTAVE_PARAM);
  98. // Semi
  99. auto semi = createParamCentered<Rogan1PSBlue>(
  100. Vec(col2, row1), module, Super<WidgetComposite>::SEMI_PARAM, -11, 11, 0);
  101. semi->snap = true;
  102. semi->smooth = false;
  103. addParam(semi);
  104. l = addLabel(
  105. Vec(col2 - 27, row1 + labelOffsetBig),
  106. "Semi");
  107. semitoneDisplay.setSemiLabel(l, Super<WidgetComposite>::SEMI_PARAM);
  108. // Fine
  109. addParam(createParamCentered<Rogan1PSBlue>(
  110. Vec(col1, row2), module, Super<WidgetComposite>::FINE_PARAM, -1, 1, 0));
  111. addLabel(
  112. Vec(col1 - 19,
  113. row2 + labelOffsetBig),
  114. "Fine");
  115. // FM
  116. addParam(createParamCentered<Rogan1PSBlue>(
  117. Vec(col2, row2), module, Super<WidgetComposite>::FM_PARAM, 0, 1, 0));
  118. addLabel(
  119. Vec(col2 - 15, row2 + labelOffsetBig),
  120. "FM");
  121. }
  122. void superWidget::addOtherKnobs(SuperModule *)
  123. {
  124. // Detune
  125. addParam(createParamCentered<Blue30Knob>(
  126. Vec(col1, row3), module, Super<WidgetComposite>::DETUNE_PARAM, -5, 5, 0));
  127. addLabel(
  128. Vec(col1 - 27, row3 + labelOffsetSmall),
  129. "Detune");
  130. addParam(createParamCentered<Trimpot>(
  131. Vec(col1, row4), module, Super<WidgetComposite>::DETUNE_TRIM_PARAM, -1, 1, 0));
  132. addParam(createParamCentered<Blue30Knob>(
  133. Vec(col2, row3), module, Super<WidgetComposite>::MIX_PARAM, -5, 5, 0));
  134. addLabel(
  135. Vec(col2 - 18, row3 + labelOffsetSmall),
  136. "Mix");
  137. addParam(createParamCentered<Trimpot>(
  138. Vec(col2, row4), module, Super<WidgetComposite>::MIX_TRIM_PARAM, -1, 1, 0));
  139. }
  140. const float jackX = 27;
  141. const float jackDx = 33;
  142. const float jackOffsetLabel = -30;
  143. const float jackLabelPoints = 11;
  144. void superWidget::addJacks(SuperModule *)
  145. {
  146. Label* l = nullptr;
  147. // first row
  148. addInput(createInputCentered<PJ301MPort>(
  149. Vec(jackX, jackRow1),
  150. module,
  151. Super<WidgetComposite>::DETUNE_INPUT));
  152. l = addLabel(
  153. Vec(jackX - 25, jackRow1 + jackOffsetLabel),
  154. "Detune");
  155. l->fontSize = jackLabelPoints;
  156. addInput(createInputCentered<PJ301MPort>(
  157. Vec(jackX + 3 * jackDx, jackRow1),
  158. module,
  159. Super<WidgetComposite>::MIX_INPUT));
  160. l = addLabel(
  161. Vec(jackX + 3 * jackDx - 15, jackRow1 + jackOffsetLabel),
  162. "Mix");
  163. l->fontSize = jackLabelPoints;
  164. // second row
  165. addInput(createInputCentered<PJ301MPort>(
  166. Vec(jackX, jackRow2),
  167. module,
  168. Super<WidgetComposite>::CV_INPUT));
  169. l = addLabel(
  170. Vec(jackX - 20, jackRow2 + jackOffsetLabel),
  171. "V/Oct");
  172. l->fontSize = jackLabelPoints;
  173. addInput(createInputCentered<PJ301MPort>(
  174. Vec(jackX + 1 * jackDx, jackRow2),
  175. module,
  176. Super<WidgetComposite>::TRIGGER_INPUT));
  177. l = addLabel(
  178. Vec(jackX + 1 * jackDx - 17, jackRow2 + jackOffsetLabel),
  179. "Trig");
  180. l->fontSize = jackLabelPoints;
  181. addInput(createInputCentered<PJ301MPort>(
  182. Vec(jackX + 2 * jackDx, jackRow2),
  183. module,
  184. Super<WidgetComposite>::FM_INPUT));
  185. l = addLabel(
  186. Vec(jackX + 2 * jackDx - 14, jackRow2 + jackOffsetLabel), "FM");
  187. l->fontSize = jackLabelPoints;
  188. addOutput(createOutputCentered<PJ301MPort>(
  189. Vec(jackX + 3 * jackDx, jackRow2),
  190. module,
  191. Super<WidgetComposite>::MAIN_OUTPUT));
  192. l = addLabel(
  193. Vec(jackX + 3 * jackDx - 18, jackRow2 + jackOffsetLabel),
  194. "Out", COLOR_WHITE);
  195. l->fontSize = jackLabelPoints;
  196. }
  197. /**
  198. * Widget constructor will describe my implementation structure and
  199. * provide meta-data.
  200. * This is not shared by all modules in the DLL, just one
  201. */
  202. superWidget::superWidget(SuperModule *module) :
  203. ModuleWidget(module),
  204. semitoneDisplay(module)
  205. {
  206. box.size = Vec(10 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT);
  207. {
  208. SVGPanel *panel = new SVGPanel();
  209. panel->box.size = box.size;
  210. panel->setBackground(SVG::load(assetPlugin(plugin, "res/super_panel.svg")));
  211. addChild(panel);
  212. // Is this really needed?
  213. auto border = new PanelBorderWidget();
  214. border->box = box;
  215. addChild(border);
  216. }
  217. addPitchKnobs(module);
  218. addOtherKnobs(module);
  219. addJacks(module);
  220. // the "classic" switch
  221. ToggleButton* tog = createParamCentered<ToggleButton>(
  222. Vec(83, 164),
  223. module,
  224. Super<WidgetComposite>::CLEAN_PARAM,
  225. 0.0f, 2, 0);
  226. tog->addSvg("res/clean-switch-01.svg");
  227. tog->addSvg("res/clean-switch-02.svg");
  228. tog->addSvg("res/clean-switch-03.svg");
  229. addParam(tog);
  230. // screws
  231. addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
  232. addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
  233. addChild(Widget::create<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  234. addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  235. }
  236. RACK_PLUGIN_MODEL_INIT(squinkylabs_plug1, Super) {
  237. Model *modelSuperModule = Model::create<SuperModule,
  238. superWidget>("Squinky Labs",
  239. "squinkylabs-super",
  240. "Saws: super saw VCO emulation", RANDOM_TAG);
  241. return modelSuperModule;
  242. }
  243. #endif