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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  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. }
  265. void SegmentJuiceUI::updateSynth() {
  266. synthL.setWave(0, fKnobWave1->getValue());
  267. synthL.setWave(1, fKnobWave2->getValue());
  268. synthL.setWave(2, fKnobWave3->getValue());
  269. synthL.setWave(3, fKnobWave4->getValue());
  270. synthL.setWave(4, fKnobWave5->getValue());
  271. synthL.setWave(5, fKnobWave6->getValue());
  272. synthL.setFM(0, fKnobFM1->getValue());
  273. synthL.setFM(1, fKnobFM2->getValue());
  274. synthL.setFM(2, fKnobFM3->getValue());
  275. synthL.setFM(3, fKnobFM4->getValue());
  276. synthL.setFM(4, fKnobFM5->getValue());
  277. synthL.setFM(5, fKnobFM6->getValue());
  278. synthL.setPan(0, -fKnobPan1->getValue());
  279. synthL.setPan(1, -fKnobPan2->getValue());
  280. synthL.setPan(2, -fKnobPan3->getValue());
  281. synthL.setPan(3, -fKnobPan4->getValue());
  282. synthL.setPan(4, -fKnobPan5->getValue());
  283. synthL.setPan(5, -fKnobPan6->getValue());
  284. synthL.setAmp(0, fKnobAmp1->getValue());
  285. synthL.setAmp(1, fKnobAmp2->getValue());
  286. synthL.setAmp(2, fKnobAmp3->getValue());
  287. synthL.setAmp(3, fKnobAmp4->getValue());
  288. synthL.setAmp(4, fKnobAmp5->getValue());
  289. synthL.setAmp(5, fKnobAmp6->getValue());
  290. synthL.setMAmp(fKnobVolume->getValue());
  291. synthR.setWave(0, fKnobWave1->getValue());
  292. synthR.setWave(1, fKnobWave2->getValue());
  293. synthR.setWave(2, fKnobWave3->getValue());
  294. synthR.setWave(3, fKnobWave4->getValue());
  295. synthR.setWave(4, fKnobWave5->getValue());
  296. synthR.setWave(5, fKnobWave6->getValue());
  297. synthR.setFM(0, fKnobFM1->getValue());
  298. synthR.setFM(1, fKnobFM2->getValue());
  299. synthR.setFM(2, fKnobFM3->getValue());
  300. synthR.setFM(3, fKnobFM4->getValue());
  301. synthR.setFM(4, fKnobFM5->getValue());
  302. synthR.setFM(5, fKnobFM6->getValue());
  303. synthR.setPan(0, fKnobPan1->getValue());
  304. synthR.setPan(1, fKnobPan2->getValue());
  305. synthR.setPan(2, fKnobPan3->getValue());
  306. synthR.setPan(3, fKnobPan4->getValue());
  307. synthR.setPan(4, fKnobPan5->getValue());
  308. synthR.setPan(5, fKnobPan6->getValue());
  309. synthR.setAmp(0, fKnobAmp1->getValue());
  310. synthR.setAmp(1, fKnobAmp2->getValue());
  311. synthR.setAmp(2, fKnobAmp3->getValue());
  312. synthR.setAmp(3, fKnobAmp4->getValue());
  313. synthR.setAmp(4, fKnobAmp5->getValue());
  314. synthR.setAmp(5, fKnobAmp6->getValue());
  315. synthR.setMAmp(fKnobVolume->getValue());
  316. }
  317. // -----------------------------------------------------------------------
  318. // DSP Callbacks
  319. void SegmentJuiceUI::d_parameterChanged(uint32_t index, float value)
  320. {
  321. switch (index)
  322. {
  323. case SegmentJuicePlugin::paramWave1:
  324. fKnobWave1->setValue(value);
  325. break;
  326. case SegmentJuicePlugin::paramWave2:
  327. fKnobWave2->setValue(value);
  328. break;
  329. case SegmentJuicePlugin::paramWave3:
  330. fKnobWave3->setValue(value);
  331. break;
  332. case SegmentJuicePlugin::paramWave4:
  333. fKnobWave4->setValue(value);
  334. break;
  335. case SegmentJuicePlugin::paramWave5:
  336. fKnobWave5->setValue(value);
  337. break;
  338. case SegmentJuicePlugin::paramWave6:
  339. fKnobWave6->setValue(value);
  340. break;
  341. case SegmentJuicePlugin::paramFM1:
  342. fKnobFM1->setValue(value);
  343. break;
  344. case SegmentJuicePlugin::paramFM2:
  345. fKnobFM2->setValue(value);
  346. break;
  347. case SegmentJuicePlugin::paramFM3:
  348. fKnobFM3->setValue(value);
  349. break;
  350. case SegmentJuicePlugin::paramFM4:
  351. fKnobFM4->setValue(value);
  352. break;
  353. case SegmentJuicePlugin::paramFM5:
  354. fKnobFM5->setValue(value);
  355. break;
  356. case SegmentJuicePlugin::paramFM6:
  357. fKnobFM6->setValue(value);
  358. break;
  359. case SegmentJuicePlugin::paramPan1:
  360. fKnobPan1->setValue(value);
  361. break;
  362. case SegmentJuicePlugin::paramPan2:
  363. fKnobPan2->setValue(value);
  364. break;
  365. case SegmentJuicePlugin::paramPan3:
  366. fKnobPan3->setValue(value);
  367. break;
  368. case SegmentJuicePlugin::paramPan4:
  369. fKnobPan4->setValue(value);
  370. break;
  371. case SegmentJuicePlugin::paramPan5:
  372. fKnobPan5->setValue(value);
  373. break;
  374. case SegmentJuicePlugin::paramPan6:
  375. fKnobPan6->setValue(value);
  376. break;
  377. case SegmentJuicePlugin::paramAmp1:
  378. fKnobAmp1->setValue(value);
  379. break;
  380. case SegmentJuicePlugin::paramAmp2:
  381. fKnobAmp2->setValue(value);
  382. break;
  383. case SegmentJuicePlugin::paramAmp3:
  384. fKnobAmp3->setValue(value);
  385. break;
  386. case SegmentJuicePlugin::paramAmp4:
  387. fKnobAmp4->setValue(value);
  388. break;
  389. case SegmentJuicePlugin::paramAmp5:
  390. fKnobAmp5->setValue(value);
  391. break;
  392. case SegmentJuicePlugin::paramAmp6:
  393. fKnobAmp6->setValue(value);
  394. break;
  395. case SegmentJuicePlugin::paramAttack:
  396. fKnobAttack->setValue(value);
  397. break;
  398. case SegmentJuicePlugin::paramDecay:
  399. fKnobDecay->setValue(value);
  400. break;
  401. case SegmentJuicePlugin::paramSustain:
  402. fKnobSustain->setValue(value);
  403. break;
  404. case SegmentJuicePlugin::paramRelease:
  405. fKnobRelease->setValue(value);
  406. break;
  407. case SegmentJuicePlugin::paramStereo:
  408. fKnobStereo->setValue(value);
  409. break;
  410. case SegmentJuicePlugin::paramTune:
  411. fKnobTune->setValue(value);
  412. break;
  413. case SegmentJuicePlugin::paramVolume:
  414. fKnobVolume->setValue(value);
  415. break;
  416. case SegmentJuicePlugin::paramGlide:
  417. fKnobGlide->setValue(value);
  418. break;
  419. }
  420. updateSynth();
  421. }
  422. void SegmentJuiceUI::d_programChanged(uint32_t index)
  423. {
  424. if (index != 0)
  425. return;
  426. // Default values
  427. fKnobWave1->setValue(3.0f);
  428. fKnobWave2->setValue(3.0f);
  429. fKnobWave3->setValue(3.0f);
  430. fKnobWave6->setValue(3.0f);
  431. fKnobWave5->setValue(3.0f);
  432. fKnobWave6->setValue(3.0f);
  433. fKnobFM1->setValue(0.5f);
  434. fKnobFM2->setValue(0.5f);
  435. fKnobFM3->setValue(0.5f);
  436. fKnobFM6->setValue(0.5f);
  437. fKnobFM5->setValue(0.5f);
  438. fKnobFM6->setValue(0.5f);
  439. fKnobPan1->setValue(0.0f);
  440. fKnobPan2->setValue(0.0f);
  441. fKnobPan3->setValue(0.0f);
  442. fKnobPan6->setValue(0.0f);
  443. fKnobPan5->setValue(0.0f);
  444. fKnobPan6->setValue(0.0f);
  445. fKnobAmp1->setValue(0.5f);
  446. fKnobAmp2->setValue(0.5f);
  447. fKnobAmp3->setValue(0.5f);
  448. fKnobAmp6->setValue(0.5f);
  449. fKnobAmp5->setValue(0.5f);
  450. fKnobAmp6->setValue(0.5f);
  451. fKnobAttack->setValue(0.0f);
  452. fKnobDecay->setValue(0.0f);
  453. fKnobSustain->setValue(1.0f);
  454. fKnobRelease->setValue(0.0f);
  455. fKnobStereo->setValue(0.0f);
  456. fKnobTune->setValue(0.0f);
  457. fKnobVolume->setValue(0.5f);
  458. fKnobGlide->setValue(0.0f);
  459. for (int i=0; i<6; i++) {
  460. synthL.setFM(i, 0.5f);
  461. synthR.setFM(i, 0.5f);
  462. synthL.setPan(i, 0.0f);
  463. synthR.setPan(i, 0.0f);
  464. synthL.setAmp(i, 0.5f);
  465. synthR.setAmp(i, 0.5f);
  466. }
  467. synthL.setSampleRate(d_getSampleRate());
  468. synthR.setSampleRate(d_getSampleRate());
  469. synthL.setMAmp(0.5f);
  470. synthR.setMAmp(0.5f);
  471. synthL.play(69);
  472. synthR.play(69);
  473. synthL.setAttack(0);
  474. synthR.setAttack(0);
  475. synthL.setDecay(0);
  476. synthR.setDecay(0);
  477. synthL.setSustain(1);
  478. synthR.setSustain(1);
  479. synthL.setRelease(0);
  480. synthR.setRelease(0);
  481. synthL.setGlide(0);
  482. synthR.setGlide(0);
  483. synthL.setTune(0);
  484. synthR.setTune(0);
  485. }
  486. // -----------------------------------------------------------------------
  487. // Widget Callbacks
  488. void SegmentJuiceUI::imageButtonClicked(ImageButton* button, int)
  489. {
  490. if (button != fButtonAbout)
  491. return;
  492. fAboutWindow.exec();
  493. }
  494. void SegmentJuiceUI::imageKnobDragStarted(ImageKnob* knob)
  495. {
  496. if (knob == fKnobWave1)
  497. d_editParameter(SegmentJuicePlugin::paramWave1, true);
  498. else if (knob == fKnobWave2)
  499. d_editParameter(SegmentJuicePlugin::paramWave2, true);
  500. else if (knob == fKnobWave3)
  501. d_editParameter(SegmentJuicePlugin::paramWave3, true);
  502. else if (knob == fKnobWave4)
  503. d_editParameter(SegmentJuicePlugin::paramWave4, true);
  504. else if (knob == fKnobWave5)
  505. d_editParameter(SegmentJuicePlugin::paramWave5, true);
  506. else if (knob == fKnobWave6)
  507. d_editParameter(SegmentJuicePlugin::paramWave6, true);
  508. else if (knob == fKnobFM1)
  509. d_editParameter(SegmentJuicePlugin::paramFM1, true);
  510. else if (knob == fKnobFM2)
  511. d_editParameter(SegmentJuicePlugin::paramFM2, true);
  512. else if (knob == fKnobFM3)
  513. d_editParameter(SegmentJuicePlugin::paramFM3, true);
  514. else if (knob == fKnobFM4)
  515. d_editParameter(SegmentJuicePlugin::paramFM4, true);
  516. else if (knob == fKnobFM5)
  517. d_editParameter(SegmentJuicePlugin::paramFM5, true);
  518. else if (knob == fKnobFM6)
  519. d_editParameter(SegmentJuicePlugin::paramFM6, true);
  520. else if (knob == fKnobPan1)
  521. d_editParameter(SegmentJuicePlugin::paramPan1, true);
  522. else if (knob == fKnobPan2)
  523. d_editParameter(SegmentJuicePlugin::paramPan2, true);
  524. else if (knob == fKnobPan3)
  525. d_editParameter(SegmentJuicePlugin::paramPan3, true);
  526. else if (knob == fKnobPan4)
  527. d_editParameter(SegmentJuicePlugin::paramPan4, true);
  528. else if (knob == fKnobPan5)
  529. d_editParameter(SegmentJuicePlugin::paramPan5, true);
  530. else if (knob == fKnobPan6)
  531. d_editParameter(SegmentJuicePlugin::paramPan6, true);
  532. else if (knob == fKnobAmp1)
  533. d_editParameter(SegmentJuicePlugin::paramAmp1, true);
  534. else if (knob == fKnobAmp2)
  535. d_editParameter(SegmentJuicePlugin::paramAmp2, true);
  536. else if (knob == fKnobAmp3)
  537. d_editParameter(SegmentJuicePlugin::paramAmp3, true);
  538. else if (knob == fKnobAmp4)
  539. d_editParameter(SegmentJuicePlugin::paramAmp4, true);
  540. else if (knob == fKnobAmp5)
  541. d_editParameter(SegmentJuicePlugin::paramAmp5, true);
  542. else if (knob == fKnobAmp6)
  543. d_editParameter(SegmentJuicePlugin::paramAmp6, true);
  544. else if (knob == fKnobAttack)
  545. d_editParameter(SegmentJuicePlugin::paramAttack, true);
  546. else if (knob == fKnobDecay)
  547. d_editParameter(SegmentJuicePlugin::paramDecay, true);
  548. else if (knob == fKnobSustain)
  549. d_editParameter(SegmentJuicePlugin::paramSustain, true);
  550. else if (knob == fKnobRelease)
  551. d_editParameter(SegmentJuicePlugin::paramRelease, true);
  552. else if (knob == fKnobStereo)
  553. d_editParameter(SegmentJuicePlugin::paramStereo, true);
  554. else if (knob == fKnobTune)
  555. d_editParameter(SegmentJuicePlugin::paramTune, true);
  556. else if (knob == fKnobVolume)
  557. d_editParameter(SegmentJuicePlugin::paramVolume, true);
  558. else if (knob == fKnobGlide)
  559. d_editParameter(SegmentJuicePlugin::paramGlide, true);
  560. }
  561. void SegmentJuiceUI::imageKnobDragFinished(ImageKnob* knob)
  562. {
  563. if (knob == fKnobWave1)
  564. d_editParameter(SegmentJuicePlugin::paramWave1, false);
  565. else if (knob == fKnobWave2)
  566. d_editParameter(SegmentJuicePlugin::paramWave2, false);
  567. else if (knob == fKnobWave3)
  568. d_editParameter(SegmentJuicePlugin::paramWave3, false);
  569. else if (knob == fKnobWave4)
  570. d_editParameter(SegmentJuicePlugin::paramWave4, false);
  571. else if (knob == fKnobWave5)
  572. d_editParameter(SegmentJuicePlugin::paramWave5, false);
  573. else if (knob == fKnobWave6)
  574. d_editParameter(SegmentJuicePlugin::paramWave6, false);
  575. else if (knob == fKnobFM1)
  576. d_editParameter(SegmentJuicePlugin::paramFM1, false);
  577. else if (knob == fKnobFM2)
  578. d_editParameter(SegmentJuicePlugin::paramFM2, false);
  579. else if (knob == fKnobFM3)
  580. d_editParameter(SegmentJuicePlugin::paramFM3, false);
  581. else if (knob == fKnobFM4)
  582. d_editParameter(SegmentJuicePlugin::paramFM4, false);
  583. else if (knob == fKnobFM5)
  584. d_editParameter(SegmentJuicePlugin::paramFM5, false);
  585. else if (knob == fKnobFM6)
  586. d_editParameter(SegmentJuicePlugin::paramFM6, false);
  587. else if (knob == fKnobPan1)
  588. d_editParameter(SegmentJuicePlugin::paramPan1, false);
  589. else if (knob == fKnobPan2)
  590. d_editParameter(SegmentJuicePlugin::paramPan2, false);
  591. else if (knob == fKnobPan3)
  592. d_editParameter(SegmentJuicePlugin::paramPan3, false);
  593. else if (knob == fKnobPan4)
  594. d_editParameter(SegmentJuicePlugin::paramPan4, false);
  595. else if (knob == fKnobPan5)
  596. d_editParameter(SegmentJuicePlugin::paramPan5, false);
  597. else if (knob == fKnobPan6)
  598. d_editParameter(SegmentJuicePlugin::paramPan6, false);
  599. else if (knob == fKnobAmp1)
  600. d_editParameter(SegmentJuicePlugin::paramAmp1, false);
  601. else if (knob == fKnobAmp2)
  602. d_editParameter(SegmentJuicePlugin::paramAmp2, false);
  603. else if (knob == fKnobAmp3)
  604. d_editParameter(SegmentJuicePlugin::paramAmp3, false);
  605. else if (knob == fKnobAmp4)
  606. d_editParameter(SegmentJuicePlugin::paramAmp4, false);
  607. else if (knob == fKnobAmp5)
  608. d_editParameter(SegmentJuicePlugin::paramAmp5, false);
  609. else if (knob == fKnobAmp6)
  610. d_editParameter(SegmentJuicePlugin::paramAmp6, false);
  611. else if (knob == fKnobAttack)
  612. d_editParameter(SegmentJuicePlugin::paramAttack, false);
  613. else if (knob == fKnobDecay)
  614. d_editParameter(SegmentJuicePlugin::paramDecay, false);
  615. else if (knob == fKnobSustain)
  616. d_editParameter(SegmentJuicePlugin::paramSustain, false);
  617. else if (knob == fKnobRelease)
  618. d_editParameter(SegmentJuicePlugin::paramRelease, false);
  619. else if (knob == fKnobStereo)
  620. d_editParameter(SegmentJuicePlugin::paramStereo, false);
  621. else if (knob == fKnobTune)
  622. d_editParameter(SegmentJuicePlugin::paramTune, false);
  623. else if (knob == fKnobVolume)
  624. d_editParameter(SegmentJuicePlugin::paramVolume, false);
  625. else if (knob == fKnobGlide)
  626. d_editParameter(SegmentJuicePlugin::paramGlide, false);
  627. }
  628. void SegmentJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value)
  629. {
  630. if (knob == fKnobWave1)
  631. d_setParameterValue(SegmentJuicePlugin::paramWave1, value);
  632. else if (knob == fKnobWave2)
  633. d_setParameterValue(SegmentJuicePlugin::paramWave2, value);
  634. else if (knob == fKnobWave3)
  635. d_setParameterValue(SegmentJuicePlugin::paramWave3, value);
  636. else if (knob == fKnobWave4)
  637. d_setParameterValue(SegmentJuicePlugin::paramWave4, value);
  638. else if (knob == fKnobWave5)
  639. d_setParameterValue(SegmentJuicePlugin::paramWave5, value);
  640. else if (knob == fKnobWave6)
  641. d_setParameterValue(SegmentJuicePlugin::paramWave6, value);
  642. else if (knob == fKnobFM1)
  643. d_setParameterValue(SegmentJuicePlugin::paramFM1, value);
  644. else if (knob == fKnobFM2)
  645. d_setParameterValue(SegmentJuicePlugin::paramFM2, value);
  646. else if (knob == fKnobFM3)
  647. d_setParameterValue(SegmentJuicePlugin::paramFM3, value);
  648. else if (knob == fKnobFM4)
  649. d_setParameterValue(SegmentJuicePlugin::paramFM4, value);
  650. else if (knob == fKnobFM5)
  651. d_setParameterValue(SegmentJuicePlugin::paramFM5, value);
  652. else if (knob == fKnobFM6)
  653. d_setParameterValue(SegmentJuicePlugin::paramFM6, value);
  654. else if (knob == fKnobPan1)
  655. d_setParameterValue(SegmentJuicePlugin::paramPan1, value);
  656. else if (knob == fKnobPan2)
  657. d_setParameterValue(SegmentJuicePlugin::paramPan2, value);
  658. else if (knob == fKnobPan3)
  659. d_setParameterValue(SegmentJuicePlugin::paramPan3, value);
  660. else if (knob == fKnobPan4)
  661. d_setParameterValue(SegmentJuicePlugin::paramPan4, value);
  662. else if (knob == fKnobPan5)
  663. d_setParameterValue(SegmentJuicePlugin::paramPan5, value);
  664. else if (knob == fKnobPan6)
  665. d_setParameterValue(SegmentJuicePlugin::paramPan6, value);
  666. else if (knob == fKnobAmp1)
  667. d_setParameterValue(SegmentJuicePlugin::paramAmp1, value);
  668. else if (knob == fKnobAmp2)
  669. d_setParameterValue(SegmentJuicePlugin::paramAmp2, value);
  670. else if (knob == fKnobAmp3)
  671. d_setParameterValue(SegmentJuicePlugin::paramAmp3, value);
  672. else if (knob == fKnobAmp4)
  673. d_setParameterValue(SegmentJuicePlugin::paramAmp4, value);
  674. else if (knob == fKnobAmp5)
  675. d_setParameterValue(SegmentJuicePlugin::paramAmp5, value);
  676. else if (knob == fKnobAmp6)
  677. d_setParameterValue(SegmentJuicePlugin::paramAmp6, value);
  678. else if (knob == fKnobAttack)
  679. d_setParameterValue(SegmentJuicePlugin::paramAttack, value);
  680. else if (knob == fKnobDecay)
  681. d_setParameterValue(SegmentJuicePlugin::paramDecay, value);
  682. else if (knob == fKnobSustain)
  683. d_setParameterValue(SegmentJuicePlugin::paramSustain, value);
  684. else if (knob == fKnobRelease)
  685. d_setParameterValue(SegmentJuicePlugin::paramRelease, value);
  686. else if (knob == fKnobStereo)
  687. d_setParameterValue(SegmentJuicePlugin::paramStereo, value);
  688. else if (knob == fKnobTune)
  689. d_setParameterValue(SegmentJuicePlugin::paramTune, value);
  690. else if (knob == fKnobVolume)
  691. d_setParameterValue(SegmentJuicePlugin::paramVolume, value);
  692. else if (knob == fKnobGlide)
  693. d_setParameterValue(SegmentJuicePlugin::paramGlide, value);
  694. updateSynth();
  695. }
  696. void SegmentJuiceUI::onDisplay()
  697. {
  698. fImgBackground.draw();
  699. int cX = 23+4;
  700. int cY = 50;
  701. int cW = 388-cX-3;
  702. int cH = 216-cY;
  703. //draw waveform
  704. synthL.play(71);
  705. synthR.play(71);
  706. //glEnable(GL_BLEND);
  707. //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  708. //glEnable( GL_LINE_SMOOTH );
  709. //glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
  710. glLineWidth(1.0f);
  711. //draw #left waveform
  712. glColor4f(0.0f, 1.0f, 0.0f, 0.5f);
  713. glBegin(GL_LINE_STRIP);
  714. for (int i = 0; i<cW; i++) {
  715. float out = synthL.run()*cH/2+cH/2+cY;
  716. glVertex2i(i+cX, out);
  717. std::cout << out << std::endl;
  718. }
  719. //draw #right waveform
  720. glEnd();
  721. glColor4f(0.0f, 0.0f, 1.0f, 0.5f);
  722. glBegin(GL_LINE_STRIP);
  723. for (int i = 0; i<cW; i++) {
  724. glVertex2i(i+cX, synthR.run()*cH/2+cH/2+cY);
  725. }
  726. glEnd();
  727. //draw 0dc line
  728. glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
  729. glBegin(GL_LINES);
  730. glVertex2i(cX, cY+cH/2);
  731. glVertex2i(cX+cW, cY+cH/2);
  732. glEnd();
  733. glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
  734. }
  735. // -----------------------------------------------------------------------
  736. UI* createUI()
  737. {
  738. return new SegmentJuiceUI();
  739. }
  740. // -----------------------------------------------------------------------
  741. END_NAMESPACE_DISTRHO