Audio plugin host https://kx.studio/carla
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.

SegmentJuiceUI.cpp 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. /*
  2. * Segment Juice Plugin
  3. * Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "SegmentJuiceUI.hpp"
  18. using DGL::Point;
  19. START_NAMESPACE_DISTRHO
  20. // -----------------------------------------------------------------------
  21. SegmentJuiceUI::SegmentJuiceUI()
  22. : UI(),
  23. fAboutWindow(this)
  24. {
  25. // background
  26. fImgBackground = Image(SegmentJuiceArtwork::backgroundData, SegmentJuiceArtwork::backgroundWidth, SegmentJuiceArtwork::backgroundHeight, GL_BGR);
  27. // about
  28. Image imageAbout(SegmentJuiceArtwork::aboutData, SegmentJuiceArtwork::aboutWidth, SegmentJuiceArtwork::aboutHeight, GL_BGR);
  29. fAboutWindow.setImage(imageAbout);
  30. // knobs
  31. Image knobImage(SegmentJuiceArtwork::knobData, SegmentJuiceArtwork::knobWidth, SegmentJuiceArtwork::knobHeight);
  32. // knobs2
  33. Image knobImage2(SegmentJuiceArtwork::knob2Data, SegmentJuiceArtwork::knob2Width, SegmentJuiceArtwork::knob2Height);
  34. // knob Wave1
  35. fKnobWave1 = new ImageKnob(this, knobImage);
  36. fKnobWave1->setAbsolutePos(446, 79);
  37. fKnobWave1->setRange(1.0f, 4.0f);
  38. fKnobWave1->setValue(0.3f);
  39. fKnobWave1->setRotationAngle(270);
  40. fKnobWave1->setCallback(this);
  41. // knob Wave2
  42. fKnobWave2 = new ImageKnob(this, knobImage);
  43. fKnobWave2->setAbsolutePos(446, 139);
  44. fKnobWave2->setRange(1.0f, 4.0f);
  45. fKnobWave2->setValue(3.0f);
  46. fKnobWave2->setRotationAngle(270);
  47. fKnobWave2->setCallback(this);
  48. // knob Wave3
  49. fKnobWave3 = new ImageKnob(this, knobImage);
  50. fKnobWave3->setAbsolutePos(446, 199);
  51. fKnobWave3->setRange(1.0f, 4.0f);
  52. fKnobWave3->setValue(3.0f);
  53. fKnobWave3->setRotationAngle(270);
  54. fKnobWave3->setCallback(this);
  55. // knob Wave4
  56. fKnobWave4 = new ImageKnob(this, knobImage);
  57. fKnobWave4->setAbsolutePos(446, 259);
  58. fKnobWave4->setRange(1.0f, 4.0f);
  59. fKnobWave4->setValue(3.0f);
  60. fKnobWave4->setRotationAngle(270);
  61. fKnobWave4->setCallback(this);
  62. // knob Wave5
  63. fKnobWave5 = new ImageKnob(this, knobImage);
  64. fKnobWave5->setAbsolutePos(446, 319);
  65. fKnobWave5->setRange(1.0f, 4.0f);
  66. fKnobWave5->setValue(3.0f);
  67. fKnobWave5->setRotationAngle(270);
  68. fKnobWave5->setCallback(this);
  69. // knob Wave6
  70. fKnobWave6 = new ImageKnob(this, knobImage);
  71. fKnobWave6->setAbsolutePos(446, 379);
  72. fKnobWave6->setRange(1.0f, 4.0f);
  73. fKnobWave6->setValue(3.0f);
  74. fKnobWave6->setRotationAngle(270);
  75. fKnobWave6->setCallback(this);
  76. // knob FM1
  77. fKnobFM1 = new ImageKnob(this, knobImage);
  78. fKnobFM1->setAbsolutePos(510, 79);
  79. fKnobFM1->setRange(0.0f, 1.0f);
  80. fKnobFM1->setValue(0.5f);
  81. fKnobFM1->setRotationAngle(270);
  82. fKnobFM1->setCallback(this);
  83. // knob FM2
  84. fKnobFM2 = new ImageKnob(this, knobImage);
  85. fKnobFM2->setAbsolutePos(510, 139);
  86. fKnobFM2->setRange(0.0f, 1.0f);
  87. fKnobFM2->setValue(0.5f);
  88. fKnobFM2->setRotationAngle(270);
  89. fKnobFM2->setCallback(this);
  90. // knob FM3
  91. fKnobFM3 = new ImageKnob(this, knobImage);
  92. fKnobFM3->setAbsolutePos(510, 199);
  93. fKnobFM3->setRange(0.0f, 1.0f);
  94. fKnobFM3->setValue(0.5f);
  95. fKnobFM3->setRotationAngle(270);
  96. fKnobFM3->setCallback(this);
  97. // knob FM4
  98. fKnobFM4 = new ImageKnob(this, knobImage);
  99. fKnobFM4->setAbsolutePos(510, 259);
  100. fKnobFM4->setRange(0.0f, 1.0f);
  101. fKnobFM4->setValue(0.5f);
  102. fKnobFM4->setRotationAngle(270);
  103. fKnobFM4->setCallback(this);
  104. // knob FM5
  105. fKnobFM5 = new ImageKnob(this, knobImage);
  106. fKnobFM5->setAbsolutePos(510, 319);
  107. fKnobFM5->setRange(0.0f, 1.0f);
  108. fKnobFM5->setValue(0.5f);
  109. fKnobFM5->setRotationAngle(270);
  110. fKnobFM5->setCallback(this);
  111. // knob FM6
  112. fKnobFM6 = new ImageKnob(this, knobImage);
  113. fKnobFM6->setAbsolutePos(510, 379);
  114. fKnobFM6->setRange(0.0f, 1.0f);
  115. fKnobFM6->setValue(0.5f);
  116. fKnobFM6->setRotationAngle(270);
  117. fKnobFM6->setCallback(this);
  118. // knob Pan1
  119. fKnobPan1 = new ImageKnob(this, knobImage);
  120. fKnobPan1->setAbsolutePos(574, 79);
  121. fKnobPan1->setRange(-1.0f, 1.0f);
  122. fKnobPan1->setValue(0.0f);
  123. fKnobPan1->setRotationAngle(270);
  124. fKnobPan1->setCallback(this);
  125. // knob Pan2
  126. fKnobPan2 = new ImageKnob(this, knobImage);
  127. fKnobPan2->setAbsolutePos(574, 139);
  128. fKnobPan2->setRange(-1.0f, 1.0f);
  129. fKnobPan2->setValue(0.0f);
  130. fKnobPan2->setRotationAngle(270);
  131. fKnobPan2->setCallback(this);
  132. // knob Pan3
  133. fKnobPan3 = new ImageKnob(this, knobImage);
  134. fKnobPan3->setAbsolutePos(574, 199);
  135. fKnobPan3->setRange(-1.0f, 1.0f);
  136. fKnobPan3->setValue(0.0f);
  137. fKnobPan3->setRotationAngle(270);
  138. fKnobPan3->setCallback(this);
  139. // knob Pan4
  140. fKnobPan4 = new ImageKnob(this, knobImage);
  141. fKnobPan4->setAbsolutePos(574, 259);
  142. fKnobPan4->setRange(-1.0f, 1.0f);
  143. fKnobPan4->setValue(0.0f);
  144. fKnobPan4->setRotationAngle(270);
  145. fKnobPan4->setCallback(this);
  146. // knob Pan5
  147. fKnobPan5 = new ImageKnob(this, knobImage);
  148. fKnobPan5->setAbsolutePos(574, 319);
  149. fKnobPan5->setRange(-1.0f, 1.0f);
  150. fKnobPan5->setValue(0.0f);
  151. fKnobPan5->setRotationAngle(270);
  152. fKnobPan5->setCallback(this);
  153. // knob Pan6
  154. fKnobPan6 = new ImageKnob(this, knobImage);
  155. fKnobPan6->setAbsolutePos(574, 379);
  156. fKnobPan6->setRange(-1.0f, 1.0f);
  157. fKnobPan6->setValue(0.0f);
  158. fKnobPan6->setRotationAngle(270);
  159. fKnobPan6->setCallback(this);
  160. // knob Amp1
  161. fKnobAmp1 = new ImageKnob(this, knobImage);
  162. fKnobAmp1->setAbsolutePos(638, 79);
  163. fKnobAmp1->setRange(0.0f, 1.0f);
  164. fKnobAmp1->setValue(0.5f);
  165. fKnobAmp1->setRotationAngle(270);
  166. fKnobAmp1->setCallback(this);
  167. // knob Amp2
  168. fKnobAmp2 = new ImageKnob(this, knobImage);
  169. fKnobAmp2->setAbsolutePos(638, 139);
  170. fKnobAmp2->setRange(0.0f, 1.0f);
  171. fKnobAmp2->setValue(0.5f);
  172. fKnobAmp2->setRotationAngle(270);
  173. fKnobAmp2->setCallback(this);
  174. // knob Amp3
  175. fKnobAmp3 = new ImageKnob(this, knobImage);
  176. fKnobAmp3->setAbsolutePos(638, 199);
  177. fKnobAmp3->setRange(0.0f, 1.0f);
  178. fKnobAmp3->setValue(0.5f);
  179. fKnobAmp3->setRotationAngle(270);
  180. fKnobAmp3->setCallback(this);
  181. // knob Amp4
  182. fKnobAmp4 = new ImageKnob(this, knobImage);
  183. fKnobAmp4->setAbsolutePos(638, 259);
  184. fKnobAmp4->setRange(0.0f, 1.0f);
  185. fKnobAmp4->setValue(0.5f);
  186. fKnobAmp4->setRotationAngle(270);
  187. fKnobAmp4->setCallback(this);
  188. // knob Amp5
  189. fKnobAmp5 = new ImageKnob(this, knobImage);
  190. fKnobAmp5->setAbsolutePos(638, 319);
  191. fKnobAmp5->setRange(0.0f, 1.0f);
  192. fKnobAmp5->setValue(0.5f);
  193. fKnobAmp5->setRotationAngle(270);
  194. fKnobAmp5->setCallback(this);
  195. // knob Amp6
  196. fKnobAmp6 = new ImageKnob(this, knobImage);
  197. fKnobAmp6->setAbsolutePos(638, 379);
  198. fKnobAmp6->setRange(0.0f, 1.0f);
  199. fKnobAmp6->setValue(0.5f);
  200. fKnobAmp6->setRotationAngle(270);
  201. fKnobAmp6->setCallback(this);
  202. // knob Attack
  203. fKnobAttack = new ImageKnob(this, knobImage2);
  204. fKnobAttack->setAbsolutePos(34, 248);
  205. fKnobAttack->setRange(0.0f, 1.0f);
  206. fKnobAttack->setValue(0.0f);
  207. fKnobAttack->setRotationAngle(270);
  208. fKnobAttack->setCallback(this);
  209. // knob Decay
  210. fKnobDecay = new ImageKnob(this, knobImage2);
  211. fKnobDecay->setAbsolutePos(132, 248);
  212. fKnobDecay->setRange(0.0f, 1.0f);
  213. fKnobDecay->setValue(0.0f);
  214. fKnobDecay->setRotationAngle(270);
  215. fKnobDecay->setCallback(this);
  216. // knob Sustain
  217. fKnobSustain = new ImageKnob(this, knobImage2);
  218. fKnobSustain->setAbsolutePos(232, 248);
  219. fKnobSustain->setRange(0.0f, 1.0f);
  220. fKnobSustain->setValue(1.0f);
  221. fKnobSustain->setRotationAngle(270);
  222. fKnobSustain->setCallback(this);
  223. // knob Release
  224. fKnobRelease = new ImageKnob(this, knobImage2);
  225. fKnobRelease->setAbsolutePos(330, 248);
  226. fKnobRelease->setRange(0.0f, 1.0f);
  227. fKnobRelease->setValue(0.0f);
  228. fKnobRelease->setRotationAngle(270);
  229. fKnobRelease->setCallback(this);
  230. // knob Stereo
  231. fKnobStereo = new ImageKnob(this, knobImage2);
  232. fKnobStereo->setAbsolutePos(34, 339);
  233. fKnobStereo->setRange(-1.0f, 1.0f);
  234. fKnobStereo->setValue(0.0f);
  235. fKnobStereo->setRotationAngle(270);
  236. fKnobStereo->setCallback(this);
  237. // knob Tune
  238. fKnobTune = new ImageKnob(this, knobImage2);
  239. fKnobTune->setAbsolutePos(132, 339);
  240. fKnobTune->setRange(-1.0f, 1.0f);
  241. fKnobTune->setValue(0.0f);
  242. fKnobTune->setRotationAngle(270);
  243. fKnobTune->setCallback(this);
  244. // knob Volume
  245. fKnobVolume = new ImageKnob(this, knobImage2);
  246. fKnobVolume->setAbsolutePos(232, 339);
  247. fKnobVolume->setRange(0.0f, 1.0f);
  248. fKnobVolume->setValue(0.5f);
  249. fKnobVolume->setRotationAngle(270);
  250. fKnobVolume->setCallback(this);
  251. // knob Glide
  252. fKnobGlide = new ImageKnob(this, knobImage2);
  253. fKnobGlide->setAbsolutePos(330, 339);
  254. fKnobGlide->setRange(0.0f, 1.0f);
  255. fKnobGlide->setValue(0.0f);
  256. fKnobGlide->setRotationAngle(270);
  257. fKnobGlide->setCallback(this);
  258. // about button
  259. Image aboutImageNormal(SegmentJuiceArtwork::aboutButtonNormalData, SegmentJuiceArtwork::aboutButtonNormalWidth, SegmentJuiceArtwork::aboutButtonNormalHeight);
  260. Image aboutImageHover(SegmentJuiceArtwork::aboutButtonHoverData, SegmentJuiceArtwork::aboutButtonHoverWidth, SegmentJuiceArtwork::aboutButtonHoverHeight);
  261. fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover);
  262. fButtonAbout->setAbsolutePos(599, 17);
  263. fButtonAbout->setCallback(this);
  264. // set default values
  265. d_programChanged(0);
  266. }
  267. void SegmentJuiceUI::updateSynth() {
  268. synthL.setWave(0, fKnobWave1->getValue());
  269. synthL.setWave(1, fKnobWave2->getValue());
  270. synthL.setWave(2, fKnobWave3->getValue());
  271. synthL.setWave(3, fKnobWave4->getValue());
  272. synthL.setWave(4, fKnobWave5->getValue());
  273. synthL.setWave(5, fKnobWave6->getValue());
  274. synthL.setFM(0, fKnobFM1->getValue());
  275. synthL.setFM(1, fKnobFM2->getValue());
  276. synthL.setFM(2, fKnobFM3->getValue());
  277. synthL.setFM(3, fKnobFM4->getValue());
  278. synthL.setFM(4, fKnobFM5->getValue());
  279. synthL.setFM(5, fKnobFM6->getValue());
  280. synthL.setPan(0, -fKnobPan1->getValue());
  281. synthL.setPan(1, -fKnobPan2->getValue());
  282. synthL.setPan(2, -fKnobPan3->getValue());
  283. synthL.setPan(3, -fKnobPan4->getValue());
  284. synthL.setPan(4, -fKnobPan5->getValue());
  285. synthL.setPan(5, -fKnobPan6->getValue());
  286. synthL.setAmp(0, fKnobAmp1->getValue());
  287. synthL.setAmp(1, fKnobAmp2->getValue());
  288. synthL.setAmp(2, fKnobAmp3->getValue());
  289. synthL.setAmp(3, fKnobAmp4->getValue());
  290. synthL.setAmp(4, fKnobAmp5->getValue());
  291. synthL.setAmp(5, fKnobAmp6->getValue());
  292. synthL.setMAmp(fKnobVolume->getValue());
  293. synthR.setWave(0, fKnobWave1->getValue());
  294. synthR.setWave(1, fKnobWave2->getValue());
  295. synthR.setWave(2, fKnobWave3->getValue());
  296. synthR.setWave(3, fKnobWave4->getValue());
  297. synthR.setWave(4, fKnobWave5->getValue());
  298. synthR.setWave(5, fKnobWave6->getValue());
  299. synthR.setFM(0, fKnobFM1->getValue());
  300. synthR.setFM(1, fKnobFM2->getValue());
  301. synthR.setFM(2, fKnobFM3->getValue());
  302. synthR.setFM(3, fKnobFM4->getValue());
  303. synthR.setFM(4, fKnobFM5->getValue());
  304. synthR.setFM(5, fKnobFM6->getValue());
  305. synthR.setPan(0, fKnobPan1->getValue());
  306. synthR.setPan(1, fKnobPan2->getValue());
  307. synthR.setPan(2, fKnobPan3->getValue());
  308. synthR.setPan(3, fKnobPan4->getValue());
  309. synthR.setPan(4, fKnobPan5->getValue());
  310. synthR.setPan(5, fKnobPan6->getValue());
  311. synthR.setAmp(0, fKnobAmp1->getValue());
  312. synthR.setAmp(1, fKnobAmp2->getValue());
  313. synthR.setAmp(2, fKnobAmp3->getValue());
  314. synthR.setAmp(3, fKnobAmp4->getValue());
  315. synthR.setAmp(4, fKnobAmp5->getValue());
  316. synthR.setAmp(5, fKnobAmp6->getValue());
  317. synthR.setMAmp(fKnobVolume->getValue());
  318. }
  319. // -----------------------------------------------------------------------
  320. // DSP Callbacks
  321. void SegmentJuiceUI::d_parameterChanged(uint32_t index, float value)
  322. {
  323. switch (index)
  324. {
  325. case SegmentJuicePlugin::paramWave1:
  326. fKnobWave1->setValue(value);
  327. break;
  328. case SegmentJuicePlugin::paramWave2:
  329. fKnobWave2->setValue(value);
  330. break;
  331. case SegmentJuicePlugin::paramWave3:
  332. fKnobWave3->setValue(value);
  333. break;
  334. case SegmentJuicePlugin::paramWave4:
  335. fKnobWave4->setValue(value);
  336. break;
  337. case SegmentJuicePlugin::paramWave5:
  338. fKnobWave5->setValue(value);
  339. break;
  340. case SegmentJuicePlugin::paramWave6:
  341. fKnobWave6->setValue(value);
  342. break;
  343. case SegmentJuicePlugin::paramFM1:
  344. fKnobFM1->setValue(value);
  345. break;
  346. case SegmentJuicePlugin::paramFM2:
  347. fKnobFM2->setValue(value);
  348. break;
  349. case SegmentJuicePlugin::paramFM3:
  350. fKnobFM3->setValue(value);
  351. break;
  352. case SegmentJuicePlugin::paramFM4:
  353. fKnobFM4->setValue(value);
  354. break;
  355. case SegmentJuicePlugin::paramFM5:
  356. fKnobFM5->setValue(value);
  357. break;
  358. case SegmentJuicePlugin::paramFM6:
  359. fKnobFM6->setValue(value);
  360. break;
  361. case SegmentJuicePlugin::paramPan1:
  362. fKnobPan1->setValue(value);
  363. break;
  364. case SegmentJuicePlugin::paramPan2:
  365. fKnobPan2->setValue(value);
  366. break;
  367. case SegmentJuicePlugin::paramPan3:
  368. fKnobPan3->setValue(value);
  369. break;
  370. case SegmentJuicePlugin::paramPan4:
  371. fKnobPan4->setValue(value);
  372. break;
  373. case SegmentJuicePlugin::paramPan5:
  374. fKnobPan5->setValue(value);
  375. break;
  376. case SegmentJuicePlugin::paramPan6:
  377. fKnobPan6->setValue(value);
  378. break;
  379. case SegmentJuicePlugin::paramAmp1:
  380. fKnobAmp1->setValue(value);
  381. break;
  382. case SegmentJuicePlugin::paramAmp2:
  383. fKnobAmp2->setValue(value);
  384. break;
  385. case SegmentJuicePlugin::paramAmp3:
  386. fKnobAmp3->setValue(value);
  387. break;
  388. case SegmentJuicePlugin::paramAmp4:
  389. fKnobAmp4->setValue(value);
  390. break;
  391. case SegmentJuicePlugin::paramAmp5:
  392. fKnobAmp5->setValue(value);
  393. break;
  394. case SegmentJuicePlugin::paramAmp6:
  395. fKnobAmp6->setValue(value);
  396. break;
  397. case SegmentJuicePlugin::paramAttack:
  398. fKnobAttack->setValue(value);
  399. break;
  400. case SegmentJuicePlugin::paramDecay:
  401. fKnobDecay->setValue(value);
  402. break;
  403. case SegmentJuicePlugin::paramSustain:
  404. fKnobSustain->setValue(value);
  405. break;
  406. case SegmentJuicePlugin::paramRelease:
  407. fKnobRelease->setValue(value);
  408. break;
  409. case SegmentJuicePlugin::paramStereo:
  410. fKnobStereo->setValue(value);
  411. break;
  412. case SegmentJuicePlugin::paramTune:
  413. fKnobTune->setValue(value);
  414. break;
  415. case SegmentJuicePlugin::paramVolume:
  416. fKnobVolume->setValue(value);
  417. break;
  418. case SegmentJuicePlugin::paramGlide:
  419. fKnobGlide->setValue(value);
  420. break;
  421. }
  422. updateSynth();
  423. }
  424. void SegmentJuiceUI::d_programChanged(uint32_t index)
  425. {
  426. if (index != 0)
  427. return;
  428. // Default values
  429. fKnobWave1->setValue(3.0f);
  430. fKnobWave2->setValue(3.0f);
  431. fKnobWave3->setValue(3.0f);
  432. fKnobWave6->setValue(3.0f);
  433. fKnobWave5->setValue(3.0f);
  434. fKnobWave6->setValue(3.0f);
  435. fKnobFM1->setValue(0.5f);
  436. fKnobFM2->setValue(0.5f);
  437. fKnobFM3->setValue(0.5f);
  438. fKnobFM6->setValue(0.5f);
  439. fKnobFM5->setValue(0.5f);
  440. fKnobFM6->setValue(0.5f);
  441. fKnobPan1->setValue(0.0f);
  442. fKnobPan2->setValue(0.0f);
  443. fKnobPan3->setValue(0.0f);
  444. fKnobPan6->setValue(0.0f);
  445. fKnobPan5->setValue(0.0f);
  446. fKnobPan6->setValue(0.0f);
  447. fKnobAmp1->setValue(0.5f);
  448. fKnobAmp2->setValue(0.5f);
  449. fKnobAmp3->setValue(0.5f);
  450. fKnobAmp6->setValue(0.5f);
  451. fKnobAmp5->setValue(0.5f);
  452. fKnobAmp6->setValue(0.5f);
  453. fKnobAttack->setValue(0.0f);
  454. fKnobDecay->setValue(0.0f);
  455. fKnobSustain->setValue(1.0f);
  456. fKnobRelease->setValue(0.0f);
  457. fKnobStereo->setValue(0.0f);
  458. fKnobTune->setValue(0.0f);
  459. fKnobVolume->setValue(0.5f);
  460. fKnobGlide->setValue(0.0f);
  461. for (int i=0; i<6; i++) {
  462. synthL.setFM(i, 0.5f);
  463. synthR.setFM(i, 0.5f);
  464. synthL.setPan(i, 0.0f);
  465. synthR.setPan(i, 0.0f);
  466. synthL.setAmp(i, 0.5f);
  467. synthR.setAmp(i, 0.5f);
  468. }
  469. synthL.setSampleRate(d_getSampleRate());
  470. synthR.setSampleRate(d_getSampleRate());
  471. synthL.setMAmp(0.5f);
  472. synthR.setMAmp(0.5f);
  473. synthL.play(69);
  474. synthR.play(69);
  475. synthL.setAttack(0);
  476. synthR.setAttack(0);
  477. synthL.setDecay(0);
  478. synthR.setDecay(0);
  479. synthL.setSustain(1);
  480. synthR.setSustain(1);
  481. synthL.setRelease(0);
  482. synthR.setRelease(0);
  483. synthL.setGlide(0);
  484. synthR.setGlide(0);
  485. synthL.setTune(0);
  486. synthR.setTune(0);
  487. }
  488. // -----------------------------------------------------------------------
  489. // Widget Callbacks
  490. void SegmentJuiceUI::imageButtonClicked(ImageButton* button, int)
  491. {
  492. if (button != fButtonAbout)
  493. return;
  494. fAboutWindow.exec();
  495. }
  496. void SegmentJuiceUI::imageKnobDragStarted(ImageKnob* knob)
  497. {
  498. if (knob == fKnobWave1)
  499. d_editParameter(SegmentJuicePlugin::paramWave1, true);
  500. else if (knob == fKnobWave2)
  501. d_editParameter(SegmentJuicePlugin::paramWave2, true);
  502. else if (knob == fKnobWave3)
  503. d_editParameter(SegmentJuicePlugin::paramWave3, true);
  504. else if (knob == fKnobWave4)
  505. d_editParameter(SegmentJuicePlugin::paramWave4, true);
  506. else if (knob == fKnobWave5)
  507. d_editParameter(SegmentJuicePlugin::paramWave5, true);
  508. else if (knob == fKnobWave6)
  509. d_editParameter(SegmentJuicePlugin::paramWave6, true);
  510. else if (knob == fKnobFM1)
  511. d_editParameter(SegmentJuicePlugin::paramFM1, true);
  512. else if (knob == fKnobFM2)
  513. d_editParameter(SegmentJuicePlugin::paramFM2, true);
  514. else if (knob == fKnobFM3)
  515. d_editParameter(SegmentJuicePlugin::paramFM3, true);
  516. else if (knob == fKnobFM4)
  517. d_editParameter(SegmentJuicePlugin::paramFM4, true);
  518. else if (knob == fKnobFM5)
  519. d_editParameter(SegmentJuicePlugin::paramFM5, true);
  520. else if (knob == fKnobFM6)
  521. d_editParameter(SegmentJuicePlugin::paramFM6, true);
  522. else if (knob == fKnobPan1)
  523. d_editParameter(SegmentJuicePlugin::paramPan1, true);
  524. else if (knob == fKnobPan2)
  525. d_editParameter(SegmentJuicePlugin::paramPan2, true);
  526. else if (knob == fKnobPan3)
  527. d_editParameter(SegmentJuicePlugin::paramPan3, true);
  528. else if (knob == fKnobPan4)
  529. d_editParameter(SegmentJuicePlugin::paramPan4, true);
  530. else if (knob == fKnobPan5)
  531. d_editParameter(SegmentJuicePlugin::paramPan5, true);
  532. else if (knob == fKnobPan6)
  533. d_editParameter(SegmentJuicePlugin::paramPan6, true);
  534. else if (knob == fKnobAmp1)
  535. d_editParameter(SegmentJuicePlugin::paramAmp1, true);
  536. else if (knob == fKnobAmp2)
  537. d_editParameter(SegmentJuicePlugin::paramAmp2, true);
  538. else if (knob == fKnobAmp3)
  539. d_editParameter(SegmentJuicePlugin::paramAmp3, true);
  540. else if (knob == fKnobAmp4)
  541. d_editParameter(SegmentJuicePlugin::paramAmp4, true);
  542. else if (knob == fKnobAmp5)
  543. d_editParameter(SegmentJuicePlugin::paramAmp5, true);
  544. else if (knob == fKnobAmp6)
  545. d_editParameter(SegmentJuicePlugin::paramAmp6, true);
  546. else if (knob == fKnobAttack)
  547. d_editParameter(SegmentJuicePlugin::paramAttack, true);
  548. else if (knob == fKnobDecay)
  549. d_editParameter(SegmentJuicePlugin::paramDecay, true);
  550. else if (knob == fKnobSustain)
  551. d_editParameter(SegmentJuicePlugin::paramSustain, true);
  552. else if (knob == fKnobRelease)
  553. d_editParameter(SegmentJuicePlugin::paramRelease, true);
  554. else if (knob == fKnobStereo)
  555. d_editParameter(SegmentJuicePlugin::paramStereo, true);
  556. else if (knob == fKnobTune)
  557. d_editParameter(SegmentJuicePlugin::paramTune, true);
  558. else if (knob == fKnobVolume)
  559. d_editParameter(SegmentJuicePlugin::paramVolume, true);
  560. else if (knob == fKnobGlide)
  561. d_editParameter(SegmentJuicePlugin::paramGlide, true);
  562. }
  563. void SegmentJuiceUI::imageKnobDragFinished(ImageKnob* knob)
  564. {
  565. if (knob == fKnobWave1)
  566. d_editParameter(SegmentJuicePlugin::paramWave1, false);
  567. else if (knob == fKnobWave2)
  568. d_editParameter(SegmentJuicePlugin::paramWave2, false);
  569. else if (knob == fKnobWave3)
  570. d_editParameter(SegmentJuicePlugin::paramWave3, false);
  571. else if (knob == fKnobWave4)
  572. d_editParameter(SegmentJuicePlugin::paramWave4, false);
  573. else if (knob == fKnobWave5)
  574. d_editParameter(SegmentJuicePlugin::paramWave5, false);
  575. else if (knob == fKnobWave6)
  576. d_editParameter(SegmentJuicePlugin::paramWave6, false);
  577. else if (knob == fKnobFM1)
  578. d_editParameter(SegmentJuicePlugin::paramFM1, false);
  579. else if (knob == fKnobFM2)
  580. d_editParameter(SegmentJuicePlugin::paramFM2, false);
  581. else if (knob == fKnobFM3)
  582. d_editParameter(SegmentJuicePlugin::paramFM3, false);
  583. else if (knob == fKnobFM4)
  584. d_editParameter(SegmentJuicePlugin::paramFM4, false);
  585. else if (knob == fKnobFM5)
  586. d_editParameter(SegmentJuicePlugin::paramFM5, false);
  587. else if (knob == fKnobFM6)
  588. d_editParameter(SegmentJuicePlugin::paramFM6, false);
  589. else if (knob == fKnobPan1)
  590. d_editParameter(SegmentJuicePlugin::paramPan1, false);
  591. else if (knob == fKnobPan2)
  592. d_editParameter(SegmentJuicePlugin::paramPan2, false);
  593. else if (knob == fKnobPan3)
  594. d_editParameter(SegmentJuicePlugin::paramPan3, false);
  595. else if (knob == fKnobPan4)
  596. d_editParameter(SegmentJuicePlugin::paramPan4, false);
  597. else if (knob == fKnobPan5)
  598. d_editParameter(SegmentJuicePlugin::paramPan5, false);
  599. else if (knob == fKnobPan6)
  600. d_editParameter(SegmentJuicePlugin::paramPan6, false);
  601. else if (knob == fKnobAmp1)
  602. d_editParameter(SegmentJuicePlugin::paramAmp1, false);
  603. else if (knob == fKnobAmp2)
  604. d_editParameter(SegmentJuicePlugin::paramAmp2, false);
  605. else if (knob == fKnobAmp3)
  606. d_editParameter(SegmentJuicePlugin::paramAmp3, false);
  607. else if (knob == fKnobAmp4)
  608. d_editParameter(SegmentJuicePlugin::paramAmp4, false);
  609. else if (knob == fKnobAmp5)
  610. d_editParameter(SegmentJuicePlugin::paramAmp5, false);
  611. else if (knob == fKnobAmp6)
  612. d_editParameter(SegmentJuicePlugin::paramAmp6, false);
  613. else if (knob == fKnobAttack)
  614. d_editParameter(SegmentJuicePlugin::paramAttack, false);
  615. else if (knob == fKnobDecay)
  616. d_editParameter(SegmentJuicePlugin::paramDecay, false);
  617. else if (knob == fKnobSustain)
  618. d_editParameter(SegmentJuicePlugin::paramSustain, false);
  619. else if (knob == fKnobRelease)
  620. d_editParameter(SegmentJuicePlugin::paramRelease, false);
  621. else if (knob == fKnobStereo)
  622. d_editParameter(SegmentJuicePlugin::paramStereo, false);
  623. else if (knob == fKnobTune)
  624. d_editParameter(SegmentJuicePlugin::paramTune, false);
  625. else if (knob == fKnobVolume)
  626. d_editParameter(SegmentJuicePlugin::paramVolume, false);
  627. else if (knob == fKnobGlide)
  628. d_editParameter(SegmentJuicePlugin::paramGlide, false);
  629. }
  630. void SegmentJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value)
  631. {
  632. if (knob == fKnobWave1)
  633. d_setParameterValue(SegmentJuicePlugin::paramWave1, value);
  634. else if (knob == fKnobWave2)
  635. d_setParameterValue(SegmentJuicePlugin::paramWave2, value);
  636. else if (knob == fKnobWave3)
  637. d_setParameterValue(SegmentJuicePlugin::paramWave3, value);
  638. else if (knob == fKnobWave4)
  639. d_setParameterValue(SegmentJuicePlugin::paramWave4, value);
  640. else if (knob == fKnobWave5)
  641. d_setParameterValue(SegmentJuicePlugin::paramWave5, value);
  642. else if (knob == fKnobWave6)
  643. d_setParameterValue(SegmentJuicePlugin::paramWave6, value);
  644. else if (knob == fKnobFM1)
  645. d_setParameterValue(SegmentJuicePlugin::paramFM1, value);
  646. else if (knob == fKnobFM2)
  647. d_setParameterValue(SegmentJuicePlugin::paramFM2, value);
  648. else if (knob == fKnobFM3)
  649. d_setParameterValue(SegmentJuicePlugin::paramFM3, value);
  650. else if (knob == fKnobFM4)
  651. d_setParameterValue(SegmentJuicePlugin::paramFM4, value);
  652. else if (knob == fKnobFM5)
  653. d_setParameterValue(SegmentJuicePlugin::paramFM5, value);
  654. else if (knob == fKnobFM6)
  655. d_setParameterValue(SegmentJuicePlugin::paramFM6, value);
  656. else if (knob == fKnobPan1)
  657. d_setParameterValue(SegmentJuicePlugin::paramPan1, value);
  658. else if (knob == fKnobPan2)
  659. d_setParameterValue(SegmentJuicePlugin::paramPan2, value);
  660. else if (knob == fKnobPan3)
  661. d_setParameterValue(SegmentJuicePlugin::paramPan3, value);
  662. else if (knob == fKnobPan4)
  663. d_setParameterValue(SegmentJuicePlugin::paramPan4, value);
  664. else if (knob == fKnobPan5)
  665. d_setParameterValue(SegmentJuicePlugin::paramPan5, value);
  666. else if (knob == fKnobPan6)
  667. d_setParameterValue(SegmentJuicePlugin::paramPan6, value);
  668. else if (knob == fKnobAmp1)
  669. d_setParameterValue(SegmentJuicePlugin::paramAmp1, value);
  670. else if (knob == fKnobAmp2)
  671. d_setParameterValue(SegmentJuicePlugin::paramAmp2, value);
  672. else if (knob == fKnobAmp3)
  673. d_setParameterValue(SegmentJuicePlugin::paramAmp3, value);
  674. else if (knob == fKnobAmp4)
  675. d_setParameterValue(SegmentJuicePlugin::paramAmp4, value);
  676. else if (knob == fKnobAmp5)
  677. d_setParameterValue(SegmentJuicePlugin::paramAmp5, value);
  678. else if (knob == fKnobAmp6)
  679. d_setParameterValue(SegmentJuicePlugin::paramAmp6, value);
  680. else if (knob == fKnobAttack)
  681. d_setParameterValue(SegmentJuicePlugin::paramAttack, value);
  682. else if (knob == fKnobDecay)
  683. d_setParameterValue(SegmentJuicePlugin::paramDecay, value);
  684. else if (knob == fKnobSustain)
  685. d_setParameterValue(SegmentJuicePlugin::paramSustain, value);
  686. else if (knob == fKnobRelease)
  687. d_setParameterValue(SegmentJuicePlugin::paramRelease, value);
  688. else if (knob == fKnobStereo)
  689. d_setParameterValue(SegmentJuicePlugin::paramStereo, value);
  690. else if (knob == fKnobTune)
  691. d_setParameterValue(SegmentJuicePlugin::paramTune, value);
  692. else if (knob == fKnobVolume)
  693. d_setParameterValue(SegmentJuicePlugin::paramVolume, value);
  694. else if (knob == fKnobGlide)
  695. d_setParameterValue(SegmentJuicePlugin::paramGlide, value);
  696. updateSynth();
  697. }
  698. void SegmentJuiceUI::onDisplay()
  699. {
  700. fImgBackground.draw();
  701. int cX = 23+4;
  702. int cY = 50;
  703. int cW = 388-cX-3;
  704. int cH = 216-cY;
  705. //draw waveform
  706. synthL.play(71);
  707. synthR.play(71);
  708. //glEnable(GL_BLEND);
  709. //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  710. //glEnable( GL_LINE_SMOOTH );
  711. //glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
  712. glLineWidth(1.0f);
  713. //draw #left waveform
  714. glColor4f(0.0f, 1.0f, 0.0f, 0.5f);
  715. glBegin(GL_LINE_STRIP);
  716. for (int i = 0; i<cW; i++) {
  717. float out = synthL.run()*cH/2+cH/2+cY;
  718. glVertex2i(i+cX, out);
  719. std::cout << out << std::endl;
  720. }
  721. //draw #right waveform
  722. glEnd();
  723. glColor4f(0.0f, 0.0f, 1.0f, 0.5f);
  724. glBegin(GL_LINE_STRIP);
  725. for (int i = 0; i<cW; i++) {
  726. glVertex2i(i+cX, synthR.run()*cH/2+cH/2+cY);
  727. }
  728. glEnd();
  729. //draw 0dc line
  730. glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
  731. glBegin(GL_LINES);
  732. glVertex2i(cX, cY+cH/2);
  733. glVertex2i(cX+cW, cY+cH/2);
  734. glEnd();
  735. glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  736. }
  737. // -----------------------------------------------------------------------
  738. UI* createUI()
  739. {
  740. return new SegmentJuiceUI();
  741. }
  742. // -----------------------------------------------------------------------
  743. END_NAMESPACE_DISTRHO