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.

252 lines
6.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1998
  6. //
  7. // File: dmstyleobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // dmPerformanceObj.cpp
  11. #include "dmusici.h"
  12. #include "dmusicc.h"
  13. #include "dmusicf.h"
  14. #include "stdafx.h"
  15. #include "Direct.h"
  16. #include "dms.h"
  17. #include "dmChordMapObj.h"
  18. #include "dmSegmentObj.h"
  19. #include "dmStyleObj.h"
  20. #include "dmBandObj.h"
  21. extern void *g_dxj_DirectMusicStyle;
  22. extern void *g_dxj_DirectMusicSegment;
  23. extern void *g_dxj_DirectMusicChordMap;
  24. extern void *g_dxj_DirectMusicBand;
  25. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  26. CONSTRUCTOR(_dxj_DirectMusicStyle, {});
  27. DESTRUCTOR(_dxj_DirectMusicStyle, {});
  28. GETSET_OBJECT(_dxj_DirectMusicStyle);
  29. typedef IDirectMusicSegment* LPDIRECTMUSICSEGMENT;
  30. typedef IDirectMusicPerformance* LPDIRECTMUSICPERFORMANCE;
  31. typedef IDirectMusicChordMap* LPDIRECTMUSICCHORDMAP;
  32. typedef IDirectMusicStyle* LPDIRECTMUSICSTYLE;
  33. HRESULT C_dxj_DirectMusicStyleObject:: getBandName(
  34. /* [in] */ long index,
  35. /* [retval][out] */ BSTR __RPC_FAR *name)
  36. {
  37. HRESULT hr;
  38. WCHAR wstring[MAX_PATH];
  39. ZeroMemory(wstring,MAX_PATH);
  40. hr=m__dxj_DirectMusicStyle->EnumBand((DWORD)index,wstring);
  41. if (hr!=S_OK) return hr;
  42. *name=SysAllocString(wstring);
  43. return hr;
  44. }
  45. HRESULT C_dxj_DirectMusicStyleObject:: getBandCount( long *count)
  46. {
  47. WCHAR wstring[MAX_PATH];
  48. ZeroMemory(wstring,MAX_PATH);
  49. DWORD i=0;
  50. while (S_OK==m__dxj_DirectMusicStyle->EnumBand((DWORD)i++,wstring)){
  51. //make sure dmusic is doing what its docs say it does
  52. if (i>1000000) return E_FAIL;
  53. }
  54. *count=(long)i-1;
  55. return S_OK;
  56. }
  57. HRESULT C_dxj_DirectMusicStyleObject:: getBand(
  58. /* [in] */ BSTR name,
  59. /* [retval][out] */ I_dxj_DirectMusicBand __RPC_FAR *__RPC_FAR *ret)
  60. {
  61. HRESULT hr;
  62. IDirectMusicBand *pBand=NULL;
  63. hr=m__dxj_DirectMusicStyle->GetBand(name,&pBand);
  64. if FAILED(hr) return hr;
  65. if (!pBand) return E_FAIL;
  66. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicBand,pBand,ret);
  67. return hr;
  68. }
  69. HRESULT C_dxj_DirectMusicStyleObject::getDefaultBand(
  70. /* [retval][out] */ I_dxj_DirectMusicBand __RPC_FAR *__RPC_FAR *ret)
  71. {
  72. HRESULT hr;
  73. IDirectMusicBand *pBand=NULL;
  74. *ret=NULL;
  75. hr=m__dxj_DirectMusicStyle->GetDefaultBand(&pBand);
  76. if FAILED(hr) return hr;
  77. if (hr==S_FALSE) return S_OK;
  78. if (!pBand) return E_FAIL;
  79. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicBand,pBand,ret);
  80. return hr;
  81. }
  82. HRESULT C_dxj_DirectMusicStyleObject:: getMotifName(
  83. /* [in] */ long index,
  84. /* [retval][out] */ BSTR __RPC_FAR *name)
  85. {
  86. HRESULT hr;
  87. WCHAR wstring[MAX_PATH];
  88. ZeroMemory(wstring,MAX_PATH);
  89. hr=m__dxj_DirectMusicStyle->EnumMotif((DWORD)index,wstring);
  90. if (hr!=S_OK) return hr;
  91. *name=SysAllocString(wstring);
  92. return hr;
  93. }
  94. HRESULT C_dxj_DirectMusicStyleObject:: getMotifCount( long *count)
  95. {
  96. WCHAR wstring[MAX_PATH];
  97. ZeroMemory(wstring,MAX_PATH);
  98. DWORD i=0;
  99. while (S_OK==m__dxj_DirectMusicStyle->EnumMotif((DWORD)i++,wstring)){
  100. //make sure dmusic is doing what its docs say it does
  101. if (i>1000000) return E_FAIL;
  102. }
  103. *count=(long)i-1;
  104. return S_OK;
  105. }
  106. HRESULT C_dxj_DirectMusicStyleObject:: getMotif(
  107. /* [in] */ BSTR name,
  108. /* [retval][out] */ I_dxj_DirectMusicSegment __RPC_FAR *__RPC_FAR *ret)
  109. {
  110. HRESULT hr;
  111. IDirectMusicSegment *pSeg=NULL;
  112. hr=m__dxj_DirectMusicStyle->GetMotif(name,&pSeg);
  113. if FAILED(hr) return hr;
  114. if (!pSeg) return E_FAIL;
  115. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicSegment,pSeg,ret);
  116. return hr;
  117. }
  118. HRESULT C_dxj_DirectMusicStyleObject:: getChordMapName(
  119. /* [in] */ long index,
  120. /* [retval][out] */ BSTR __RPC_FAR *name)
  121. {
  122. HRESULT hr;
  123. WCHAR wstring[MAX_PATH];
  124. ZeroMemory(wstring,MAX_PATH);
  125. hr=m__dxj_DirectMusicStyle->EnumChordMap((DWORD)index,wstring);
  126. if (hr!=S_OK) return hr;
  127. *name=SysAllocString(wstring);
  128. return hr;
  129. }
  130. HRESULT C_dxj_DirectMusicStyleObject:: getChordMapCount( long *count)
  131. {
  132. WCHAR wstring[MAX_PATH];
  133. ZeroMemory(wstring,MAX_PATH);
  134. DWORD i=0;
  135. while (S_OK==m__dxj_DirectMusicStyle->EnumChordMap((DWORD)i++,wstring)){
  136. //make sure dmusic is doing what its docs say it does
  137. if (i>1000000) return E_FAIL;
  138. }
  139. *count=(long)i-1;
  140. return S_OK;
  141. }
  142. HRESULT C_dxj_DirectMusicStyleObject:: getChordMap(
  143. /* [in] */ BSTR name,
  144. /* [retval][out] */ I_dxj_DirectMusicChordMap __RPC_FAR *__RPC_FAR *ret)
  145. {
  146. HRESULT hr;
  147. IDirectMusicChordMap *pMap=NULL;
  148. hr=m__dxj_DirectMusicStyle->GetChordMap(name,&pMap);
  149. if FAILED(hr) return hr;
  150. if (!pMap) return E_FAIL;
  151. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicChordMap,pMap,ret);
  152. return hr;
  153. }
  154. HRESULT C_dxj_DirectMusicStyleObject:: getDefaultChordMap(
  155. /* [retval][out] */ I_dxj_DirectMusicChordMap __RPC_FAR *__RPC_FAR *ret)
  156. {
  157. HRESULT hr;
  158. IDirectMusicChordMap *pMap=NULL;
  159. *ret=NULL;
  160. hr=m__dxj_DirectMusicStyle->GetDefaultChordMap(&pMap);
  161. if (hr==S_FALSE) return S_OK;
  162. if FAILED(hr) return hr;
  163. if (!pMap) return E_FAIL;
  164. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicChordMap,pMap,ret);
  165. return hr;
  166. }
  167. HRESULT C_dxj_DirectMusicStyleObject:: getEmbellishmentMinLength(
  168. /* [in] */ long type,
  169. /* [in] */ long level,
  170. /* [retval][out] */ long __RPC_FAR *ret)
  171. {
  172. HRESULT hr;
  173. DWORD dwMin=0;
  174. DWORD dwMax=0;
  175. hr=m__dxj_DirectMusicStyle->GetEmbellishmentLength((DWORD)type,(DWORD)level,&dwMin,&dwMax);
  176. *ret=(long)dwMin;
  177. return hr;
  178. }
  179. HRESULT C_dxj_DirectMusicStyleObject:: getEmbellishmentMaxLength(
  180. /* [in] */ long type,
  181. /* [in] */ long level,
  182. /* [retval][out] */ long __RPC_FAR *ret)
  183. {
  184. HRESULT hr;
  185. DWORD dwMin=0;
  186. DWORD dwMax=0;
  187. hr=m__dxj_DirectMusicStyle->GetEmbellishmentLength((DWORD)type,(DWORD)level,&dwMin,&dwMax);
  188. *ret=(long)dwMax;
  189. return hr;
  190. }
  191. HRESULT C_dxj_DirectMusicStyleObject::getTempo(
  192. /* [retval][out] */ double __RPC_FAR *ret)
  193. {
  194. HRESULT hr;
  195. hr=m__dxj_DirectMusicStyle->GetTempo(ret);
  196. return hr;
  197. }
  198. HRESULT C_dxj_DirectMusicStyleObject::getTimeSignature(
  199. /* [out][in] */ DMUS_TIMESIGNATURE_CDESC __RPC_FAR *pTimeSig)
  200. {
  201. HRESULT hr;
  202. if (!pTimeSig) return E_INVALIDARG;
  203. hr=m__dxj_DirectMusicStyle->GetTimeSignature((DMUS_TIMESIGNATURE*)pTimeSig);
  204. return hr;
  205. }
  206. // GetDC