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.

138 lines
3.6KB

  1. /*
  2. * Power 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 POWERJUICEPLUGIN_HPP_INCLUDED
  18. #define POWERJUICEPLUGIN_HPP_INCLUDED
  19. #include "DistrhoPlugin.hpp"
  20. #include "CarlaShmUtils.hpp"
  21. static const int kFloatStackCount = 1126;
  22. struct FloatStack {
  23. int32_t start;
  24. float data[kFloatStackCount];
  25. };
  26. struct SharedMemData {
  27. float input[kFloatStackCount];
  28. float output[kFloatStackCount];
  29. float gainReduction[kFloatStackCount];
  30. };
  31. START_NAMESPACE_DISTRHO
  32. // -----------------------------------------------------------------------
  33. class PowerJuicePlugin : public Plugin
  34. {
  35. public:
  36. enum Parameters
  37. {
  38. paramAttack = 0,
  39. paramRelease,
  40. paramThreshold,
  41. paramRatio,
  42. paramMakeup,
  43. paramMix,
  44. paramInput,
  45. paramOutput,
  46. paramGainReduction,
  47. paramCount
  48. };
  49. PowerJuicePlugin();
  50. ~PowerJuicePlugin() override;
  51. protected:
  52. // -------------------------------------------------------------------
  53. // Information
  54. const char* d_getLabel() const noexcept override
  55. {
  56. return "PowerJuice";
  57. }
  58. const char* d_getMaker() const noexcept override
  59. {
  60. return "Andre Sklenar";
  61. }
  62. const char* d_getLicense() const noexcept override
  63. {
  64. return "GPL v2+";
  65. }
  66. uint32_t d_getVersion() const noexcept override
  67. {
  68. return 0x1000;
  69. }
  70. long d_getUniqueId() const noexcept override
  71. {
  72. return d_cconst('P', 'w', 'r', 'J');
  73. }
  74. // -------------------------------------------------------------------
  75. // Init
  76. void d_initParameter(uint32_t index, Parameter& parameter) override;
  77. void d_initProgramName(uint32_t index, d_string& programName) override;
  78. void d_initStateKey(uint32_t, d_string&) override;
  79. // -------------------------------------------------------------------
  80. // Internal data
  81. float d_getParameterValue(uint32_t index) const override;
  82. void d_setParameterValue(uint32_t index, float value) override;
  83. void d_setProgram(uint32_t index) override;
  84. void d_setState(const char* key, const char* value) override;
  85. // -------------------------------------------------------------------
  86. // Process
  87. void d_activate() override;
  88. void d_deactivate() override;
  89. void d_run(float** inputs, float** outputs, uint32_t frames) override;
  90. // -------------------------------------------------------------------
  91. private:
  92. // params
  93. float attack, release, threshold, ratio, makeup, mix;
  94. int averageCounter;
  95. float inputMin, inputMax;
  96. // this was unused
  97. // float averageInputs[150];
  98. FloatStack input, output, gainReduction;
  99. shm_t shm;
  100. SharedMemData* shmData;
  101. void initShm(const char* shmKey);
  102. void closeShm();
  103. };
  104. // -----------------------------------------------------------------------
  105. END_NAMESPACE_DISTRHO
  106. #endif // POWERJUICE_HPP_INCLUDED