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.

476 lines
12 KiB

  1. /***************************************************************************
  2. *
  3. * Copyright (C) 1999-2001 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dsdmo.h
  6. * Content: Global declarations for dsdmo.dll.
  7. *
  8. ***************************************************************************/
  9. #ifndef _DSDMO_H_
  10. #define _DSDMO_H_
  11. #include <mmsystem.h>
  12. #include <dsoundp.h> // For effect IID and ClassID declarations
  13. #include "debug.h"
  14. extern double LogNorm[32];
  15. extern float mylog( float finput, unsigned long maxexponent);
  16. extern DWORD g_amPlatform;
  17. extern long g_cComponent;
  18. extern HMODULE g_hModule;
  19. #define EXT_STD_CREATE(x) \
  20. extern CComBase * WINAPI CreateCDirectSound ## x ## DMO(IUnknown *punkOuter, HRESULT *phr);
  21. #define EXT_STD_CAPTURE_CREATE(x) \
  22. extern CComBase * WINAPI CreateCDirectSoundCapture ## x ## DMO(IUnknown *punkOuter, HRESULT *phr);
  23. // Disable exception warnings
  24. #pragma warning(disable:4530)
  25. #define STD_CREATE(x) \
  26. CComBase* WINAPI CreateCDirectSound ## x ## DMO(IUnknown *punkOuter, HRESULT *phr) \
  27. { \
  28. *phr = E_OUTOFMEMORY; \
  29. CDirectSound ## x ## DMO *p = NULL; \
  30. try { \
  31. p = new CDirectSound ## x ## DMO(punkOuter, phr); \
  32. } catch (...) {}; \
  33. if (p) { \
  34. *phr = p->InitOnCreation(); \
  35. if (FAILED(*phr)) \
  36. { \
  37. p->Release(); \
  38. p = NULL; \
  39. } \
  40. } \
  41. else \
  42. { \
  43. Trace(1,"ERROR: Out of memory\n"); \
  44. } \
  45. return p; \
  46. }
  47. #define STD_CAPTURE_CREATE(x) \
  48. CComBase* WINAPI CreateCDirectSoundCapture ## x ## DMO(IUnknown *punkOuter, HRESULT *phr) \
  49. { \
  50. HRESULT hr = E_OUTOFMEMORY; \
  51. CDirectSoundCapture ## x ## DMO *p = NULL; \
  52. try { \
  53. p = new CDirectSoundCapture ## x ## DMO(punkOuter, phr); \
  54. } catch (...) {}; \
  55. if (p) { \
  56. *phr = p->InitOnCreation(); \
  57. if (FAILED(*phr)) \
  58. { \
  59. p->Release(); \
  60. p = NULL; \
  61. } \
  62. } \
  63. else \
  64. { \
  65. Trace(1,"ERROR: Out of memory\n"); \
  66. } \
  67. return p; \
  68. }
  69. // Common #define's and templates for all filters
  70. //
  71. #define MaxSamplesPerSec 96000
  72. #define PI 3.1415926535
  73. #define DefineMsecSize(y, x) ((int)(((x) * (y)) / 1000))
  74. #define DefineDelayLineSize(x) DefineMsecSize(MaxSamplesPerSec, x)
  75. //#define GetMsecPos(x) (DefineDelayLineSize(x))
  76. #define GetMsecPos(x) (DefineMsecSize(m_EaxSamplesPerSec, x))
  77. #define FractMask 0xfff
  78. #define FractMultiplier 0x1000
  79. template <int BufferSize> class DelayBuffer
  80. {
  81. #define DYNAMIC_ARRAYS 1
  82. #if DYNAMIC_ARRAYS
  83. int *Buffer;
  84. #else
  85. int Buffer[BufferSize];
  86. #endif
  87. int BufferPos;
  88. public:
  89. inline void Init(int SamplesPerSec)
  90. {
  91. #if DYNAMIC_ARRAYS
  92. if (SamplesPerSec <= 0) {
  93. if (!SamplesPerSec) Buffer = 0;
  94. else if (Buffer) delete Buffer;
  95. return;
  96. }
  97. if (Buffer) delete Buffer;
  98. Buffer = new int[BufferSize];
  99. #else
  100. if (SamplesPerSec <= 0) return;
  101. #endif
  102. BufferPos = 0;
  103. memset(Buffer, 0, BufferSize * sizeof(int));
  104. }
  105. __forceinline int Pos(int x)
  106. {
  107. x += BufferPos;
  108. while (x < 0)
  109. x += BufferSize * FractMultiplier;
  110. x /= FractMultiplier;
  111. while (x >= BufferSize)
  112. x -= BufferSize;
  113. return(x);
  114. }
  115. __forceinline void Bump(void)
  116. {
  117. if (BufferPos == 0)
  118. BufferPos += BufferSize * FractMultiplier;
  119. if (BufferPos < 0)
  120. BufferPos += BufferSize * FractMultiplier;
  121. BufferPos -= FractMultiplier;
  122. }
  123. __forceinline int& operator[] (int i)
  124. {
  125. return (Buffer[i]);
  126. }
  127. };
  128. template <class type, float Msec, int AdditionalPositions> class DelayBuffer2
  129. {
  130. #if DYNAMIC_ARRAYS
  131. type *Buffer;
  132. #else
  133. union {
  134. type Buffer[DefineDelayLineSize(Msec) + AdditionalPositions];
  135. type BufferDisplay[DefineDelayLineSize(Msec/10) + AdditionalPositions];
  136. };
  137. #endif
  138. int BufferPos;
  139. int BufferSize;
  140. public:
  141. inline HRESULT Init(int SamplesPerSec)
  142. {
  143. HRESULT hr = S_OK;
  144. BufferSize = DefineMsecSize(Msec, SamplesPerSec) + AdditionalPositions;
  145. #if DYNAMIC_ARRAYS
  146. if (SamplesPerSec <= 0) {
  147. if (!SamplesPerSec) Buffer = 0;
  148. else if (Buffer) delete Buffer;
  149. return hr;
  150. }
  151. if (Buffer) delete Buffer;
  152. Buffer = new type[BufferSize];
  153. #else
  154. if (SamplesPerSec <= 0) return;
  155. #endif
  156. BufferPos = 0;
  157. if (Buffer != NULL)
  158. {
  159. memset(Buffer, 0, BufferSize * sizeof(type));
  160. }
  161. else
  162. {
  163. hr = E_OUTOFMEMORY;
  164. }
  165. return hr;
  166. }
  167. __forceinline int FractPos(int x)
  168. {
  169. x *= FractMultiplier;
  170. x += BufferPos;
  171. while (x < 0)
  172. x += BufferSize * FractMultiplier;
  173. x /= FractMultiplier;
  174. while (x >= BufferSize)
  175. x -= BufferSize;
  176. return(x);
  177. }
  178. __forceinline int Pos(int x)
  179. {
  180. x += BufferPos;
  181. while (x < 0)
  182. x += BufferSize * FractMultiplier;
  183. x /= FractMultiplier;
  184. while (x >= BufferSize)
  185. x -= BufferSize;
  186. return(x);
  187. }
  188. __forceinline int LastPos(int x)
  189. {
  190. x = Pos(x + BufferSize - 1);
  191. return(x);
  192. }
  193. __forceinline void Bump(void)
  194. {
  195. if (BufferPos == 0)
  196. BufferPos += BufferSize * FractMultiplier;
  197. if (BufferPos < 0)
  198. BufferPos += BufferSize * FractMultiplier;
  199. BufferPos -= FractMultiplier;
  200. }
  201. __forceinline type& operator[] (int i)
  202. {
  203. return (Buffer[i]);
  204. }
  205. __forceinline void ZeroBuffer(void)
  206. {
  207. if (Buffer != NULL)
  208. ZeroMemory(Buffer,BufferSize * sizeof(type));
  209. }
  210. };
  211. //
  212. //
  213. //
  214. // { EAX
  215. #ifndef _EAXDMO_
  216. #define _EAXDMO_
  217. #define CHECK_PARAM(lo, hi) \
  218. if (value < lo || value > hi) {return DSERR_INVALIDPARAM;} else;
  219. #define PUT_EAX_VALUE(var, val) \
  220. m_Eax ## var = val
  221. #define PUT_EAX_FVAL(var, val) \
  222. m_Eax ## var = (float)(val)
  223. #define PUT_EAX_LVAL(var, val) \
  224. m_Eax ## var = (long)(val)
  225. #define TOFRACTION(x) ((float)x)
  226. #define INTERPOLATE(x, y) PUT_EAX_FVAL(x, (y)) // ??? Smooth it out...
  227. #define SET_MPV_FLOAT(var) \
  228. MP_DATA mpv; \
  229. mpv = (MP_DATA)var;
  230. #define SET_MPV_LONG SET_MPV_FLOAT
  231. enum ChorusFilterParams
  232. {
  233. CFP_Wetdrymix = 0,
  234. CFP_Depth,
  235. CFP_Frequency,
  236. CFP_Waveform,
  237. CFP_Phase,
  238. CFP_Feedback,
  239. CFP_Delay,
  240. CFP_MAX
  241. };
  242. enum CompressorFilterParams
  243. {
  244. CPFP_Gain = 0,
  245. CPFP_Attack,
  246. CPFP_Release,
  247. CPFP_Threshold,
  248. CPFP_Ratio,
  249. CPFP_Predelay,
  250. CPFP_MAX
  251. };
  252. enum DistortionFilterParams
  253. {
  254. DFP_Gain = 0,
  255. DFP_Edge,
  256. DFP_LpCutoff,
  257. DFP_EqCenter,
  258. DFP_EqWidth,
  259. DFP_MAX
  260. };
  261. enum EchoFilterParams
  262. {
  263. EFP_Wetdrymix = 0,
  264. EFP_Feedback,
  265. EFP_DelayLeft,
  266. EFP_DelayRight,
  267. EFP_PanDelay,
  268. EFP_MAX
  269. };
  270. enum FilterParams
  271. {
  272. FFP_Wetdrymix = 0,
  273. FFP_Waveform,
  274. FFP_Frequency,
  275. FFP_Depth,
  276. FFP_Phase,
  277. FFP_Feedback,
  278. FFP_Delay,
  279. FFP_MAX
  280. };
  281. enum ParamEqFilterParams
  282. {
  283. PFP_Center = 0,
  284. PFP_Bandwidth,
  285. PFP_Gain,
  286. PFP_MAX
  287. };
  288. enum GargleFilterParams
  289. {
  290. GFP_Rate = 0,
  291. GFP_Shape,
  292. GFP_MAX
  293. };
  294. enum SVerbParams
  295. {
  296. SVP_Gain = 0,
  297. SVP_Mix,
  298. SVP_ReverbTime,
  299. SVP_Ratio,
  300. SVP_MAX
  301. };
  302. enum MicArrayParams
  303. {
  304. MAP_Enable = 0,
  305. MAP_Reset,
  306. MAP_MAX
  307. };
  308. enum AecParams
  309. {
  310. AECP_Enable = 0,
  311. AECP_NoiseFill,
  312. AECP_Mode,
  313. AECP_MAX
  314. };
  315. enum NoiseSuppressParams
  316. {
  317. NSP_Enable = 0,
  318. NSP_MAX
  319. };
  320. enum AgcParams
  321. {
  322. AGCP_Enable = 0,
  323. AGCP_Reset,
  324. AGCP_MAX
  325. };
  326. #define GET_PUT(x, type) \
  327. STDMETHOD(get_Eax ## x) \
  328. ( THIS_ \
  329. type *Eax ## x \
  330. ) PURE; \
  331. STDMETHOD(put_Eax ## x) \
  332. ( THIS_ \
  333. type Eax ## x \
  334. ) PURE
  335. interface IChorus : public IUnknown
  336. {
  337. public:
  338. GET_PUT(Wetdrymix, float);
  339. GET_PUT(Depth, float);
  340. GET_PUT(Frequency, float);
  341. GET_PUT(Waveform, long);
  342. GET_PUT(Phase, long);
  343. GET_PUT(Feedback, float);
  344. GET_PUT(Delay, float);
  345. };
  346. interface ICompressor : public IUnknown
  347. {
  348. public:
  349. GET_PUT(Gain, float);
  350. GET_PUT(Attack, float);
  351. GET_PUT(Release, float);
  352. GET_PUT(Threshold, float);
  353. GET_PUT(Ratio, float);
  354. GET_PUT(Predelay, float);
  355. };
  356. interface IDistortion : public IUnknown
  357. {
  358. public:
  359. GET_PUT(Gain, float);
  360. GET_PUT(Edge, float);
  361. GET_PUT(LpCutoff, float);
  362. GET_PUT(EqCenter, float);
  363. GET_PUT(EqWidth, float);
  364. };
  365. interface IEcho : public IUnknown
  366. {
  367. public:
  368. GET_PUT(Wetdrymix, float);
  369. GET_PUT(Feedback, float);
  370. GET_PUT(DelayLeft, float);
  371. GET_PUT(DelayRight, float);
  372. GET_PUT(PanDelay, long);
  373. };
  374. interface IFlanger : public IUnknown
  375. {
  376. public:
  377. GET_PUT(Wetdrymix, float);
  378. GET_PUT(Waveform, long);
  379. GET_PUT(Frequency, float);
  380. GET_PUT(Depth, float);
  381. GET_PUT(Phase, long);
  382. GET_PUT(Feedback, float);
  383. GET_PUT(Delay, float);
  384. };
  385. interface IParamEq : public IUnknown
  386. {
  387. public:
  388. GET_PUT(Center, float);
  389. GET_PUT(Bandwidth, float);
  390. GET_PUT(Gain, float);
  391. };
  392. #undef GET_PUT
  393. DEFINE_GUID(CLSID_DirectSoundPropGargle,0x794885CC,0x5EB7,0x46E3,0xA9,0x37,0xAD,0x89,0x0A,0x6C,0x66,0x77);
  394. DEFINE_GUID(CLSID_DirectSoundPropChorus,0x60129CFD,0x2E9B,0x4098,0xAA,0x4B,0xD6,0xCF,0xAD,0xA2,0x65,0xC3);
  395. DEFINE_GUID(CLSID_DirectSoundPropFlanger,0x22AF00DF,0x46B4,0x4F51,0xA3,0x63,0x68,0x54,0xD5,0x2E,0x13,0xA0);
  396. DEFINE_GUID(CLSID_DirectSoundPropDistortion,0x5858107D,0x11EA,0x47B1,0x96,0x94,0x3F,0x29,0xF7,0x68,0x0F,0xB8);
  397. DEFINE_GUID(CLSID_DirectSoundPropEcho,0xD45CF2C7,0x48CF,0x4234,0x86,0xE2,0x45,0x59,0xC3,0x2F,0xAD,0x1A);
  398. DEFINE_GUID(CLSID_DirectSoundPropCompressor,0xED3DC730,0x31E5,0x4108,0xAD,0x8A,0x39,0x62,0xC9,0x30,0x42,0x5E);
  399. DEFINE_GUID(CLSID_DirectSoundPropParamEq,0xAE86C36D,0x808E,0x4B07,0xB7,0x99,0x56,0xD7,0x36,0x1C,0x38,0x35);
  400. DEFINE_GUID(CLSID_DirectSoundPropWavesReverb,0x6A879859,0x3858,0x4322,0x97,0x1A,0xB7,0x05,0xF3,0x49,0xF1,0x24);
  401. DEFINE_GUID(CLSID_DirectSoundPropI3DL2Reverb,0xD3952B77,0x2D22,0x4B72,0x8D,0xF4,0xBA,0x26,0x7A,0x9C,0x12,0xD0);
  402. DEFINE_GUID(CLSID_DirectSoundPropI3DL2Source,0x3DC26D0C,0xBEFF,0x406C,0x89,0xB0,0xCA,0x13,0xE2,0xBD,0x91,0x72);
  403. // } EAX
  404. #endif
  405. #endif // _DSDMO_H_