Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.7 KiB

  1. //
  2. //
  3. //
  4. #ifndef _Flangerp_
  5. #define _Flangerp_
  6. #include "dsdmobse.h"
  7. #include "dmocom.h"
  8. #include "dsdmo.h"
  9. #include "PropertyHelp.h"
  10. #include "param.h"
  11. #define cALLPASS ((float).61803398875) // 1-x^2=x.
  12. #define RVB_LP_COEF ((float).1)
  13. #define MAXALLPASS cALLPASS
  14. #define Delay_len DefineDelayLineSize(8)
  15. class CDirectSoundFlangerDMO :
  16. public CDirectSoundDMO,
  17. public CParamsManager,
  18. public ISpecifyPropertyPages,
  19. public IDirectSoundFXFlanger,
  20. public CParamsManager::UpdateCallback,
  21. public CComBase
  22. {
  23. public:
  24. CDirectSoundFlangerDMO( IUnknown *pUnk, HRESULT *phr );
  25. ~CDirectSoundFlangerDMO();
  26. DECLARE_IUNKNOWN;
  27. STDMETHODIMP NDQueryInterface(REFIID riid, void **ppv);
  28. static CComBase* WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
  29. // InitOnCreation is called by the class factory to give the object a chance to initialize
  30. // immediately after it is created. This is used to prepare the object's parameter information.
  31. HRESULT InitOnCreation();
  32. HRESULT Init();
  33. // Note that an Init function also exists in the CPCMDMO base class and it can be overridden
  34. // to provide initialization for the effect's actual audio processing.
  35. STDMETHOD(Clone) (THIS_ IMediaObjectInPlace **);
  36. /* IFilter */
  37. STDMETHOD(SetAllParameters) (THIS_ LPCDSFXFlanger);
  38. STDMETHOD(GetAllParameters) (THIS_ LPDSFXFlanger);
  39. // ISpecifyPropertyPages
  40. STDMETHOD(GetPages)(CAUUID * pPages) { return PropertyHelp::GetPages(CLSID_DirectSoundPropFlanger, pPages); }
  41. // IPersist methods
  42. virtual HRESULT STDMETHODCALLTYPE GetClassID( CLSID *pClassID );
  43. // IPersistStream
  44. STDMETHOD(IsDirty)(void) { return m_fDirty ? S_OK : S_FALSE; }
  45. STDMETHOD(Load)(IStream *pStm) { return PropertyHelp::Load(this, DSFXFlanger(), pStm); }
  46. STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty) { return PropertyHelp::Save(this, DSFXFlanger(), pStm, fClearDirty); }
  47. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize) { if (!pcbSize) return E_POINTER; pcbSize->QuadPart = sizeof(DSFXFlanger); return S_OK; }
  48. // SetParam handling
  49. STDMETHODIMP SetParam(DWORD dwParamIndex,MP_DATA value) { return SetParamInternal(dwParamIndex, value, false); }
  50. HRESULT SetParamUpdate(DWORD dwParamIndex, MP_DATA value) { return SetParamInternal(dwParamIndex, value, true); }
  51. HRESULT SetParamInternal(DWORD dwParamIndex, MP_DATA value, bool fSkipPasssingToParamManager);
  52. // Overrides
  53. //
  54. HRESULT FBRProcess(DWORD cQuanta, BYTE *pIn, BYTE *pOut);
  55. HRESULT ProcessInPlace(ULONG ulQuanta, LPBYTE pcbData, REFERENCE_TIME rtStart, DWORD dwFlags);
  56. HRESULT Discontinuity();
  57. bool m_fDirty;
  58. protected:
  59. HRESULT CheckInputType(const DMO_MEDIA_TYPE *pmt) {
  60. HRESULT hr = CPCMDMO::CheckInputType(pmt);
  61. if (FAILED(hr)) return hr;
  62. WAVEFORMATEX *pWave = (WAVEFORMATEX*)pmt->pbFormat;
  63. if (pWave->wFormatTag != WAVE_FORMAT_PCM ||
  64. (pWave->wBitsPerSample != 8 && pWave->wBitsPerSample != 16) ||
  65. (pWave->nChannels != 1 && pWave->nChannels != 2)) {
  66. return DMO_E_TYPE_NOT_ACCEPTED;
  67. }
  68. return S_OK;
  69. }
  70. private:
  71. // { EAX
  72. __forceinline void DoOneSample(int *l, int *r);
  73. // Declare internal variables.
  74. #define DECLARE_EAX_VARS(type, var) \
  75. type m_Eax ## var;
  76. DECLARE_EAX_VARS(float, LfoCoef);
  77. DECLARE_EAX_VARS(float, Wetlevel);
  78. DECLARE_EAX_VARS(float, FbCoef);
  79. DECLARE_EAX_VARS(float, DepthCoef);
  80. DECLARE_EAX_VARS(long, FixedptrL);
  81. DECLARE_EAX_VARS(long, FixedptrR);
  82. DECLARE_EAX_VARS(float, Depth);
  83. DECLARE_EAX_VARS(long, Phase);
  84. DECLARE_EAX_VARS(float, Delay);
  85. DECLARE_EAX_VARS(float, Frequency);
  86. DECLARE_EAX_VARS(long, Waveform);
  87. // DECLARE_EAX_VARS(SamplesPerSec);
  88. #define m_EaxSamplesPerSec m_ulSamplingRate
  89. __forceinline int Saturate(float f) {
  90. int i;
  91. #ifdef DONTUSEi386
  92. _asm {
  93. fld f
  94. fistp i
  95. }
  96. #else
  97. i = (int)f;
  98. #endif
  99. if (i > 32767)
  100. i = 32767;
  101. else if ( i < -32768)
  102. i = -32768;
  103. return(i);
  104. }
  105. float m_StateL, m_StateR;
  106. __forceinline float Interpolate(float a, float b, float percent)
  107. {
  108. percent = a + (b - a) * percent;
  109. return(percent);
  110. }
  111. void Bump(void);
  112. DWORD m_ModdelayL1;
  113. DWORD m_ModdelayL;
  114. DWORD m_DelayptrL;
  115. DWORD m_ModdelayR1;
  116. DWORD m_ModdelayR;
  117. DWORD m_DelayptrR;
  118. float m_LfoState[2];
  119. DelayBuffer2<float, Delay_len, 3> m_DelayL;
  120. DelayBuffer2<float, Delay_len, 3> m_DelayR;
  121. DelayBuffer2<float, 0, 3> m_DryDelayL;
  122. DelayBuffer2<float, 0, 3> m_DryDelayR;
  123. // } EAX
  124. };
  125. EXT_STD_CREATE(Flanger);
  126. #endif//