Gargle.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Gargle.h
  3. * --------
  4. * Purpose: Implementation of the DMO Gargle 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 Gargle final : public IMixPlugin
  15. {
  16. protected:
  17. enum Parameters
  18. {
  19. kGargleRate = 0,
  20. kGargleWaveShape,
  21. kGargleNumParameters
  22. };
  23. std::array<float, kGargleNumParameters> m_param;
  24. uint32 m_period, m_periodHalf, m_counter; // In frames
  25. public:
  26. static IMixPlugin* Create(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct);
  27. Gargle(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct);
  28. void Release() override { delete this; }
  29. int32 GetUID() const override { return 0xDAFD8210; }
  30. int32 GetVersion() const override { return 0; }
  31. void Idle() override { }
  32. uint32 GetLatency() const override { return 0; }
  33. void Process(float *pOutL, float *pOutR, uint32 numFrames) override;
  34. float RenderSilence(uint32) override { return 0.0f; }
  35. int32 GetNumPrograms() const override { return 0; }
  36. int32 GetCurrentProgram() override { return 0; }
  37. void SetCurrentProgram(int32) override { }
  38. PlugParamIndex GetNumParameters() const override { return kGargleNumParameters; }
  39. PlugParamValue GetParameter(PlugParamIndex index) override;
  40. void SetParameter(PlugParamIndex index, PlugParamValue value) override;
  41. void Resume() override;
  42. void Suspend() override { m_isResumed = false; }
  43. void PositionChanged() override { m_counter = 0; }
  44. bool IsInstrument() const override { return false; }
  45. bool CanRecieveMidiEvents() override { return false; }
  46. bool ShouldProcessSilence() override { return true; }
  47. #ifdef MODPLUG_TRACKER
  48. CString GetDefaultEffectName() override { return _T("Gargle"); }
  49. CString GetParamName(PlugParamIndex param) override;
  50. CString GetParamLabel(PlugParamIndex) override;
  51. CString GetParamDisplay(PlugParamIndex param) override;
  52. CString GetCurrentProgramName() override { return CString(); }
  53. void SetCurrentProgramName(const CString &) override { }
  54. CString GetProgramName(int32) override { return CString(); }
  55. bool HasEditor() const override { return false; }
  56. #endif
  57. int GetNumInputChannels() const override { return 2; }
  58. int GetNumOutputChannels() const override { return 2; }
  59. protected:
  60. uint32 RateInHertz() const;
  61. void RecalculateGargleParams();
  62. };
  63. } // namespace DMO
  64. OPENMPT_NAMESPACE_END
  65. #endif // !NO_PLUGINS