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.

143 lines
4.2KB

  1. /*
  2. * Wobble 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. #ifndef WOBBLEJUICEPLUGIN_HPP_INCLUDED
  18. #define WOBBLEJUICEPLUGIN_HPP_INCLUDED
  19. #include "DistrhoPlugin.hpp"
  20. #include "moogVCF.hxx"
  21. START_NAMESPACE_DISTRHO
  22. // -----------------------------------------------------------------------
  23. class WobbleJuicePlugin : public Plugin
  24. {
  25. public:
  26. enum Parameters
  27. {
  28. paramDivision = 0,
  29. paramReso,
  30. paramRange,
  31. paramPhase,
  32. paramWave,
  33. paramDrive,
  34. paramCount
  35. };
  36. float getSinePhase(float x) {
  37. return ((-std::cos(x)+1)/2);
  38. }
  39. float getSawPhase(float x) {
  40. return (-((2/M_PI * std::atan(1/std::tan(x/2)))-1)/2);
  41. }
  42. float getRevSawPhase(float x) {
  43. return (((2/M_PI * std::atan(1/std::tan(x/2)))+1)/2);
  44. }
  45. float getSquarePhase(float x) {
  46. return (std::round((std::sin(x)+1)/2));
  47. }
  48. //saw, sqr, sin, revSaw
  49. float getBlendedPhase(float x, float wave)
  50. {
  51. //wave = 2;
  52. if (wave>=1 && wave<2) {
  53. /* saw vs sqr */
  54. waveBlend = wave-1;
  55. return (getSawPhase(x)*(1-waveBlend) + getSquarePhase(x)*waveBlend);
  56. } else if (wave>=2 && wave<3) {
  57. /* sqr vs sin */
  58. waveBlend = wave-2;
  59. return (getSquarePhase(x)*(1-waveBlend) + getSinePhase(x)*waveBlend);
  60. } else if (wave>=3 && wave<=4) {
  61. /* sin vs revSaw */
  62. waveBlend = wave-3;
  63. return (getSinePhase(x)*(1-waveBlend) + getRevSawPhase(x)*waveBlend);
  64. } else {
  65. return 0.0f;
  66. }
  67. }
  68. WobbleJuicePlugin();
  69. protected:
  70. // -------------------------------------------------------------------
  71. // Information
  72. const char* d_getLabel() const noexcept override
  73. {
  74. return "WobbleJuice";
  75. }
  76. const char* d_getMaker() const noexcept override
  77. {
  78. return "Andre Sklenar";
  79. }
  80. const char* d_getLicense() const noexcept override
  81. {
  82. return "GPL v2+";
  83. }
  84. uint32_t d_getVersion() const noexcept override
  85. {
  86. return 0x1000;
  87. }
  88. int64_t d_getUniqueId() const noexcept override
  89. {
  90. return d_cconst('W', 'b', 'l', 'J');
  91. }
  92. // -------------------------------------------------------------------
  93. // Init
  94. void d_initParameter(uint32_t index, Parameter& parameter) override;
  95. void d_initProgramName(uint32_t index, d_string& programName) override;
  96. // -------------------------------------------------------------------
  97. // Internal data
  98. float d_getParameterValue(uint32_t index) const override;
  99. void d_setParameterValue(uint32_t index, float value) override;
  100. void d_setProgram(uint32_t index) override;
  101. // -------------------------------------------------------------------
  102. // Process
  103. void d_activate() override;
  104. void d_run(const float** inputs, float** outputs, uint32_t frames) override;
  105. // -------------------------------------------------------------------
  106. private:
  107. MoogVCF filterL, filterR;
  108. float division, reso, range, phase, wave, drive; //parameters
  109. float bar, tick, tickOffset, percentage, phaseOffset, currentPhaseL, currentPhaseR, posL, posR, cutoffL, cutoffR;
  110. double sinePos;
  111. float waveType, waveBlend;
  112. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WobbleJuicePlugin)
  113. };
  114. // -----------------------------------------------------------------------
  115. END_NAMESPACE_DISTRHO
  116. #endif // WOBBLEJUICE_HPP_INCLUDED