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.

ZamTubeUI.cpp 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * ZamTube triode WDF distortion model
  3. * Copyright (C) 2014 Damien Zammit <damien@zamaudio.com>
  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 "ZamTubePlugin.hpp"
  18. // conflict macros in wdf
  19. #undef max
  20. #undef min
  21. #include "ZamTubeUI.hpp"
  22. using DGL::Point;
  23. START_NAMESPACE_DISTRHO
  24. // -----------------------------------------------------------------------
  25. ZamTubeUI::ZamTubeUI()
  26. : UI()
  27. {
  28. // background
  29. fImgBackground = Image(ZamTubeArtwork::zamtubeData, ZamTubeArtwork::zamtubeWidth, ZamTubeArtwork::zamtubeHeight, GL_BGR);
  30. // knob
  31. Image knobImage(ZamTubeArtwork::knobData, ZamTubeArtwork::knobWidth, ZamTubeArtwork::knobHeight);
  32. // notch slider
  33. Image notchImage(ZamTubeArtwork::notchData, ZamTubeArtwork::notchWidth, ZamTubeArtwork::notchHeight);
  34. // knobs
  35. fKnobTube = new ImageKnob(this, knobImage);
  36. fKnobTube->setAbsolutePos(177, 76);
  37. fKnobTube->setRange(0.f, 30.0f);
  38. fKnobTube->setStep(0.1f);
  39. fKnobTube->setDefault(0.0f);
  40. fKnobTube->setRotationAngle(240);
  41. fKnobTube->setCallback(this);
  42. fKnobBass = new ImageKnob(this, knobImage);
  43. fKnobBass->setAbsolutePos(63, 140.5);
  44. fKnobBass->setRange(0.f, 1.0f);
  45. fKnobBass->setStep(0.01f);
  46. fKnobBass->setDefault(0.5f);
  47. fKnobBass->setRotationAngle(240);
  48. fKnobBass->setCallback(this);
  49. fKnobMids = new ImageKnob(this, knobImage);
  50. fKnobMids->setAbsolutePos(63, 87);
  51. fKnobMids->setRange(0.f, 1.0f);
  52. fKnobMids->setStep(0.01f);
  53. fKnobMids->setDefault(0.5f);
  54. fKnobMids->setRotationAngle(240);
  55. fKnobMids->setCallback(this);
  56. fKnobTreb = new ImageKnob(this, knobImage);
  57. fKnobTreb->setAbsolutePos(63, 33);
  58. fKnobTreb->setRange(0.f, 1.0f);
  59. fKnobTreb->setStep(0.01f);
  60. fKnobTreb->setDefault(0.0f);
  61. fKnobTreb->setRotationAngle(240);
  62. fKnobTreb->setCallback(this);
  63. fKnobGain = new ImageKnob(this, knobImage);
  64. fKnobGain->setAbsolutePos(63, 231);
  65. fKnobGain->setRange(-30.f, 30.0f);
  66. fKnobGain->setStep(1.f);
  67. fKnobGain->setDefault(0.0f);
  68. fKnobGain->setRotationAngle(240);
  69. fKnobGain->setCallback(this);
  70. Point<int> notchPosStart(289,5);
  71. Point<int> notchPosEnd(289,5+280);
  72. fSliderNotch = new ImageSlider(this, notchImage);
  73. fSliderNotch->setStartPos(notchPosStart);
  74. fSliderNotch->setEndPos(notchPosEnd);
  75. fSliderNotch->setRange(0.f, 24.f);
  76. fSliderNotch->setStep(1.f);
  77. fSliderNotch->setValue(0.f);
  78. fSliderNotch->setCallback(this);
  79. // set default values
  80. d_programChanged(0);
  81. }
  82. // -----------------------------------------------------------------------
  83. // DSP Callbacks
  84. void ZamTubeUI::d_parameterChanged(uint32_t index, float value)
  85. {
  86. switch (index)
  87. {
  88. case ZamTubePlugin::paramTubedrive:
  89. fKnobTube->setValue(value);
  90. break;
  91. case ZamTubePlugin::paramBass:
  92. fKnobBass->setValue(value);
  93. break;
  94. case ZamTubePlugin::paramMiddle:
  95. fKnobMids->setValue(value);
  96. break;
  97. case ZamTubePlugin::paramTreble:
  98. fKnobTreb->setValue(value);
  99. break;
  100. case ZamTubePlugin::paramGain:
  101. fKnobGain->setValue(value);
  102. break;
  103. }
  104. }
  105. void ZamTubeUI::d_programChanged(uint32_t index)
  106. {
  107. if (index != 0)
  108. return;
  109. // Default values
  110. fKnobTube->setValue(0.0f);
  111. fKnobBass->setValue(0.5f);
  112. fKnobMids->setValue(0.5f);
  113. fKnobTreb->setValue(0.0f);
  114. fKnobGain->setValue(0.0f);
  115. fSliderNotch->setValue(0.0f);
  116. }
  117. // -----------------------------------------------------------------------
  118. // Widget Callbacks
  119. void ZamTubeUI::imageKnobDragStarted(ImageKnob* knob)
  120. {
  121. if (knob == fKnobTube)
  122. d_editParameter(ZamTubePlugin::paramTubedrive, true);
  123. else if (knob == fKnobBass)
  124. d_editParameter(ZamTubePlugin::paramBass, true);
  125. else if (knob == fKnobMids)
  126. d_editParameter(ZamTubePlugin::paramMiddle, true);
  127. else if (knob == fKnobTreb)
  128. d_editParameter(ZamTubePlugin::paramTreble, true);
  129. else if (knob == fKnobGain)
  130. d_editParameter(ZamTubePlugin::paramGain, true);
  131. }
  132. void ZamTubeUI::imageKnobDragFinished(ImageKnob* knob)
  133. {
  134. if (knob == fKnobTube)
  135. d_editParameter(ZamTubePlugin::paramTubedrive, false);
  136. else if (knob == fKnobBass)
  137. d_editParameter(ZamTubePlugin::paramBass, false);
  138. else if (knob == fKnobMids)
  139. d_editParameter(ZamTubePlugin::paramMiddle, false);
  140. else if (knob == fKnobTreb)
  141. d_editParameter(ZamTubePlugin::paramTreble, false);
  142. else if (knob == fKnobGain)
  143. d_editParameter(ZamTubePlugin::paramGain, false);
  144. }
  145. void ZamTubeUI::imageKnobValueChanged(ImageKnob* knob, float value)
  146. {
  147. if (knob == fKnobTube)
  148. d_setParameterValue(ZamTubePlugin::paramTubedrive, value);
  149. else if (knob == fKnobBass)
  150. d_setParameterValue(ZamTubePlugin::paramBass, value);
  151. else if (knob == fKnobMids)
  152. d_setParameterValue(ZamTubePlugin::paramMiddle, value);
  153. else if (knob == fKnobTreb)
  154. d_setParameterValue(ZamTubePlugin::paramTreble, value);
  155. else if (knob == fKnobGain)
  156. d_setParameterValue(ZamTubePlugin::paramGain, value);
  157. }
  158. void ZamTubeUI::imageSliderDragStarted(ImageSlider*)
  159. {
  160. d_editParameter(ZamTubePlugin::paramToneStack, true);
  161. }
  162. void ZamTubeUI::imageSliderDragFinished(ImageSlider*)
  163. {
  164. d_editParameter(ZamTubePlugin::paramToneStack, false);
  165. }
  166. void ZamTubeUI::imageSliderValueChanged(ImageSlider*, float value)
  167. {
  168. d_setParameterValue(ZamTubePlugin::paramToneStack, value);
  169. }
  170. void ZamTubeUI::onDisplay()
  171. {
  172. fImgBackground.draw();
  173. }
  174. // -----------------------------------------------------------------------
  175. UI* createUI()
  176. {
  177. return new ZamTubeUI();
  178. }
  179. // -----------------------------------------------------------------------
  180. END_NAMESPACE_DISTRHO