Echo.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Echo.h
  3. * ------
  4. * Purpose: Implementation of the DMO Echo 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 Echo final : public IMixPlugin
  15. {
  16. protected:
  17. enum Parameters
  18. {
  19. kEchoWetDry = 0,
  20. kEchoFeedback,
  21. kEchoLeftDelay,
  22. kEchoRightDelay,
  23. kEchoPanDelay,
  24. kEchoNumParameters
  25. };
  26. std::vector<float> m_delayLine; // Echo delay line
  27. float m_param[kEchoNumParameters];
  28. uint32 m_bufferSize; // Delay line length in frames
  29. uint32 m_writePos; // Current write position in the delay line
  30. uint32 m_delayTime[2]; // In frames
  31. uint32 m_sampleRate;
  32. // Echo calculation coefficients
  33. float m_initialFeedback;
  34. bool m_crossEcho;
  35. public:
  36. static IMixPlugin* Create(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct);
  37. Echo(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct);
  38. void Release() override { delete this; }
  39. int32 GetUID() const override { return 0xEF3E932C; }
  40. int32 GetVersion() const override { return 0; }
  41. void Idle() override { }
  42. uint32 GetLatency() const override { return 0; }
  43. void Process(float *pOutL, float *pOutR, uint32 numFrames)override;
  44. float RenderSilence(uint32) override { return 0.0f; }
  45. int32 GetNumPrograms() const override { return 0; }
  46. int32 GetCurrentProgram() override { return 0; }
  47. void SetCurrentProgram(int32) override { }
  48. PlugParamIndex GetNumParameters() const override { return kEchoNumParameters; }
  49. PlugParamValue GetParameter(PlugParamIndex index) override;
  50. void SetParameter(PlugParamIndex index, PlugParamValue value) override;
  51. void Resume() override;
  52. void Suspend() override { m_isResumed = false; }
  53. void PositionChanged() override;
  54. bool IsInstrument() const override { return false; }
  55. bool CanRecieveMidiEvents() override { return false; }
  56. bool ShouldProcessSilence() override { return true; }
  57. #ifdef MODPLUG_TRACKER
  58. CString GetDefaultEffectName() override { return _T("Echo"); }
  59. CString GetParamName(PlugParamIndex param) override;
  60. CString GetParamLabel(PlugParamIndex) override;
  61. CString GetParamDisplay(PlugParamIndex param) override;
  62. CString GetCurrentProgramName() override { return CString(); }
  63. void SetCurrentProgramName(const CString &) override { }
  64. CString GetProgramName(int32) override { return CString(); }
  65. bool HasEditor() const override { return false; }
  66. #endif
  67. int GetNumInputChannels() const override { return 2; }
  68. int GetNumOutputChannels() const override { return 2; }
  69. protected:
  70. void RecalculateEchoParams();
  71. };
  72. } // namespace DMO
  73. OPENMPT_NAMESPACE_END
  74. #endif // !NO_PLUGINS