CompressorControlDialog.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*
  2. * CompressorControlDialog.h
  3. *
  4. * Copyright (c) 2020 Lost Robot <r94231@gmail.com>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) 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 GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef COMPRESSOR_CONTROL_DIALOG_H
  25. #define COMPRESSOR_CONTROL_DIALOG_H
  26. #include <QBasicTimer>
  27. #include <QLabel>
  28. #include <QMouseEvent>
  29. #include <QPainter>
  30. #include <QTime>
  31. #include "../Eq/EqFader.h"
  32. #include "EffectControlDialog.h"
  33. #include "GuiApplication.h"
  34. #include "Knob.h"
  35. #include "MainWindow.h"
  36. #include "PixmapButton.h"
  37. constexpr int COMP_MILLI_PER_PIXEL = 6;
  38. constexpr int MIN_COMP_SCREEN_X = 800;
  39. constexpr int MIN_COMP_SCREEN_Y = 360;
  40. constexpr int MAX_COMP_SCREEN_X = 1920;
  41. constexpr int MAX_COMP_SCREEN_Y = 1080;
  42. constexpr int COMP_SCREEN_X = 800;
  43. constexpr int COMP_SCREEN_Y = 560;
  44. constexpr int KNEE_SCREEN_X = COMP_SCREEN_Y;
  45. constexpr int KNEE_SCREEN_Y = COMP_SCREEN_Y;
  46. constexpr int COMP_KNEE_LINES = 20;
  47. constexpr int COMP_BOX_X = 720;
  48. constexpr int COMP_BOX_Y = 280;
  49. constexpr float COMP_GRID_SPACING = 3.f;// 3 db per grid line
  50. constexpr float COMP_GRID_MAX = 96.f;// Can't zoom out past 96 db
  51. constexpr float COMP_NOISE_FLOOR = 0.000001;// -120 dbFs
  52. class CompressorControls;
  53. class CompressorControlDialog : public EffectControlDialog
  54. {
  55. Q_OBJECT
  56. public:
  57. CompressorControlDialog(CompressorControls* controls);
  58. bool isResizable() const override {return true;}
  59. QSize sizeHint() const override {return QSize(COMP_SCREEN_X, COMP_SCREEN_Y);}
  60. // For theming purposes
  61. Q_PROPERTY(QColor inVolAreaColor MEMBER m_inVolAreaColor)
  62. Q_PROPERTY(QColor inVolColor MEMBER m_inVolColor)
  63. Q_PROPERTY(QColor outVolAreaColor MEMBER m_outVolAreaColor)
  64. Q_PROPERTY(QColor outVolColor MEMBER m_outVolColor)
  65. Q_PROPERTY(QColor gainReductionColor MEMBER m_gainReductionColor)
  66. Q_PROPERTY(QColor kneeColor MEMBER m_kneeColor)
  67. Q_PROPERTY(QColor kneeColor2 MEMBER m_kneeColor2)
  68. Q_PROPERTY(QColor threshColor MEMBER m_threshColor)
  69. Q_PROPERTY(QColor textColor MEMBER m_textColor)
  70. Q_PROPERTY(QColor graphColor MEMBER m_graphColor)
  71. Q_PROPERTY(QColor resetColor MEMBER m_resetColor)
  72. protected:
  73. void resizeEvent(QResizeEvent *event) override;
  74. void paintEvent(QPaintEvent *event) override;
  75. void wheelEvent(QWheelEvent *event) override;
  76. private slots:
  77. void updateDisplay();
  78. void peakmodeChanged();
  79. void stereoLinkChanged();
  80. void lookaheadChanged();
  81. void limiterChanged();
  82. private:
  83. void makeLargeKnob(Knob * knob, QString hint, QString unit);
  84. void makeSmallKnob(Knob * knob, QString hint, QString unit);
  85. void resetCompressorView();
  86. void drawVisPixmap();
  87. void redrawKnee();
  88. void drawKneePixmap2();
  89. void drawMiscPixmap();
  90. void drawGraph();
  91. QPainter m_p;
  92. QBasicTimer m_updateTimer;
  93. CompressorControls * m_controls;
  94. inline int dbfsToYPoint(float inDbfs);
  95. inline int dbfsToXPoint(float inDbfs);
  96. QPixmap m_visPixmap = QPixmap(MAX_COMP_SCREEN_X, MAX_COMP_SCREEN_Y);
  97. QPixmap m_kneePixmap = QPixmap(MAX_COMP_SCREEN_X, MAX_COMP_SCREEN_Y);
  98. QPixmap m_kneePixmap2 = QPixmap(MAX_COMP_SCREEN_X, MAX_COMP_SCREEN_Y);
  99. QPixmap m_miscPixmap = QPixmap(MAX_COMP_SCREEN_X, MAX_COMP_SCREEN_Y);
  100. QPixmap m_graphPixmap = QPixmap(MAX_COMP_SCREEN_X, MAX_COMP_SCREEN_Y);
  101. int m_lastPoint;
  102. int m_lastGainPoint;
  103. int m_lastKneePoint = 0;
  104. int m_windowSizeX = size().width();
  105. int m_windowSizeY = size().height();
  106. int m_kneeWindowSizeX = m_windowSizeY;
  107. int m_kneeWindowSizeY = m_windowSizeY;
  108. int m_controlsBoxX = 0;
  109. int m_controlsBoxY = 0;
  110. float m_dbRange = 36;
  111. QColor m_inVolAreaColor = QColor(209, 216, 228, 17);
  112. QColor m_inVolColor = QColor(209, 216, 228, 100);
  113. QColor m_outVolAreaColor = QColor(209, 216, 228, 30);
  114. QColor m_outVolColor = QColor(209, 216, 228, 240);
  115. QColor m_gainReductionColor = QColor(180, 100, 100, 210);
  116. QColor m_kneeColor = QColor(39, 171, 95, 255);
  117. QColor m_kneeColor2 = QColor(9, 171, 160, 255);
  118. QColor m_threshColor = QColor(39, 171, 95, 100);
  119. QColor m_textColor = QColor(209, 216, 228, 50);
  120. QColor m_graphColor = QColor(209, 216, 228, 50);
  121. QColor m_resetColor = QColor(200, 100, 15, 200);
  122. float m_peakAvg;
  123. float m_gainAvg;
  124. float m_yPoint;
  125. float m_yGainPoint;
  126. int m_threshYPoint;
  127. int m_threshXPoint;
  128. int m_compPixelMovement;
  129. QLabel * m_controlsBoxLabel;
  130. QLabel * m_rmsEnabledLabel;
  131. QLabel * m_blendEnabledLabel;
  132. QLabel * m_lookaheadEnabledLabel;
  133. QLabel * m_ratioEnabledLabel;
  134. Knob * m_thresholdKnob;
  135. Knob * m_ratioKnob;
  136. Knob * m_attackKnob;
  137. Knob * m_releaseKnob;
  138. Knob * m_kneeKnob;
  139. Knob * m_rangeKnob;
  140. Knob * m_lookaheadLengthKnob;
  141. Knob * m_holdKnob;
  142. Knob * m_rmsKnob;
  143. Knob * m_inBalanceKnob;
  144. Knob * m_outBalanceKnob;
  145. Knob * m_stereoBalanceKnob;
  146. Knob * m_blendKnob;
  147. Knob * m_tiltKnob;
  148. Knob * m_tiltFreqKnob;
  149. Knob * m_mixKnob;
  150. Knob * m_autoAttackKnob;
  151. Knob * m_autoReleaseKnob;
  152. EqFader * m_outFader;
  153. EqFader * m_inFader;
  154. PixmapButton * rmsButton;
  155. PixmapButton * peakButton;
  156. automatableButtonGroup * rmsPeakGroup;
  157. PixmapButton * leftRightButton;
  158. PixmapButton * midSideButton;
  159. automatableButtonGroup * leftRightMidSideGroup;
  160. PixmapButton * compressButton;
  161. PixmapButton * limitButton;
  162. automatableButtonGroup * compressLimitGroup;
  163. PixmapButton * unlinkedButton;
  164. PixmapButton * maximumButton;
  165. PixmapButton * averageButton;
  166. PixmapButton * minimumButton;
  167. PixmapButton * blendButton;
  168. automatableButtonGroup * stereoLinkGroup;
  169. PixmapButton * autoMakeupButton;
  170. PixmapButton * auditionButton;
  171. PixmapButton * feedbackButton;
  172. PixmapButton * lookaheadButton;
  173. QElapsedTimer m_timeElapsed;
  174. int m_timeSinceLastUpdate = 0;
  175. friend class CompressorControls;
  176. } ;
  177. #endif