DISTRHO Juice Plugins
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.

115 lines
3.2KB

  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 POWERJUICEUI_HPP_INCLUDED
  18. #define POWERJUICEUI_HPP_INCLUDED
  19. #include "DistrhoUI.hpp"
  20. #include "ImageWidgets.hpp"
  21. #include "PowerJuiceX2Artwork.hpp"
  22. #include "PowerJuiceX2Plugin.hpp"
  23. #include <cmath>
  24. using DGL::Image;
  25. using DGL::ImageAboutWindow;
  26. using DGL::ImageButton;
  27. using DGL::ImageKnob;
  28. START_NAMESPACE_DISTRHO
  29. // -----------------------------------------------------------------------
  30. class PowerJuiceX2UI : public UI,
  31. public ImageButton::Callback,
  32. public ImageKnob::Callback
  33. {
  34. public:
  35. PowerJuiceX2UI();
  36. protected:
  37. // -------------------------------------------------------------------
  38. // DSP Callbacks
  39. void parameterChanged(uint32_t index, float value) override;
  40. void programLoaded(uint32_t index) override;
  41. // -------------------------------------------------------------------
  42. // UI Callbacks
  43. void uiIdle() override;
  44. // -------------------------------------------------------------------
  45. // Widget Callbacks
  46. void imageButtonClicked(ImageButton* button, int) override;
  47. void imageKnobDragStarted(ImageKnob* knob) override;
  48. void imageKnobDragFinished(ImageKnob* knob) override;
  49. void imageKnobValueChanged(ImageKnob* knob, float value) override;
  50. void onDisplay() override;
  51. private:
  52. Image fImgBackground;
  53. ImageAboutWindow fAboutWindow;
  54. ScopedPointer<ImageKnob> fKnobAttack, fKnobRelease, fKnobThreshold;
  55. ScopedPointer<ImageKnob> fKnobRatio, fKnobMakeup, fKnobMix;
  56. ScopedPointer<ImageButton> fButtonAbout;
  57. PowerJuiceX2Plugin* const dsp;
  58. float fromDB(float gdb) {
  59. return (std::exp(gdb/20.f*std::log(10.f)));
  60. };
  61. float toDB(float g) {
  62. return (20.f*std::log10(g));
  63. }
  64. float toIEC(float db) {
  65. float def = 0.0f; /* Meter deflection %age */
  66. if (db < -70.0f) {
  67. def = 0.0f;
  68. } else if (db < -60.0f) {
  69. def = (db + 70.0f) * 0.25f;
  70. } else if (db < -50.0f) {
  71. def = (db + 60.0f) * 0.5f + 5.0f;
  72. } else if (db < -40.0f) {
  73. def = (db + 50.0f) * 0.75f + 7.5;
  74. } else if (db < -30.0f) {
  75. def = (db + 40.0f) * 1.5f + 15.0f;
  76. } else if (db < -20.0f) {
  77. def = (db + 30.0f) * 2.0f + 30.0f;
  78. } else if (db < 0.0f) {
  79. def = (db + 20.0f) * 2.5f + 50.0f;
  80. } else {
  81. def = 100.0f;
  82. }
  83. return (def * 2.0f);
  84. }
  85. };
  86. // -----------------------------------------------------------------------
  87. END_NAMESPACE_DISTRHO
  88. #endif // POWERJUICEUI_HPP_INCLUDED