CompressorControls.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * CompressorControls.cpp
  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. #include "CompressorControls.h"
  25. #include "Compressor.h"
  26. #include <QDomElement>
  27. #include "Engine.h"
  28. #include "Song.h"
  29. CompressorControls::CompressorControls(CompressorEffect* effect) :
  30. EffectControls(effect),
  31. m_effect(effect),
  32. m_thresholdModel(-8.0f, -60.0f, 0.0f, 0.001f, this, tr("Threshold")),
  33. m_ratioModel(1.8f, 1.0f, 20.0f, 0.001f, this, tr("Ratio")),
  34. m_attackModel(10.0f, 0.005f, 250.f, 0.001f, this, tr("Attack")),
  35. m_releaseModel(100.0f, 1.f, 2500.f, 0.001f, this, tr("Release")),
  36. m_kneeModel(12.0f, 0.0f, 96.0f, 0.01f, this, tr("Knee")),
  37. m_holdModel(0.0f, 0.0f, 500.0f, 0.01f, this, tr("Hold")),
  38. m_rangeModel(-240.0f, -240.0f, 0.0f, 0.01f, this, tr("Range")),
  39. m_rmsModel(1.0f, 0.0f, 250.0f, 0.01f, this, tr("RMS Size")),
  40. m_midsideModel(0.0f, 0.0f, 1.0f, this, tr("Mid/Side")),
  41. m_peakmodeModel(0.0f, 0.0f, 1.0f, this, tr("Peak Mode")),
  42. m_lookaheadLengthModel(0.0f, 0.0f, 20.0f, 0.0001f, this, tr("Lookahead Length")),
  43. m_inBalanceModel(0.0f, -1.0f, 1.0f, 0.0001f, this, tr("Input Balance")),
  44. m_outBalanceModel(0.0f, -1.0f, 1.0f, 0.0001f, this, tr("Output Balance")),
  45. m_limiterModel(0.f, 0.f, 1.0f, this, tr("Limiter")),
  46. m_outGainModel(0.f, -60.f, 30.f, 0.01f, this, tr("Output Gain")),
  47. m_inGainModel(0.f, -60.f, 30.f, 0.01f, this, tr("Input Gain")),
  48. m_blendModel(1.f, 0.f, 3.f, 0.0001f, this, tr("Blend")),
  49. m_stereoBalanceModel(0.0f, -1.0f, 1.0f, 0.0001f, this, tr("Stereo Balance")),
  50. m_autoMakeupModel(false, this, tr("Auto Makeup Gain")),
  51. m_auditionModel(false, this, tr("Audition")),
  52. m_feedbackModel(false, this, tr("Feedback")),
  53. m_autoAttackModel(0.0f, 0.f, 100.0f, 0.01f, this, tr("Auto Attack")),
  54. m_autoReleaseModel(0.0f, 0.f, 100.0f, 0.01f, this, tr("Auto Release")),
  55. m_lookaheadModel(false, this, tr("Lookahead")),
  56. m_tiltModel(0.0f, -6.0f, 6.0f, 0.0001f, this, tr("Tilt")),
  57. m_tiltFreqModel(150.0f, 20.0f, 20000.0f, 0.1f, this, tr("Tilt Frequency")),
  58. m_stereoLinkModel(1.0f, 0.0f, 4.0f, this, tr("Stereo Link")),
  59. m_mixModel(100.0f, 0.f, 100.0f, 0.01f, this, tr("Mix"))
  60. {
  61. m_ratioModel.setScaleLogarithmic(true);
  62. m_holdModel.setScaleLogarithmic(true);
  63. m_attackModel.setScaleLogarithmic(true);
  64. m_releaseModel.setScaleLogarithmic(true);
  65. m_thresholdModel.setScaleLogarithmic(true);
  66. m_rangeModel.setScaleLogarithmic(true);
  67. m_lookaheadLengthModel.setScaleLogarithmic(true);
  68. m_rmsModel.setScaleLogarithmic(true);
  69. m_kneeModel.setScaleLogarithmic(true);
  70. m_tiltFreqModel.setScaleLogarithmic(true);
  71. m_rangeModel.setScaleLogarithmic(true);
  72. }
  73. void CompressorControls::saveSettings(QDomDocument& doc, QDomElement& _this)
  74. {
  75. m_thresholdModel.saveSettings(doc, _this, "threshold");
  76. m_ratioModel.saveSettings(doc, _this, "ratio");
  77. m_attackModel.saveSettings(doc, _this, "attack");
  78. m_releaseModel.saveSettings(doc, _this, "release");
  79. m_kneeModel.saveSettings(doc, _this, "knee");
  80. m_holdModel.saveSettings(doc, _this, "hold");
  81. m_rangeModel.saveSettings(doc, _this, "range");
  82. m_rmsModel.saveSettings(doc, _this, "rms");
  83. m_midsideModel.saveSettings(doc, _this, "midside");
  84. m_peakmodeModel.saveSettings(doc, _this, "peakmode");
  85. m_lookaheadLengthModel.saveSettings(doc, _this, "lookaheadLength");
  86. m_inBalanceModel.saveSettings(doc, _this, "inBalance");
  87. m_outBalanceModel.saveSettings(doc, _this, "outBalance");
  88. m_limiterModel.saveSettings(doc, _this, "limiter");
  89. m_outGainModel.saveSettings(doc, _this, "outGain");
  90. m_inGainModel.saveSettings(doc, _this, "inGain");
  91. m_blendModel.saveSettings(doc, _this, "blend");
  92. m_stereoBalanceModel.saveSettings(doc, _this, "stereoBalance");
  93. m_autoMakeupModel.saveSettings(doc, _this, "autoMakeup");
  94. m_auditionModel.saveSettings(doc, _this, "audition");
  95. m_feedbackModel.saveSettings(doc, _this, "feedback");
  96. m_autoAttackModel.saveSettings(doc, _this, "autoAttack");
  97. m_autoReleaseModel.saveSettings(doc, _this, "autoRelease");
  98. m_lookaheadModel.saveSettings(doc, _this, "lookahead");
  99. m_tiltModel.saveSettings(doc, _this, "tilt");
  100. m_tiltFreqModel.saveSettings(doc, _this, "tiltFreq");
  101. m_stereoLinkModel.saveSettings(doc, _this, "stereoLink");
  102. m_mixModel.saveSettings(doc, _this, "mix");
  103. }
  104. void CompressorControls::loadSettings(const QDomElement& _this)
  105. {
  106. m_thresholdModel.loadSettings(_this, "threshold");
  107. m_ratioModel.loadSettings(_this, "ratio");
  108. m_attackModel.loadSettings(_this, "attack");
  109. m_releaseModel.loadSettings(_this, "release");
  110. m_kneeModel.loadSettings(_this, "knee");
  111. m_holdModel.loadSettings(_this, "hold");
  112. m_rangeModel.loadSettings(_this, "range");
  113. m_rmsModel.loadSettings(_this, "rms");
  114. m_midsideModel.loadSettings(_this, "midside");
  115. m_peakmodeModel.loadSettings(_this, "peakmode");
  116. m_lookaheadLengthModel.loadSettings(_this, "lookaheadLength");
  117. m_inBalanceModel.loadSettings(_this, "inBalance");
  118. m_outBalanceModel.loadSettings(_this, "outBalance");
  119. m_limiterModel.loadSettings(_this, "limiter");
  120. m_outGainModel.loadSettings(_this, "outGain");
  121. m_inGainModel.loadSettings(_this, "inGain");
  122. m_blendModel.loadSettings(_this, "blend");
  123. m_stereoBalanceModel.loadSettings(_this, "stereoBalance");
  124. m_autoMakeupModel.loadSettings(_this, "autoMakeup");
  125. m_auditionModel.loadSettings(_this, "audition");
  126. m_feedbackModel.loadSettings(_this, "feedback");
  127. m_autoAttackModel.loadSettings(_this, "autoAttack");
  128. m_autoReleaseModel.loadSettings(_this, "autoRelease");
  129. m_lookaheadModel.loadSettings(_this, "lookahead");
  130. m_tiltModel.loadSettings(_this, "tilt");
  131. m_tiltFreqModel.loadSettings(_this, "tiltFreq");
  132. m_stereoLinkModel.loadSettings(_this, "stereoLink");
  133. m_mixModel.loadSettings(_this, "mix");
  134. }