DMOPlugin.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * DMOPlugin.h
  3. * -----------
  4. * Purpose: DirectX Media Object plugin handling / processing.
  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. #if defined(MPT_WITH_DMO)
  10. #include "../PlugInterface.h"
  11. #include <dmoreg.h>
  12. #include <strmif.h>
  13. typedef interface IMediaObject IMediaObject;
  14. typedef interface IMediaObjectInPlace IMediaObjectInPlace;
  15. typedef interface IMediaParamInfo IMediaParamInfo;
  16. typedef interface IMediaParams IMediaParams;
  17. OPENMPT_NAMESPACE_BEGIN
  18. class DMOPlugin final : public IMixPlugin
  19. {
  20. protected:
  21. IMediaObject *m_pMediaObject;
  22. IMediaObjectInPlace *m_pMediaProcess;
  23. IMediaParamInfo *m_pParamInfo;
  24. IMediaParams *m_pMediaParams;
  25. uint32 m_nSamplesPerSec;
  26. const uint32 m_uid;
  27. union
  28. {
  29. int16 *i16;
  30. float *f32;
  31. } m_alignedBuffer;
  32. union
  33. {
  34. int16 i16[MIXBUFFERSIZE * 2 + 16]; // 16-bit PCM Stereo interleaved
  35. float f32[MIXBUFFERSIZE * 2 + 16]; // 32-bit Float Stereo interleaved
  36. } m_interleavedBuffer;
  37. bool m_useFloat;
  38. public:
  39. static IMixPlugin* Create(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct);
  40. protected:
  41. DMOPlugin(VSTPluginLib &factory, CSoundFile &sndFile, SNDMIXPLUGIN *mixStruct, IMediaObject *pMO, IMediaObjectInPlace *pMOIP, uint32 uid);
  42. ~DMOPlugin();
  43. public:
  44. void Release() override { delete this; }
  45. int32 GetUID() const override { return m_uid; }
  46. int32 GetVersion() const override { return 2; }
  47. void Idle() override { }
  48. uint32 GetLatency() const override;
  49. void Process(float *pOutL, float *pOutR, uint32 numFrames) override;
  50. int32 GetNumPrograms() const override { return 0; }
  51. int32 GetCurrentProgram() override { return 0; }
  52. void SetCurrentProgram(int32 /*nIndex*/) override { }
  53. PlugParamIndex GetNumParameters() const override;
  54. PlugParamValue GetParameter(PlugParamIndex index) override;
  55. void SetParameter(PlugParamIndex index, PlugParamValue value) override;
  56. void Resume() override;
  57. void Suspend() override;
  58. void PositionChanged() override;
  59. bool IsInstrument() const override { return false; }
  60. bool CanRecieveMidiEvents() override { return false; }
  61. bool ShouldProcessSilence() override { return true; }
  62. #ifdef MODPLUG_TRACKER
  63. CString GetDefaultEffectName() override { return CString(); }
  64. CString GetParamName(PlugParamIndex param) override;
  65. CString GetParamLabel(PlugParamIndex param) override;
  66. CString GetParamDisplay(PlugParamIndex param) override;
  67. // TODO we could simply add our own preset mechanism. But is it really useful for these plugins?
  68. CString GetCurrentProgramName() override { return CString(); }
  69. void SetCurrentProgramName(const CString &) override { }
  70. CString GetProgramName(int32) override { return CString(); }
  71. bool HasEditor() const override { return false; }
  72. #endif
  73. int GetNumInputChannels() const override { return 2; }
  74. int GetNumOutputChannels() const override { return 2; }
  75. };
  76. OPENMPT_NAMESPACE_END
  77. #endif // MPT_WITH_DMO