Source code of Windows XP (NT5)
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.

149 lines
4.2 KiB

  1. //
  2. //
  3. //
  4. #ifndef _ParamEqp_
  5. #define _ParamEqp_
  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 CDirectSoundParamEqDMO :
  16. public CDirectSoundDMO,
  17. public CParamsManager,
  18. public ISpecifyPropertyPages,
  19. public IDirectSoundFXParamEq,
  20. public CParamsManager::UpdateCallback,
  21. public CComBase
  22. {
  23. public:
  24. CDirectSoundParamEqDMO( IUnknown *pUnk, HRESULT *phr );
  25. ~CDirectSoundParamEqDMO();
  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_ LPCDSFXParamEq);
  38. STDMETHOD(GetAllParameters) (THIS_ LPDSFXParamEq);
  39. // ISpecifyPropertyPages
  40. STDMETHOD(GetPages)(CAUUID * pPages) { return PropertyHelp::GetPages(CLSID_DirectSoundPropParamEq, 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, DSFXParamEq(), pStm); }
  46. STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty) { return PropertyHelp::Save(this, DSFXParamEq(), pStm, fClearDirty); }
  47. STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize) { if (!pcbSize) return E_POINTER; pcbSize->QuadPart = sizeof(DSFXParamEq); 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. __forceinline void DoOneSampleMono(int *l);
  74. void UpdateCoefficients(void);
  75. // Declare internal variables.
  76. #define DECLARE_EAX_VARS(type, var) \
  77. type m_Eax ## var;
  78. DECLARE_EAX_VARS(float, GainCoefA);
  79. DECLARE_EAX_VARS(float, GainCoefB);
  80. DECLARE_EAX_VARS(float, ApA);
  81. DECLARE_EAX_VARS(float, ApB);
  82. DECLARE_EAX_VARS(float, Scale);
  83. DECLARE_EAX_VARS(float, Gain);
  84. DECLARE_EAX_VARS(float, Center);
  85. DECLARE_EAX_VARS(float, Bandwidth);
  86. // DECLARE_EAX_VARS(float, SamplesPerSec);
  87. #define m_EaxSamplesPerSec m_ulSamplingRate
  88. __forceinline int Saturate(float f) {
  89. int i;
  90. #ifdef DONTUSEi386
  91. _asm {
  92. fld f
  93. fistp i
  94. }
  95. #else
  96. i = (int)f;
  97. #endif
  98. if (i > 32767)
  99. i = 32767;
  100. else if ( i < -32768)
  101. i = -32768;
  102. return(i);
  103. }
  104. float m_StateL, m_StateR;
  105. __forceinline float Interpolate(float a, float b, float percent)
  106. {
  107. percent = a + (b - a) * percent;
  108. return(percent);
  109. }
  110. void Bump(void);
  111. float m_delayL1;
  112. float m_delayL2;
  113. float m_delayR1;
  114. float m_delayR2;
  115. // } EAX
  116. };
  117. EXT_STD_CREATE(ParamEq);
  118. #endif//