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.

89 lines
1.5KB

  1. #pragma once
  2. #include "bogaudio.hpp"
  3. #include "dsp/signal.hpp"
  4. using namespace bogaudio::dsp;
  5. extern Model* modelPressor;
  6. namespace bogaudio {
  7. struct Pressor : Module {
  8. enum ParamsIds {
  9. THRESHOLD_PARAM,
  10. RATIO_PARAM,
  11. ATTACK_PARAM,
  12. RELEASE_PARAM,
  13. OUTPUT_GAIN_PARAM,
  14. INPUT_GAIN_PARAM,
  15. DETECTOR_MIX_PARAM,
  16. MODE_PARAM,
  17. DECTECTOR_MODE_PARAM,
  18. KNEE_PARAM,
  19. NUM_PARAMS
  20. };
  21. enum InputsIds {
  22. LEFT_INPUT,
  23. SIDECHAIN_INPUT,
  24. THRESHOLD_INPUT,
  25. RATIO_INPUT,
  26. RIGHT_INPUT,
  27. ATTACK_INPUT,
  28. RELEASE_INPUT,
  29. INPUT_GAIN_INPUT,
  30. OUTPUT_GAIN_INPUT,
  31. NUM_INPUTS
  32. };
  33. enum OutputsIds {
  34. ENVELOPE_OUTPUT,
  35. LEFT_OUTPUT,
  36. RIGHT_OUTPUT,
  37. NUM_OUTPUTS
  38. };
  39. enum LightsIds {
  40. NUM_LIGHTS
  41. };
  42. const int modulationSteps = 100;
  43. int _modulationStep = 0;
  44. float _thresholdDb = 0.0f;
  45. float _ratio = 0.0f;
  46. float _ratioKnob = -1.0f;
  47. float _inGain = -1.0f;
  48. float _inLevel = 0.0f;
  49. float _outGain = -1.0f;
  50. float _outLevel = 0.0f;
  51. bool _compressorMode = true;
  52. bool _rmsDetector = true;
  53. bool _softKnee = true;
  54. float _lastEnv = 0.0f;
  55. float _compressionDb = 0.0f;
  56. SlewLimiter _attackSL;
  57. SlewLimiter _releaseSL;
  58. CrossFader _detectorMix;
  59. RootMeanSquare _detectorRMS;
  60. Compressor _compressor;
  61. NoiseGate _noiseGate;
  62. Amplifier _amplifier;
  63. Saturator _saturator;
  64. Pressor()
  65. : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS)
  66. , _detectorRMS(1000.0f, 1.0f, 50.0f)
  67. {
  68. onReset();
  69. onSampleRateChange();
  70. }
  71. void onReset() override;
  72. void onSampleRateChange() override;
  73. void step() override;
  74. };
  75. } // namespace bogaudio