WavesReverb.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * WavesReverb.h
  3. * -------------
  4. * Purpose: Implementation of the DMO WavesReverb DSP (for non-Windows platforms)
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #ifndef NO_PLUGINS
  10. #include "../PlugInterface.h"
  11. OPENMPT_NAMESPACE_BEGIN
  12. namespace DMO
  13. {
  14. class WavesReverb final : public IMixPlugin
  15. {
  16. protected:
  17. enum Parameters
  18. {
  19. kRvbInGain = 0,
  20. kRvbReverbMix,
  21. kRvbReverbTime,
  22. kRvbHighFreqRTRatio,
  23. kRvbNumParameters
  24. };
  25. std::array<float, kRvbNumParameters> m_param;
  26. // Parameters and coefficients
  27. float m_dryFactor;
  28. float m_wetFactor;
  29. std::array<float, 10> m_coeffs;
  30. std::array<uint32, 6> m_delay;
  31. // State
  32. struct ReverbState
  33. {
  34. uint32 combPos, allpassPos;
  35. float comb[4096][4];
  36. float allpass1[1024][2];
  37. float allpass2[1024][2];
  38. } m_state;
  39. public:
  40. static IMixPlugin* Create(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct);
  41. WavesReverb(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct);
  42. void Release() override { delete this; }
  43. int32 GetUID() const override { return 0x87FC0268; }
  44. int32 GetVersion() const override { return 0; }
  45. void Idle() override { }
  46. uint32 GetLatency() const override { return 0; }
  47. void Process(float *pOutL, float *pOutR, uint32 numFrames) override;
  48. float RenderSilence(uint32) override { return 0.0f; }
  49. int32 GetNumPrograms() const override { return 0; }
  50. int32 GetCurrentProgram() override { return 0; }
  51. void SetCurrentProgram(int32) override { }
  52. PlugParamIndex GetNumParameters() const override { return kRvbNumParameters; }
  53. PlugParamValue GetParameter(PlugParamIndex index) override;
  54. void SetParameter(PlugParamIndex index, PlugParamValue value) override;
  55. void Resume() override;
  56. void Suspend() override { m_isResumed = false; }
  57. void PositionChanged() override;
  58. bool IsInstrument() const override { return false; }
  59. bool CanRecieveMidiEvents() override { return false; }
  60. bool ShouldProcessSilence() override { return true; }
  61. #ifdef MODPLUG_TRACKER
  62. CString GetDefaultEffectName() override { return _T("WavesReverb"); }
  63. CString GetParamName(PlugParamIndex param) override;
  64. CString GetParamLabel(PlugParamIndex) override;
  65. CString GetParamDisplay(PlugParamIndex param) override;
  66. CString GetCurrentProgramName() override { return CString(); }
  67. void SetCurrentProgramName(const CString &) override { }
  68. CString GetProgramName(int32) override { return CString(); }
  69. bool HasEditor() const override { return false; }
  70. #endif
  71. int GetNumInputChannels() const override { return 2; }
  72. int GetNumOutputChannels() const override { return 2; }
  73. protected:
  74. static float GainInDecibel(float param) { return -96.0f + param * 96.0f; }
  75. float ReverbTime() const { return 0.001f + m_param[kRvbReverbTime] * 2999.999f; }
  76. float HighFreqRTRatio() const { return 0.001f + m_param[kRvbHighFreqRTRatio] * 0.998f; }
  77. void RecalculateWavesReverbParams();
  78. };
  79. } // namespace DMO
  80. OPENMPT_NAMESPACE_END
  81. #endif // !NO_PLUGINS