DISTRHO glBars
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.

157 lines
4.6KB

  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-2022 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::initAudioPort(bool input, uint32_t index, AudioPort& port)
  41. {
  42. port.groupId = kPortGroupMono;
  43. Plugin::initAudioPort(input, index, port);
  44. }
  45. void DistrhoPluginGLBars::initParameter(uint32_t index, Parameter& parameter)
  46. {
  47. switch (index)
  48. {
  49. case kParameterScale:
  50. parameter.hints = kParameterIsAutomatable|kParameterIsLogarithmic;
  51. parameter.name = "Scale";
  52. parameter.symbol = "scale";
  53. parameter.unit = "";
  54. parameter.ranges.def = 1.0f / log(256.f);
  55. parameter.ranges.min = 0.5f / log(256.f);
  56. parameter.ranges.max = 3.0f / log(256.f);
  57. break;
  58. case kParameterSpeed:
  59. parameter.hints = kParameterIsAutomatable|kParameterIsLogarithmic;
  60. parameter.name = "Speed";
  61. parameter.symbol = "speed";
  62. parameter.unit = "";
  63. parameter.ranges.def = 0.025f;
  64. parameter.ranges.min = 0.0125f;
  65. parameter.ranges.max = 0.1f;
  66. break;
  67. case kParameterX:
  68. parameter.hints = kParameterIsAutomatable;
  69. parameter.name = "X";
  70. parameter.symbol = "x";
  71. parameter.unit = "";
  72. parameter.ranges.def = 0.0f;
  73. parameter.ranges.min = -4.0f;
  74. parameter.ranges.max = 4.0f;
  75. break;
  76. case kParameterY:
  77. parameter.hints = kParameterIsAutomatable;
  78. parameter.name = "Y";
  79. parameter.symbol = "y";
  80. parameter.unit = "";
  81. parameter.ranges.def = 0.5f;
  82. parameter.ranges.min = -4.0f;
  83. parameter.ranges.max = 4.0f;
  84. break;
  85. case kParameterZ:
  86. parameter.hints = kParameterIsAutomatable;
  87. parameter.name = "Z";
  88. parameter.symbol = "z";
  89. parameter.unit = "";
  90. parameter.ranges.def = 0.0f;
  91. parameter.ranges.min = -4.0f;
  92. parameter.ranges.max = 4.0f;
  93. break;
  94. }
  95. }
  96. // -----------------------------------------------------------------------
  97. // Internal data
  98. float DistrhoPluginGLBars::getParameterValue(uint32_t index) const
  99. {
  100. if (index >= kParameterCount)
  101. return 0.0f;
  102. return fParameters[index];
  103. }
  104. void DistrhoPluginGLBars::setParameterValue(uint32_t index, float value)
  105. {
  106. if (index >= kParameterCount)
  107. return;
  108. fParameters[index] = value;
  109. }
  110. // -----------------------------------------------------------------------
  111. // Process
  112. void DistrhoPluginGLBars::run(const float** inputs, float** outputs, uint32_t frames)
  113. {
  114. const float* in = inputs[0];
  115. float* out = outputs[0];
  116. if (out != in)
  117. std::memcpy(out, in, sizeof(float)*frames);
  118. const MutexLocker csm(fMutex);
  119. if (fState != nullptr)
  120. fState->AudioData(in, frames);
  121. }
  122. // -----------------------------------------------------------------------
  123. Plugin* createPlugin()
  124. {
  125. return new DistrhoPluginGLBars();
  126. }
  127. // -----------------------------------------------------------------------
  128. END_NAMESPACE_DISTRHO