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.

236 lines
7.9KB

  1. /*
  2. * DISTRHO MVerb, a DPF'ied MVerb.
  3. * Copyright (c) 2010 Martin Eastwood
  4. * Copyright (C) 2015 Filipe Coelho <falktx@falktx.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 3 of
  9. * the License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * For a full copy of the GNU General Public License see the LICENSE file.
  17. */
  18. #include "DistrhoPluginMVerb.hpp"
  19. START_NAMESPACE_DISTRHO
  20. // -----------------------------------------------------------------------
  21. DistrhoPluginMVerb::DistrhoPluginMVerb()
  22. : Plugin(MVerb<float>::NUM_PARAMS, 5, 0) // 5 program, 0 states
  23. {
  24. fVerb.setSampleRate(getSampleRate());
  25. // set initial values
  26. loadProgram(0);
  27. }
  28. // -----------------------------------------------------------------------
  29. // Init
  30. void DistrhoPluginMVerb::initParameter(uint32_t index, Parameter& parameter)
  31. {
  32. parameter.unit = "%";
  33. parameter.ranges.min = 0.0f;
  34. parameter.ranges.max = 100.0f;
  35. // default values taken from 1st preset
  36. switch (index)
  37. {
  38. case MVerb<float>::DAMPINGFREQ:
  39. parameter.hints = kParameterIsAutomable;
  40. parameter.name = "Damping";
  41. parameter.symbol = "damping";
  42. parameter.ranges.def = 0.5f * 100.0f;
  43. break;
  44. case MVerb<float>::DENSITY:
  45. parameter.hints = kParameterIsAutomable;
  46. parameter.name = "Density";
  47. parameter.symbol = "density";
  48. parameter.ranges.def = 0.5f * 100.0f;
  49. break;
  50. case MVerb<float>::BANDWIDTHFREQ:
  51. parameter.hints = kParameterIsAutomable;
  52. parameter.name = "Bandwidth";
  53. parameter.symbol = "bandwidth";
  54. parameter.ranges.def = 0.5f * 100.0f;
  55. break;
  56. case MVerb<float>::DECAY:
  57. parameter.hints = kParameterIsAutomable;
  58. parameter.name = "Decay";
  59. parameter.symbol = "decay";
  60. parameter.ranges.def = 0.5f * 100.0f;
  61. break;
  62. case MVerb<float>::PREDELAY:
  63. parameter.hints = kParameterIsAutomable;
  64. parameter.name = "Predelay";
  65. parameter.symbol = "predelay";
  66. parameter.ranges.def = 0.5f * 100.0f;
  67. break;
  68. case MVerb<float>::SIZE:
  69. parameter.hints = kParameterIsAutomable;
  70. parameter.name = "Size";
  71. parameter.symbol = "size";
  72. parameter.ranges.def = 0.75f * 100.0f;
  73. parameter.ranges.min = 0.05f * 100.0f;
  74. break;
  75. case MVerb<float>::GAIN:
  76. parameter.hints = kParameterIsAutomable;
  77. parameter.name = "Gain";
  78. parameter.symbol = "gain";
  79. parameter.ranges.def = 1.0f * 100.0f;
  80. break;
  81. case MVerb<float>::MIX:
  82. parameter.hints = kParameterIsAutomable;
  83. parameter.name = "Mix";
  84. parameter.symbol = "mix";
  85. parameter.ranges.def = 0.5f * 100.0f;
  86. break;
  87. case MVerb<float>::EARLYMIX:
  88. parameter.hints = kParameterIsAutomable;
  89. parameter.name = "Early/Late Mix";
  90. parameter.symbol = "earlymix";
  91. parameter.ranges.def = 0.5f * 100.0f;
  92. break;
  93. }
  94. }
  95. void DistrhoPluginMVerb::initProgramName(uint32_t index, String& programName)
  96. {
  97. switch(index)
  98. {
  99. case 0:
  100. programName = "Halves";
  101. break;
  102. case 1:
  103. programName = "Dark";
  104. break;
  105. case 2:
  106. programName = "Cupboard";
  107. break;
  108. case 3:
  109. programName = "Stadium";
  110. break;
  111. case 4:
  112. programName = "Subtle";
  113. break;
  114. }
  115. }
  116. // -----------------------------------------------------------------------
  117. // Internal data
  118. float DistrhoPluginMVerb::getParameterValue(uint32_t index) const
  119. {
  120. return fVerb.getParameter(static_cast<int>(index)) * 100.0f;
  121. }
  122. void DistrhoPluginMVerb::setParameterValue(uint32_t index, float value)
  123. {
  124. fVerb.setParameter(static_cast<int>(index), value / 100.0f);
  125. }
  126. void DistrhoPluginMVerb::loadProgram(uint32_t index)
  127. {
  128. // NOTE: DAMPINGFREQ is reversed
  129. switch(index)
  130. {
  131. case 0:
  132. fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 0.5f);
  133. fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
  134. fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 0.5f);
  135. fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
  136. fVerb.setParameter(MVerb<float>::PREDELAY, 0.5f);
  137. fVerb.setParameter(MVerb<float>::SIZE, 0.75f);
  138. fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
  139. fVerb.setParameter(MVerb<float>::MIX, 0.5f);
  140. fVerb.setParameter(MVerb<float>::EARLYMIX, 0.5f);
  141. break;
  142. case 1:
  143. fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 0.1f);
  144. fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
  145. fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 0.1f);
  146. fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
  147. fVerb.setParameter(MVerb<float>::PREDELAY, 0.0f);
  148. fVerb.setParameter(MVerb<float>::SIZE, 0.5f);
  149. fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
  150. fVerb.setParameter(MVerb<float>::MIX, 0.5f);
  151. fVerb.setParameter(MVerb<float>::EARLYMIX, 0.75f);
  152. break;
  153. case 2:
  154. fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 1.0f);
  155. fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
  156. fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 1.0f);
  157. fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
  158. fVerb.setParameter(MVerb<float>::PREDELAY, 0.0f);
  159. fVerb.setParameter(MVerb<float>::SIZE, 0.25f);
  160. fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
  161. fVerb.setParameter(MVerb<float>::MIX, 0.35f);
  162. fVerb.setParameter(MVerb<float>::EARLYMIX, 0.75f);
  163. break;
  164. case 3:
  165. fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 1.0f);
  166. fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
  167. fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 1.0f);
  168. fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
  169. fVerb.setParameter(MVerb<float>::PREDELAY, 0.0f);
  170. fVerb.setParameter(MVerb<float>::SIZE, 1.0f);
  171. fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
  172. fVerb.setParameter(MVerb<float>::MIX, 0.35f);
  173. fVerb.setParameter(MVerb<float>::EARLYMIX, 0.75f);
  174. break;
  175. case 4:
  176. fVerb.setParameter(MVerb<float>::DAMPINGFREQ, 1.0f);
  177. fVerb.setParameter(MVerb<float>::DENSITY, 0.5f);
  178. fVerb.setParameter(MVerb<float>::BANDWIDTHFREQ, 1.0f);
  179. fVerb.setParameter(MVerb<float>::DECAY, 0.5f);
  180. fVerb.setParameter(MVerb<float>::PREDELAY, 0.0f);
  181. fVerb.setParameter(MVerb<float>::SIZE, 0.5f);
  182. fVerb.setParameter(MVerb<float>::GAIN, 1.0f);
  183. fVerb.setParameter(MVerb<float>::MIX, 0.15f);
  184. fVerb.setParameter(MVerb<float>::EARLYMIX, 0.75f);
  185. break;
  186. }
  187. fVerb.reset();
  188. }
  189. // -----------------------------------------------------------------------
  190. // Process
  191. void DistrhoPluginMVerb::activate()
  192. {
  193. fVerb.reset();
  194. }
  195. void DistrhoPluginMVerb::run(const float** inputs, float** outputs, uint32_t frames)
  196. {
  197. fVerb.process(inputs, outputs, static_cast<int>(frames));
  198. }
  199. // -----------------------------------------------------------------------
  200. // Callbacks
  201. void DistrhoPluginMVerb::sampleRateChanged(double newSampleRate)
  202. {
  203. fVerb.setSampleRate(newSampleRate);
  204. }
  205. // -----------------------------------------------------------------------
  206. Plugin* createPlugin()
  207. {
  208. return new DistrhoPluginMVerb();
  209. }
  210. // -----------------------------------------------------------------------
  211. END_NAMESPACE_DISTRHO