SymMODEcho.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * SymMODEcho.h
  3. * ------------
  4. * Purpose: Implementation of the SymMOD Echo DSP
  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. class SymMODEcho final : public IMixPlugin
  13. {
  14. public:
  15. enum class DSPType : uint8
  16. {
  17. Off = 0,
  18. Normal,
  19. Cross,
  20. Cross2,
  21. Center,
  22. NumTypes
  23. };
  24. enum Parameters
  25. {
  26. kEchoType = 0,
  27. kEchoDelay,
  28. kEchoFeedback,
  29. kEchoNumParameters
  30. };
  31. // Our settings chunk for file I/O, as it will be written to files
  32. struct PluginChunk
  33. {
  34. char id[4];
  35. uint8 param[kEchoNumParameters];
  36. static PluginChunk Create(uint8 type, uint8 delay, uint8 feedback)
  37. {
  38. static_assert(sizeof(PluginChunk) == 7);
  39. PluginChunk result;
  40. memcpy(result.id, "Echo", 4);
  41. result.param[kEchoType] = type;
  42. result.param[kEchoDelay] = delay;
  43. result.param[kEchoFeedback] = feedback;
  44. return result;
  45. }
  46. static PluginChunk Default()
  47. {
  48. return Create(0, 4, 1);
  49. }
  50. };
  51. std::vector<float> m_delayLine;
  52. uint32 m_writePos = 0; // Current write position in the delay line
  53. float m_feedback = 0.5f;
  54. // Settings chunk for file I/O
  55. PluginChunk m_chunk;
  56. public:
  57. static IMixPlugin* Create(VSTPluginLib& factory, CSoundFile& sndFile, SNDMIXPLUGIN* mixStruct);
  58. SymMODEcho(VSTPluginLib& factory, CSoundFile& sndFile, SNDMIXPLUGIN* mixStruct);
  59. void Release() override { delete this; }
  60. void SaveAllParameters() override;
  61. void RestoreAllParameters(int32 program) override;
  62. int32 GetUID() const override { int32le id; memcpy(&id, "Echo", 4); return id; }
  63. int32 GetVersion() const override { return 0; }
  64. void Idle() override { }
  65. uint32 GetLatency() const override { return 0; }
  66. void Process(float* pOutL, float* pOutR, uint32 numFrames) override;
  67. float RenderSilence(uint32) override { return 0.0f; }
  68. int32 GetNumPrograms() const override { return 0; }
  69. int32 GetCurrentProgram() override { return 0; }
  70. void SetCurrentProgram(int32) override { }
  71. PlugParamIndex GetNumParameters() const override { return kEchoNumParameters; }
  72. PlugParamValue GetParameter(PlugParamIndex index) override;
  73. void SetParameter(PlugParamIndex index, PlugParamValue value) override;
  74. void Resume() override;
  75. void Suspend() override { m_isResumed = false; }
  76. void PositionChanged() override;
  77. bool IsInstrument() const override { return false; }
  78. bool CanRecieveMidiEvents() override { return false; }
  79. bool ShouldProcessSilence() override { return true; }
  80. #ifdef MODPLUG_TRACKER
  81. CString GetDefaultEffectName() override { return _T("Echo"); }
  82. std::pair<PlugParamValue, PlugParamValue> GetParamUIRange(PlugParamIndex param) override;
  83. CString GetParamName(PlugParamIndex param) override;
  84. CString GetParamLabel(PlugParamIndex) override;
  85. CString GetParamDisplay(PlugParamIndex param) override;
  86. CString GetCurrentProgramName() override { return CString(); }
  87. void SetCurrentProgramName(const CString&) override { }
  88. CString GetProgramName(int32) override { return CString(); }
  89. bool HasEditor() const override { return false; }
  90. #endif
  91. int GetNumInputChannels() const override { return 2; }
  92. int GetNumOutputChannels() const override { return 2; }
  93. bool ProgramsAreChunks() const override { return true; }
  94. ChunkData GetChunk(bool) override;
  95. void SetChunk(const ChunkData& chunk, bool) override;
  96. protected:
  97. DSPType GetDSPType() const { return static_cast<DSPType>(m_chunk.param[kEchoType]); }
  98. void RecalculateEchoParams();
  99. };
  100. MPT_BINARY_STRUCT(SymMODEcho::PluginChunk, 7)
  101. OPENMPT_NAMESPACE_END
  102. #endif // NO_PLUGINS