Collection of DPF-based plugins for packaging
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.

150 lines
4.4KB

  1. /*
  2. * DISTRHO glBars Plugin based on XMMS/XBMC "GL Bars"
  3. * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
  4. * Copyright (C) 2000 Christian Zander <phoenix@minion.de>
  5. * Copyright (C) 2015 Nedko Arnaudov
  6. * Copyright (C) 2016 Filipe Coelho <falktx@falktx.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * For a full copy of the license see the LICENSE file.
  19. */
  20. #include "DistrhoPluginGLBars.hpp"
  21. #include "glBars.hpp"
  22. START_NAMESPACE_DISTRHO
  23. // -----------------------------------------------------------------------
  24. DistrhoPluginGLBars::DistrhoPluginGLBars()
  25. : Plugin(kParameterCount, 0, 0),
  26. fState(nullptr)
  27. {
  28. fParameters[kParameterScale] = 1.f / log(256.f);
  29. fParameters[kParameterSpeed] = 0.025f;
  30. fParameters[kParameterX] = 0.0f;
  31. fParameters[kParameterY] = 0.5f;
  32. fParameters[kParameterZ] = 0.0f;
  33. }
  34. DistrhoPluginGLBars::~DistrhoPluginGLBars()
  35. {
  36. DISTRHO_SAFE_ASSERT(fState == nullptr);
  37. }
  38. // -----------------------------------------------------------------------
  39. // Init
  40. void DistrhoPluginGLBars::initParameter(uint32_t index, Parameter& parameter)
  41. {
  42. switch (index)
  43. {
  44. case kParameterScale:
  45. parameter.hints = kParameterIsAutomable|kParameterIsLogarithmic;
  46. parameter.name = "Scale";
  47. parameter.symbol = "scale";
  48. parameter.unit = "";
  49. parameter.ranges.def = 1.0f / log(256.f);
  50. parameter.ranges.min = 0.5f / log(256.f);
  51. parameter.ranges.max = 3.0f / log(256.f);
  52. break;
  53. case kParameterSpeed:
  54. parameter.hints = kParameterIsAutomable|kParameterIsLogarithmic;
  55. parameter.name = "Speed";
  56. parameter.symbol = "speed";
  57. parameter.unit = "";
  58. parameter.ranges.def = 0.025f;
  59. parameter.ranges.min = 0.0125f;
  60. parameter.ranges.max = 0.1f;
  61. break;
  62. case kParameterX:
  63. parameter.hints = kParameterIsAutomable;
  64. parameter.name = "X";
  65. parameter.symbol = "x";
  66. parameter.unit = "";
  67. parameter.ranges.def = -4.0f;
  68. parameter.ranges.min = 0.0f;
  69. parameter.ranges.max = 4.0f;
  70. break;
  71. case kParameterY:
  72. parameter.hints = kParameterIsAutomable;
  73. parameter.name = "Y";
  74. parameter.symbol = "y";
  75. parameter.unit = "";
  76. parameter.ranges.def = 0.5f;
  77. parameter.ranges.min = -4.0f;
  78. parameter.ranges.max = 4.0f;
  79. break;
  80. case kParameterZ:
  81. parameter.hints = kParameterIsAutomable;
  82. parameter.name = "Z";
  83. parameter.symbol = "z";
  84. parameter.unit = "";
  85. parameter.ranges.def = 0.0f;
  86. parameter.ranges.min = -4.0f;
  87. parameter.ranges.max = 4.0f;
  88. break;
  89. }
  90. }
  91. // -----------------------------------------------------------------------
  92. // Internal data
  93. float DistrhoPluginGLBars::getParameterValue(uint32_t index) const
  94. {
  95. if (index >= kParameterCount)
  96. return 0.0f;
  97. return fParameters[index];
  98. }
  99. void DistrhoPluginGLBars::setParameterValue(uint32_t index, float value)
  100. {
  101. if (index >= kParameterCount)
  102. return;
  103. fParameters[index] = value;
  104. }
  105. // -----------------------------------------------------------------------
  106. // Process
  107. void DistrhoPluginGLBars::run(const float** inputs, float** outputs, uint32_t frames)
  108. {
  109. const float* in = inputs[0];
  110. float* out = outputs[0];
  111. if (out != in)
  112. std::memcpy(out, in, sizeof(float)*frames);
  113. const MutexLocker csm(fMutex);
  114. if (fState != nullptr)
  115. fState->AudioData(in, frames);
  116. }
  117. // -----------------------------------------------------------------------
  118. Plugin* createPlugin()
  119. {
  120. return new DistrhoPluginGLBars();
  121. }
  122. // -----------------------------------------------------------------------
  123. END_NAMESPACE_DISTRHO