Flanger.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Flanger.h
  3. * ---------
  4. * Purpose: Implementation of the DMO Flanger 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. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #ifndef NO_PLUGINS
  12. #include "Chorus.h"
  13. OPENMPT_NAMESPACE_BEGIN
  14. namespace DMO
  15. {
  16. class Flanger final : public Chorus
  17. {
  18. protected:
  19. enum Parameters
  20. {
  21. kFlangerWetDryMix = 0,
  22. kFlangerWaveShape,
  23. kFlangerFrequency,
  24. kFlangerDepth,
  25. kFlangerPhase,
  26. kFlangerFeedback,
  27. kFlangerDelay,
  28. kFlangerNumParameters
  29. };
  30. public:
  31. static IMixPlugin* Create(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct);
  32. static IMixPlugin* CreateLegacy(VSTPluginLib& factory, CSoundFile& sndFile, SNDMIXPLUGIN* mixStruct);
  33. Flanger(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct, const bool legacy);
  34. void Release() override { delete this; }
  35. int32 GetUID() const override { return 0xEFCA3D92; }
  36. PlugParamIndex GetNumParameters() const override { return kFlangerNumParameters; }
  37. void SetParameter(PlugParamIndex index, PlugParamValue value) override;
  38. #ifdef MODPLUG_TRACKER
  39. CString GetDefaultEffectName() override { return _T("Flanger"); }
  40. CString GetParamName(PlugParamIndex param) override;
  41. CString GetParamLabel(PlugParamIndex) override;
  42. CString GetParamDisplay(PlugParamIndex param) override;
  43. #endif
  44. protected:
  45. float WetDryMix() const override { return m_param[kFlangerWetDryMix]; }
  46. bool IsTriangle() const override { return m_param[kFlangerWaveShape] < 1; }
  47. float Depth() const override { return m_param[kFlangerDepth]; }
  48. float Feedback() const override { return -99.0f + m_param[kFlangerFeedback] * 198.0f; }
  49. float Delay() const override { return m_param[kFlangerDelay] * 4.0f; }
  50. float FrequencyInHertz() const override { return m_param[kFlangerFrequency] * 10.0f; }
  51. int Phase() const override { return mpt::saturate_round<uint32>(m_param[kFlangerPhase] * 4.0f); }
  52. };
  53. } // namespace DMO
  54. OPENMPT_NAMESPACE_END
  55. #endif // !NO_PLUGINS