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.

1139 lines
32 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: dmperformanceobj.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 "dmPerformanceObj.h"
  18. #include "dmSegmentStateObj.h"
  19. #include "dmSegmentObj.h"
  20. #include "dmStyleObj.h"
  21. #include "dmChordMapObj.h"
  22. //#include "dsoundobj.h"
  23. extern void *g_dxj_DirectMusicPerformance;
  24. extern void *g_dxj_DirectMusicSegmentState;
  25. extern void *g_dxj_DirectMusicSegment;
  26. extern void *g_dxj_DirectMusicStyle;
  27. extern void *g_dxj_DirectMusicChordMap;
  28. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  29. extern CRITICAL_SECTION g_cbCriticalSection;
  30. CONSTRUCTOR(_dxj_DirectMusicPerformance, {InternalInit();});
  31. DESTRUCTOR(_dxj_DirectMusicPerformance, {InternalCleanup();});
  32. GETSET_OBJECT(_dxj_DirectMusicPerformance);
  33. typedef IDirectMusicSegment* LPDIRECTMUSICSEGMENT;
  34. typedef IDirectMusicSegmentState* LPDIRECTMUSICSEGMENTSTATE ;
  35. HRESULT C_dxj_DirectMusicPerformanceObject::InternalInit(){
  36. m_pDM = NULL;
  37. m_pPort=NULL;
  38. m_portid=-1;
  39. m_number_of_groups=4;
  40. return S_OK;
  41. }
  42. HRESULT C_dxj_DirectMusicPerformanceObject::InternalCleanup(){
  43. if (m_pPort) m_pPort->Release();
  44. if (m_pDM) m_pDM->Release();
  45. m__dxj_DirectMusicPerformance->CloseDown();
  46. return S_OK;
  47. }
  48. HRESULT C_dxj_DirectMusicPerformanceObject::init(
  49. /* [in] */ I_dxj_DirectSound __RPC_FAR *DirectSound,
  50. /* [in] */ long hWnd)
  51. {
  52. HRESULT hr;
  53. DO_GETOBJECT_NOTNULL(LPDIRECTSOUND,pSound,DirectSound);
  54. hr=m__dxj_DirectMusicPerformance->Init(&m_pDM,pSound,(HWND)hWnd);
  55. if FAILED(hr) return hr;
  56. //hr=m__dxj_DirectMusicPerformance->AddPort(NULL);
  57. return hr;
  58. }
  59. HRESULT C_dxj_DirectMusicPerformanceObject::closeDown( )
  60. {
  61. HRESULT hr;
  62. hr=m__dxj_DirectMusicPerformance->CloseDown();
  63. return hr;
  64. }
  65. #define VBREF_TO_REALREFTIME(startTime) ((__int64)startTime*10000)
  66. #define REALREF_TO_VBREFTIME(startTime) ((long)(startTime/10000))
  67. HRESULT C_dxj_DirectMusicPerformanceObject::playSegment(
  68. /* [in] */ I_dxj_DirectMusicSegment __RPC_FAR *segment,
  69. /* [in] */ long lFlags,
  70. /* [in] */ long startTime,
  71. /* [retval][out] */ I_dxj_DirectMusicSegmentState __RPC_FAR *__RPC_FAR *segmentState)
  72. {
  73. HRESULT hr;
  74. if (!segment) return E_INVALIDARG;
  75. if (!segmentState) return E_INVALIDARG;
  76. DO_GETOBJECT_NOTNULL(IDirectMusicSegment*,pSeg,segment);
  77. IDirectMusicSegmentState *pState=NULL;
  78. __int64 outTime=(__int64)startTime;
  79. if (lFlags & DMUS_SEGF_REFTIME) outTime=VBREF_TO_REALREFTIME(startTime);
  80. hr=m__dxj_DirectMusicPerformance->PlaySegment(pSeg,(DWORD)lFlags,outTime,&pState);
  81. if FAILED(hr) return hr;
  82. if (!pState) return E_FAIL;
  83. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicSegmentState,pState,segmentState);
  84. if (*segmentState==NULL) return E_OUTOFMEMORY;
  85. return hr;
  86. }
  87. HRESULT C_dxj_DirectMusicPerformanceObject::getSegmentState(
  88. /* [in] */ long mtTime,
  89. /* [retval][out] */ I_dxj_DirectMusicSegmentState __RPC_FAR *__RPC_FAR *segmentState)
  90. {
  91. HRESULT hr;
  92. IDirectMusicSegmentState *pState=NULL;
  93. hr=m__dxj_DirectMusicPerformance->GetSegmentState(&pState,(MUSIC_TIME)mtTime);
  94. if FAILED(hr) return hr;
  95. if (!pState) return E_FAIL;
  96. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicSegmentState,pState,segmentState);
  97. if (*segmentState==NULL) return E_OUTOFMEMORY;
  98. return hr;
  99. }
  100. HRESULT C_dxj_DirectMusicPerformanceObject::invalidate(
  101. /* [in] */ long mtTime,
  102. /* [in] */ long flags)
  103. {
  104. HRESULT hr;
  105. hr=m__dxj_DirectMusicPerformance->Invalidate((MUSIC_TIME)mtTime,(DWORD)flags);
  106. return hr;
  107. }
  108. HRESULT C_dxj_DirectMusicPerformanceObject::isPlaying(
  109. /* [in] */ I_dxj_DirectMusicSegment __RPC_FAR *segment,
  110. /* [in] */ I_dxj_DirectMusicSegmentState __RPC_FAR *segmentState,
  111. /* [retval][out] */ VARIANT_BOOL __RPC_FAR *b)
  112. {
  113. HRESULT hr;
  114. DO_GETOBJECT_NOTNULL(LPDIRECTMUSICSEGMENT,pSeg,segment);
  115. DO_GETOBJECT_NOTNULL(LPDIRECTMUSICSEGMENTSTATE,pSegState,segmentState);
  116. hr=m__dxj_DirectMusicPerformance->IsPlaying(pSeg,pSegState);
  117. if (hr==S_FALSE){
  118. *b=VARIANT_FALSE;
  119. }
  120. else if (hr==S_OK){
  121. *b=VARIANT_TRUE;
  122. }
  123. else{
  124. return hr;
  125. }
  126. return S_OK;
  127. }
  128. HRESULT C_dxj_DirectMusicPerformanceObject::addNotificationType(CONST_DMUS_NOTIFICATION_TYPE t)
  129. {
  130. HRESULT hr;
  131. GUID g;
  132. switch (t){
  133. case DMUS_NOTIFY_ON_CHORD:
  134. g=GUID_NOTIFICATION_CHORD;
  135. break;
  136. case DMUS_NOTIFY_ON_COMMAND:
  137. g=GUID_NOTIFICATION_COMMAND;
  138. break;
  139. case DMUS_NOTIFY_ON_MEASUREANDBEAT:
  140. g=GUID_NOTIFICATION_MEASUREANDBEAT;
  141. break;
  142. case DMUS_NOTIFY_ON_PERFORMANCE:
  143. g=GUID_NOTIFICATION_PERFORMANCE;
  144. break;
  145. case DMUS_NOTIFY_ON_SEGMENT:
  146. g=GUID_NOTIFICATION_SEGMENT;
  147. break;
  148. default:
  149. return E_INVALIDARG;
  150. }
  151. hr=m__dxj_DirectMusicPerformance->AddNotificationType(g);
  152. return hr;
  153. }
  154. HRESULT C_dxj_DirectMusicPerformanceObject::removeNotificationType( /* [in] */CONST_DMUS_NOTIFICATION_TYPE t)
  155. {
  156. HRESULT hr;
  157. GUID g;
  158. switch (t){
  159. case DMUS_NOTIFY_ON_CHORD:
  160. g=GUID_NOTIFICATION_CHORD;
  161. break;
  162. case DMUS_NOTIFY_ON_COMMAND:
  163. g=GUID_NOTIFICATION_COMMAND;
  164. break;
  165. case DMUS_NOTIFY_ON_MEASUREANDBEAT:
  166. g=GUID_NOTIFICATION_MEASUREANDBEAT;
  167. break;
  168. case DMUS_NOTIFY_ON_PERFORMANCE:
  169. g=GUID_NOTIFICATION_PERFORMANCE;
  170. break;
  171. case DMUS_NOTIFY_ON_SEGMENT:
  172. g=GUID_NOTIFICATION_SEGMENT;
  173. break;
  174. default:
  175. return E_INVALIDARG;
  176. }
  177. hr=m__dxj_DirectMusicPerformance->RemoveNotificationType(g);
  178. return hr;
  179. }
  180. HRESULT C_dxj_DirectMusicPerformanceObject::setNotificationHandle( /* [in] */ long hnd)
  181. {
  182. HRESULT hr;
  183. hr=m__dxj_DirectMusicPerformance->SetNotificationHandle((HWND)hnd,0);
  184. return hr;
  185. }
  186. HRESULT C_dxj_DirectMusicPerformanceObject::getNotificationPMSG( DMUS_NOTIFICATION_PMSG_CDESC *pMsgOut, VARIANT_BOOL *bOut)
  187. {
  188. HRESULT hr;
  189. DMUS_NOTIFICATION_PMSG *pMsg=NULL;
  190. if (!pMsgOut) return E_INVALIDARG;
  191. if (!bOut) return E_INVALIDARG;
  192. hr=m__dxj_DirectMusicPerformance->GetNotificationPMsg(&pMsg);
  193. if FAILED(hr) return hr;
  194. *bOut=VARIANT_FALSE;
  195. if (!pMsg) return S_OK;
  196. if (hr!=S_FALSE) *bOut=VARIANT_TRUE;
  197. pMsgOut->mtTime=(long)pMsg->mtTime;
  198. pMsgOut->ctTime=(long)REALREF_TO_VBREFTIME(pMsg->rtTime);
  199. pMsgOut->lFlags=(long)pMsg->dwFlags;
  200. pMsgOut->lNotificationOption =pMsg->dwNotificationOption;
  201. pMsgOut->lField1=pMsg->dwField1;
  202. pMsgOut->lField2=pMsg->dwField2;
  203. if (0==memcmp(&GUID_NOTIFICATION_CHORD,&pMsg->guidNotificationType,sizeof(GUID))){
  204. pMsgOut->lNotificationType=DMUS_NOTIFY_ON_CHORD;
  205. }
  206. else if (0==memcmp(&GUID_NOTIFICATION_COMMAND,&pMsg->guidNotificationType,sizeof(GUID))){
  207. pMsgOut->lNotificationType=DMUS_NOTIFY_ON_COMMAND;
  208. }
  209. else if (0==memcmp(&GUID_NOTIFICATION_MEASUREANDBEAT,&pMsg->guidNotificationType,sizeof(GUID))){
  210. pMsgOut->lNotificationType=DMUS_NOTIFY_ON_MEASUREANDBEAT;
  211. }
  212. else if (0==memcmp(&GUID_NOTIFICATION_PERFORMANCE,&pMsg->guidNotificationType,sizeof(GUID))){
  213. pMsgOut->lNotificationType=DMUS_NOTIFY_ON_PERFORMANCE;
  214. }
  215. else if (0==memcmp(&GUID_NOTIFICATION_SEGMENT,&pMsg->guidNotificationType,sizeof(GUID))){
  216. pMsgOut->lNotificationType=DMUS_NOTIFY_ON_SEGMENT;
  217. }
  218. else {
  219. pMsgOut->lNotificationType=0;
  220. }
  221. m__dxj_DirectMusicPerformance->FreePMsg((DMUS_PMSG *)pMsg);
  222. return hr;
  223. }
  224. HRESULT C_dxj_DirectMusicPerformanceObject::musicToClockTime( /* [in] */ long mtTime,
  225. /* [retval][out] */ long __RPC_FAR *rtTime)
  226. {
  227. HRESULT hr;
  228. __int64 outTime;
  229. hr=m__dxj_DirectMusicPerformance->MusicToReferenceTime((MUSIC_TIME)mtTime,&outTime);
  230. if FAILED(hr) return hr;
  231. *rtTime=REALREF_TO_VBREFTIME(outTime);
  232. return hr;
  233. }
  234. HRESULT C_dxj_DirectMusicPerformanceObject::clockToMusicTime( /* [in] */ long rtTime,
  235. /* [retval][out] */ long __RPC_FAR *mtTime)
  236. {
  237. HRESULT hr;
  238. __int64 outTime=VBREF_TO_REALREFTIME(rtTime);;
  239. hr=m__dxj_DirectMusicPerformance->ReferenceToMusicTime(outTime,(MUSIC_TIME*)mtTime);
  240. return hr;
  241. }
  242. HRESULT C_dxj_DirectMusicPerformanceObject::getMusicTime( /* [retval][out] */ long __RPC_FAR *mtTime)
  243. {
  244. HRESULT hr;
  245. hr=m__dxj_DirectMusicPerformance->GetTime(NULL,(MUSIC_TIME*)mtTime);
  246. return hr;
  247. }
  248. HRESULT C_dxj_DirectMusicPerformanceObject::getClockTime( /* [retval][out] */ long __RPC_FAR *rtTime)
  249. {
  250. HRESULT hr;
  251. __int64 outTime=0;
  252. hr=m__dxj_DirectMusicPerformance->GetTime(&outTime,NULL);
  253. *rtTime=REALREF_TO_VBREFTIME(outTime);
  254. return hr;
  255. }
  256. HRESULT C_dxj_DirectMusicPerformanceObject::getPrepareTime( /* [retval][out] */ long __RPC_FAR *pTime)
  257. {
  258. HRESULT hr;
  259. hr=m__dxj_DirectMusicPerformance->GetPrepareTime((DWORD*)pTime);
  260. return hr;
  261. }
  262. HRESULT C_dxj_DirectMusicPerformanceObject::getBumperLength(/* [retval][out] */ long __RPC_FAR *pTime)
  263. {
  264. HRESULT hr;
  265. hr=m__dxj_DirectMusicPerformance->GetBumperLength((DWORD*)pTime);
  266. return hr;
  267. }
  268. HRESULT C_dxj_DirectMusicPerformanceObject::getLatencyTime( /* [retval][out] */ long __RPC_FAR *pTime)
  269. {
  270. HRESULT hr;
  271. __int64 t;
  272. if (!pTime) return E_INVALIDARG;
  273. hr=m__dxj_DirectMusicPerformance->GetLatencyTime(&t);
  274. *pTime=REALREF_TO_VBREFTIME(t);
  275. return hr;
  276. }
  277. HRESULT C_dxj_DirectMusicPerformanceObject::getQueueTime( /* [retval][out] */ long __RPC_FAR *pTime)
  278. {
  279. HRESULT hr;
  280. __int64 t;
  281. if (!pTime) return E_INVALIDARG;
  282. hr=m__dxj_DirectMusicPerformance->GetQueueTime(&t);
  283. *pTime=REALREF_TO_VBREFTIME(t);
  284. return hr;
  285. }
  286. HRESULT C_dxj_DirectMusicPerformanceObject::getResolvedTime( /* [in] */ long rtTime, /* [in] */ long flags, /* [retval][out] */ long __RPC_FAR *ret)
  287. {
  288. HRESULT hr;
  289. __int64 outtime1= VBREF_TO_REALREFTIME(rtTime);
  290. __int64 outtime2=0;
  291. hr=m__dxj_DirectMusicPerformance->GetResolvedTime(outtime1,&outtime2,(DWORD)flags);
  292. *ret=REALREF_TO_VBREFTIME(outtime2);
  293. return hr;
  294. }
  295. HRESULT C_dxj_DirectMusicPerformanceObject::setPrepareTime( /* [retval][out] */ long t)
  296. {
  297. HRESULT hr;
  298. hr=m__dxj_DirectMusicPerformance->SetPrepareTime((DWORD)t);
  299. return hr;
  300. }
  301. HRESULT C_dxj_DirectMusicPerformanceObject::setBumperLength(/* [retval][out] */ long t)
  302. {
  303. HRESULT hr;
  304. hr=m__dxj_DirectMusicPerformance->SetBumperLength((DWORD)t);
  305. return hr;
  306. }
  307. HRESULT C_dxj_DirectMusicPerformanceObject::adjustTime(
  308. /* [retval][out] */ long t)
  309. {
  310. HRESULT hr;
  311. REFERENCE_TIME rt =(REFERENCE_TIME)t;
  312. hr=m__dxj_DirectMusicPerformance->AdjustTime(rt);
  313. return hr;
  314. }
  315. HRESULT C_dxj_DirectMusicPerformanceObject::setMasterAutoDownload( /* [in] */ VARIANT_BOOL bval)
  316. {
  317. HRESULT hr;
  318. BOOL b=(BOOL)(bval==VARIANT_TRUE);
  319. hr=m__dxj_DirectMusicPerformance->SetGlobalParam(GUID_PerfAutoDownload,(void*)&b,sizeof(BOOL));
  320. return hr;
  321. }
  322. HRESULT C_dxj_DirectMusicPerformanceObject::getMasterAutoDownload( /* [in] */ VARIANT_BOOL *bIn)
  323. {
  324. HRESULT hr;
  325. BOOL b;
  326. hr=m__dxj_DirectMusicPerformance->GetGlobalParam(GUID_PerfAutoDownload,(void*) &b,sizeof(BOOL));
  327. if (b){
  328. *bIn=VARIANT_TRUE;
  329. }
  330. else{
  331. *bIn=VARIANT_FALSE;
  332. }
  333. return hr;
  334. }
  335. HRESULT C_dxj_DirectMusicPerformanceObject::setMasterTempo( /* [in] */ float tempo)
  336. {
  337. HRESULT hr;
  338. hr=m__dxj_DirectMusicPerformance->SetGlobalParam( GUID_PerfMasterTempo ,(void*) &tempo,sizeof(float));
  339. return hr;
  340. }
  341. HRESULT C_dxj_DirectMusicPerformanceObject::getMasterTempo( /* [in] */ float *tempo)
  342. {
  343. HRESULT hr;
  344. hr=m__dxj_DirectMusicPerformance->GetGlobalParam( GUID_PerfMasterTempo ,(void*) tempo,sizeof(float));
  345. return hr;
  346. }
  347. HRESULT C_dxj_DirectMusicPerformanceObject::setMasterVolume( /* [in] */ long vol)
  348. {
  349. HRESULT hr;
  350. hr=m__dxj_DirectMusicPerformance->SetGlobalParam(GUID_PerfMasterVolume ,(void*) &vol,sizeof(long));
  351. return hr;
  352. }
  353. HRESULT C_dxj_DirectMusicPerformanceObject::getMasterVolume( /* [in] */ long *vol)
  354. {
  355. HRESULT hr;
  356. hr=m__dxj_DirectMusicPerformance->GetGlobalParam(GUID_PerfMasterVolume ,(void*) vol,sizeof(long));
  357. return hr;
  358. }
  359. HRESULT C_dxj_DirectMusicPerformanceObject::setMasterGrooveLevel( /* [in] */ short level)
  360. {
  361. HRESULT hr;
  362. char l=(char)level;
  363. hr=m__dxj_DirectMusicPerformance->SetGlobalParam(GUID_PerfMasterGrooveLevel ,(void*) &l,sizeof(char));
  364. return hr;
  365. }
  366. HRESULT C_dxj_DirectMusicPerformanceObject::getMasterGrooveLevel( /* [in] */ short *level)
  367. {
  368. HRESULT hr;
  369. if (!level) return E_INVALIDARG;
  370. char l=0;
  371. hr=m__dxj_DirectMusicPerformance->GetGlobalParam(GUID_PerfMasterGrooveLevel ,(void*) &l,sizeof(char));
  372. *level=(short)l;
  373. return hr;
  374. }
  375. HRESULT C_dxj_DirectMusicPerformanceObject::stop(
  376. /* [in] */ I_dxj_DirectMusicSegment __RPC_FAR *segment,
  377. /* [in] */ I_dxj_DirectMusicSegmentState __RPC_FAR *segmentState,
  378. /* [in] */ long endTime,
  379. /* [in] */ long lFlags)
  380. {
  381. HRESULT hr;
  382. DO_GETOBJECT_NOTNULL(LPDIRECTMUSICSEGMENT,pSeg,segment);
  383. DO_GETOBJECT_NOTNULL(LPDIRECTMUSICSEGMENTSTATE,pSegState,segmentState);
  384. __int64 outTime=(__int64)endTime;
  385. if (lFlags & DMUS_SEGF_REFTIME) outTime=VBREF_TO_REALREFTIME(endTime);
  386. hr=m__dxj_DirectMusicPerformance->Stop(pSeg,pSegState,(MUSIC_TIME)outTime,(DWORD)lFlags);
  387. return hr;
  388. }
  389. HRESULT C_dxj_DirectMusicPerformanceObject::Reset(long resetFlags)
  390. {
  391. DMUS_SYSEX_PMSG *pGMReset;
  392. BYTE abGMReset[] = {0xF0,0x7E,0x7F,0x09,0x01,0xF7};
  393. DWORD dwLen;
  394. HRESULT hr=S_OK;
  395. if (!resetFlags){
  396. dwLen = sizeof(abGMReset)/sizeof(abGMReset[0]);
  397. if(SUCCEEDED( m__dxj_DirectMusicPerformance->AllocPMsg( sizeof(DMUS_SYSEX_PMSG) + dwLen,
  398. (DMUS_PMSG**)&pGMReset )))
  399. {
  400. ZeroMemory(pGMReset, sizeof(pGMReset));
  401. pGMReset->dwSize = sizeof(DMUS_SYSEX_PMSG);
  402. pGMReset->dwPChannel = 0;
  403. pGMReset->dwVirtualTrackID = 0;
  404. pGMReset->dwType = DMUS_PMSGT_SYSEX ;
  405. pGMReset->dwVoiceID = 0;
  406. pGMReset->dwGroupID = 0xFFFFFFFF;
  407. pGMReset->dwLen = dwLen;
  408. memcpy(pGMReset->abData, abGMReset, dwLen);
  409. if (SUCCEEDED(m__dxj_DirectMusicPerformance->GetTime(NULL, &pGMReset->mtTime)))
  410. {
  411. pGMReset->dwFlags = DMUS_PMSGF_MUSICTIME | DMUS_PMSGF_TOOL_IMMEDIATE;
  412. }
  413. hr=m__dxj_DirectMusicPerformance->SendPMsg((DMUS_PMSG*)pGMReset);
  414. }
  415. }
  416. else if(resetFlags==1){
  417. //1) Find out what port we're playing through
  418. //2) Close the port
  419. //3) Open the port back up.
  420. hr=setPort(m_portid,m_number_of_groups);
  421. }
  422. else {
  423. hr=E_INVALIDARG;
  424. }
  425. return hr;
  426. }
  427. HRESULT C_dxj_DirectMusicPerformanceObject::getStyle(
  428. /* [in] */ long mtTime,
  429. /* [in] */ long *mtUntil,
  430. /* [retval][out] */ I_dxj_DirectMusicStyle __RPC_FAR *__RPC_FAR *ret)
  431. {
  432. HRESULT hr;
  433. IDirectMusicStyle *pStyle=NULL;
  434. if (!ret) return E_INVALIDARG;
  435. *ret=NULL;
  436. hr=m__dxj_DirectMusicPerformance->GetParam(GUID_IDirectMusicStyle,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)mtTime,(MUSIC_TIME*)mtUntil,&pStyle );
  437. if FAILED(hr) return hr;
  438. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicStyle,pStyle,ret);
  439. if (*ret==NULL) return E_OUTOFMEMORY;
  440. return hr;
  441. }
  442. HRESULT C_dxj_DirectMusicPerformanceObject::getChordMap(
  443. /* [in] */ long mtTime,
  444. /* [in] */ long *mtUntil,
  445. /* [retval][out] */ I_dxj_DirectMusicChordMap __RPC_FAR *__RPC_FAR *ret)
  446. {
  447. HRESULT hr;
  448. IDirectMusicChordMap *pMap=NULL;
  449. if (!ret) return E_INVALIDARG;
  450. *ret=NULL;
  451. hr=m__dxj_DirectMusicPerformance->GetParam(GUID_IDirectMusicChordMap,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)mtTime,(MUSIC_TIME*)mtUntil,&pMap );
  452. if FAILED(hr) return hr;
  453. INTERNAL_CREATE_NOADDREF(_dxj_DirectMusicChordMap,pMap,ret);
  454. if (*ret==NULL) return E_OUTOFMEMORY;
  455. return hr;
  456. }
  457. HRESULT C_dxj_DirectMusicPerformanceObject::getCommand(
  458. /* [in] */ long mtTime,
  459. /* [in] */ long *mtUntil,
  460. /* [retval][out] */ Byte __RPC_FAR *command)
  461. {
  462. HRESULT hr;
  463. DMUS_COMMAND_PARAM cmd;
  464. if (!command) return E_INVALIDARG;
  465. hr=m__dxj_DirectMusicPerformance->GetParam(GUID_CommandParam,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)mtTime,(MUSIC_TIME*)mtUntil,&cmd );
  466. if FAILED(hr) return hr;
  467. *command=cmd.bCommand;
  468. return hr;
  469. }
  470. HRESULT C_dxj_DirectMusicPerformanceObject::getGrooveLevel(
  471. /* [in] */ long mtTime,
  472. /* [in] */ long *mtUntil,
  473. /* [retval][out] */ Byte __RPC_FAR *level)
  474. {
  475. HRESULT hr;
  476. DMUS_COMMAND_PARAM cmd;
  477. if (!level) return E_INVALIDARG;
  478. hr=m__dxj_DirectMusicPerformance->GetParam(GUID_CommandParam,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)mtTime,(MUSIC_TIME*)mtUntil,&cmd );
  479. if FAILED(hr) return hr;
  480. *level=cmd.bGrooveLevel;
  481. return hr;
  482. }
  483. HRESULT C_dxj_DirectMusicPerformanceObject::getTempo(
  484. /* [in] */ long mtTime,
  485. /* [in] */ long *mtUntil,
  486. /* [retval][out] */ double __RPC_FAR *tempo)
  487. {
  488. HRESULT hr;
  489. DMUS_TEMPO_PARAM tmp;
  490. if (!tempo) return E_INVALIDARG;
  491. hr=m__dxj_DirectMusicPerformance->GetParam(GUID_TempoParam,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)mtTime,(MUSIC_TIME*)mtUntil,&tmp );
  492. if FAILED(hr) return hr;
  493. *tempo=tmp.dblTempo;
  494. return hr;
  495. }
  496. HRESULT C_dxj_DirectMusicPerformanceObject::getTimeSig(
  497. /* [in] */ long mtTime,
  498. /* [in] */ long *mtUntil,
  499. /* [out][in] */ DMUS_TIMESIGNATURE_CDESC __RPC_FAR *timeSig)
  500. {
  501. HRESULT hr;
  502. if (!timeSig) return E_INVALIDARG;
  503. hr=m__dxj_DirectMusicPerformance->GetParam(GUID_TimeSignature,0xFFFFFFFF,(DWORD)0,(MUSIC_TIME)mtTime,(MUSIC_TIME*)mtUntil,(DMUS_TIMESIGNATURE*)timeSig);
  504. return hr;
  505. }
  506. HRESULT C_dxj_DirectMusicPerformanceObject::sendNotePMSG(
  507. /* [in] */ long mtTime,
  508. /* [in] */ long flags,
  509. /* [in] */ long channel,
  510. /* [in] */ DMUS_NOTE_PMSG_CDESC __RPC_FAR *msg)
  511. {
  512. HRESULT hr;
  513. DMUS_NOTE_PMSG *pPMSG=NULL;
  514. if (!msg) return E_INVALIDARG;
  515. hr= m__dxj_DirectMusicPerformance->AllocPMsg( sizeof(DMUS_NOTE_PMSG),(DMUS_PMSG**)&pPMSG);
  516. if FAILED(hr) return hr;
  517. //memcpy(pPMSG,msg,sizeof(DMUS_NOTE_PMSG));
  518. //depends on alignment settings
  519. //and how dll is compiled to work right.
  520. //copy member by member instead..
  521. ZeroMemory(pPMSG,sizeof(DMUS_NOTE_PMSG));
  522. pPMSG->dwSize=sizeof(DMUS_NOTE_PMSG);
  523. pPMSG->mtTime=(MUSIC_TIME)mtTime;
  524. pPMSG->dwFlags=(DWORD)flags;
  525. pPMSG->dwType=DMUS_PMSGT_NOTE;
  526. pPMSG->dwPChannel =(DWORD)channel;
  527. pPMSG->dwVirtualTrackID =(DWORD)0;
  528. pPMSG->dwGroupID=(DWORD)-1;
  529. pPMSG->mtDuration=(MUSIC_TIME)msg->mtDuration;
  530. pPMSG->wMusicValue=(WORD)msg->musicValue;
  531. pPMSG->wMeasure=(WORD)msg->measure;
  532. pPMSG->nOffset=(short)msg->offset;
  533. pPMSG->bBeat=(BYTE)msg->beat;
  534. pPMSG->bGrid=(BYTE)msg->grid;
  535. pPMSG->bVelocity=(BYTE)msg->velocity;
  536. pPMSG->bFlags=(BYTE)msg->flags;
  537. pPMSG->bTimeRange=(BYTE)msg->timeRange;
  538. pPMSG->bDurRange=(BYTE)msg->durRange;
  539. pPMSG->bVelRange=(BYTE)msg->velRange;
  540. pPMSG->bPlayModeFlags=(BYTE)msg->playModeFlags;
  541. pPMSG->bSubChordLevel=(BYTE)msg->subChordLevel;
  542. pPMSG->bMidiValue=(BYTE)msg->midiValue;
  543. pPMSG->cTranspose=(char)msg->transpose;
  544. if (!flags) pPMSG->dwFlags= DMUS_PMSGF_MUSICTIME;
  545. hr=m__dxj_DirectMusicPerformance->SendPMsg((DMUS_PMSG*)pPMSG);
  546. return hr;
  547. }
  548. HRESULT C_dxj_DirectMusicPerformanceObject::sendCurvePMSG(
  549. /* [in] */ long mtTime,
  550. /* [in] */ long flags,
  551. /* [in] */ long channel,
  552. /* [in] */ DMUS_CURVE_PMSG_CDESC __RPC_FAR *msg)
  553. {
  554. HRESULT hr;
  555. DMUS_CURVE_PMSG *pPMSG=NULL;
  556. if (!msg) return E_INVALIDARG;
  557. hr= m__dxj_DirectMusicPerformance->AllocPMsg( sizeof(DMUS_CURVE_PMSG),(DMUS_PMSG**)&pPMSG);
  558. pPMSG->dwSize=sizeof(DMUS_CURVE_PMSG);
  559. pPMSG->mtTime=(MUSIC_TIME)mtTime;
  560. pPMSG->dwFlags=(DWORD)flags;
  561. pPMSG->dwType=DMUS_PMSGT_CURVE;
  562. pPMSG->dwPChannel =(DWORD)channel;
  563. pPMSG->dwVirtualTrackID =(DWORD)0;
  564. pPMSG->dwGroupID=(DWORD)-1;
  565. if (!flags) pPMSG->dwFlags= DMUS_PMSGF_MUSICTIME;
  566. pPMSG->mtDuration=msg->mtDuration;
  567. pPMSG->mtOriginalStart=msg->mtOriginalStart;
  568. pPMSG->mtResetDuration=msg->mtResetDuration;
  569. pPMSG->nStartValue =(short)msg->startValue;
  570. pPMSG->nEndValue =(short)msg->endValue;
  571. pPMSG->nResetValue =(short)msg->resetValue;
  572. pPMSG->wMeasure =(short)msg->measure;
  573. pPMSG->nOffset =(short)msg->offset;
  574. pPMSG->bBeat =(Byte)msg->beat;
  575. pPMSG->bGrid =(Byte)msg->grid;
  576. pPMSG->bType =(Byte)msg->type;
  577. pPMSG->bCurveShape =(Byte)msg->curveShape;
  578. pPMSG->bCCData =(Byte)msg->ccData;
  579. pPMSG->bFlags =(Byte)msg->flags;
  580. hr=m__dxj_DirectMusicPerformance->SendPMsg((DMUS_PMSG*)pPMSG);
  581. return hr;
  582. }
  583. HRESULT C_dxj_DirectMusicPerformanceObject::sendMIDIPMSG(
  584. /* [in] */ long mtTime,
  585. /* [in] */ long flags,
  586. /* [in] */ long channel,
  587. /* [in] */ Byte status,
  588. /* [in] */ Byte byte1,
  589. /* [in] */ Byte byte2)
  590. {
  591. HRESULT hr;
  592. DMUS_MIDI_PMSG *pPMSG=NULL;
  593. hr= m__dxj_DirectMusicPerformance->AllocPMsg( sizeof(DMUS_MIDI_PMSG),(DMUS_PMSG**)&pPMSG);
  594. ZeroMemory(pPMSG,sizeof(DMUS_MIDI_PMSG));
  595. pPMSG->dwSize=sizeof(DMUS_MIDI_PMSG);
  596. pPMSG->mtTime=(MUSIC_TIME)mtTime;
  597. pPMSG->dwFlags=(DWORD)flags;
  598. pPMSG->dwType=DMUS_PMSGT_MIDI;
  599. pPMSG->dwPChannel =(DWORD)channel;
  600. pPMSG->dwVirtualTrackID =(DWORD)0;
  601. pPMSG->dwGroupID=(DWORD)-1;
  602. pPMSG->bStatus=status;
  603. pPMSG->bByte1=byte1;
  604. pPMSG->bByte2=byte2;
  605. if (!flags) pPMSG->dwFlags= DMUS_PMSGF_MUSICTIME;
  606. hr=m__dxj_DirectMusicPerformance->SendPMsg((DMUS_PMSG*)pPMSG);
  607. return hr;
  608. }
  609. HRESULT C_dxj_DirectMusicPerformanceObject::sendPatchPMSG(
  610. /* [in] */ long mtTime,
  611. /* [in] */ long flags,
  612. /* [in] */ long channel,
  613. /* [in] */ Byte instrument,
  614. /* [in] */ Byte byte1,
  615. /* [in] */ Byte byte2)
  616. {
  617. HRESULT hr;
  618. DMUS_PATCH_PMSG *pPMSG=NULL;
  619. hr= m__dxj_DirectMusicPerformance->AllocPMsg( sizeof(DMUS_PATCH_PMSG),(DMUS_PMSG**)&pPMSG);
  620. ZeroMemory(pPMSG,sizeof(DMUS_PATCH_PMSG));
  621. pPMSG->dwSize=sizeof(DMUS_PATCH_PMSG);
  622. pPMSG->mtTime=(MUSIC_TIME)mtTime;
  623. pPMSG->dwFlags=(DWORD)flags;
  624. pPMSG->dwType=DMUS_PMSGT_PATCH;
  625. pPMSG->dwPChannel =(DWORD)channel;
  626. pPMSG->dwVirtualTrackID =(DWORD)0;
  627. pPMSG->dwGroupID=(DWORD)-1;
  628. pPMSG->byInstrument=instrument;
  629. pPMSG->byMSB=byte1;
  630. pPMSG->byLSB=byte2;
  631. if (!flags) pPMSG->dwFlags= DMUS_PMSGF_MUSICTIME;
  632. hr=m__dxj_DirectMusicPerformance->SendPMsg((DMUS_PMSG*)pPMSG);
  633. return hr;}
  634. HRESULT C_dxj_DirectMusicPerformanceObject::sendTempoPMSG(
  635. /* [in] */ long mtTime,
  636. /* [in] */ long flags,
  637. ///* [in] */ long channel,
  638. /* [in] */ double tempo)
  639. {
  640. HRESULT hr;
  641. DMUS_TEMPO_PMSG *pPMSG=NULL;
  642. hr= m__dxj_DirectMusicPerformance->AllocPMsg( sizeof(DMUS_TEMPO_PMSG),(DMUS_PMSG**)&pPMSG);
  643. ZeroMemory(pPMSG,sizeof(DMUS_TEMPO_PMSG));
  644. pPMSG->dwSize=sizeof(DMUS_TEMPO_PMSG);
  645. pPMSG->mtTime=(MUSIC_TIME)mtTime;
  646. pPMSG->dwFlags=(DWORD)flags;
  647. pPMSG->dwType=DMUS_PMSGT_TEMPO;
  648. pPMSG->dwPChannel =(DWORD)0;
  649. pPMSG->dwVirtualTrackID =(DWORD)0;
  650. pPMSG->dwGroupID=(DWORD)-1;
  651. pPMSG->dblTempo=tempo;
  652. if (!flags) pPMSG->dwFlags= DMUS_PMSGF_MUSICTIME;
  653. hr=m__dxj_DirectMusicPerformance->SendPMsg((DMUS_PMSG*)pPMSG);
  654. return hr;
  655. }
  656. HRESULT C_dxj_DirectMusicPerformanceObject::sendTransposePMSG(
  657. /* [in] */ long mtTime,
  658. /* [in] */ long flags,
  659. /* [in] */ long channel,
  660. /* [in] */ short transpose)
  661. {
  662. HRESULT hr;
  663. DMUS_TRANSPOSE_PMSG *pPMSG=NULL;
  664. hr= m__dxj_DirectMusicPerformance->AllocPMsg( sizeof(DMUS_TRANSPOSE_PMSG),(DMUS_PMSG**)&pPMSG);
  665. ZeroMemory(pPMSG,sizeof(DMUS_TRANSPOSE_PMSG));
  666. pPMSG->dwSize=sizeof(DMUS_TRANSPOSE_PMSG);
  667. pPMSG->mtTime=(MUSIC_TIME)mtTime;
  668. pPMSG->dwFlags=(DWORD)flags;
  669. pPMSG->dwType=DMUS_PMSGT_TRANSPOSE;
  670. pPMSG->dwPChannel =(DWORD)channel;
  671. pPMSG->dwVirtualTrackID =(DWORD)0;
  672. pPMSG->dwGroupID=(DWORD)-1;
  673. pPMSG->nTranspose=transpose;
  674. if (!flags) pPMSG->dwFlags= DMUS_PMSGF_MUSICTIME;
  675. hr=m__dxj_DirectMusicPerformance->SendPMsg((DMUS_PMSG*)pPMSG);
  676. return hr;
  677. }
  678. HRESULT C_dxj_DirectMusicPerformanceObject::sendTimeSigPMSG(
  679. /* [in] */ long mtTime,
  680. /* [in] */ long flags,
  681. /* [in] */ DMUS_TIMESIGNATURE_CDESC __RPC_FAR *timesig)
  682. {
  683. HRESULT hr;
  684. DMUS_TIMESIG_PMSG *pPMSG=NULL;
  685. if (!timesig) return E_INVALIDARG;
  686. hr= m__dxj_DirectMusicPerformance->AllocPMsg( sizeof(DMUS_TIMESIG_PMSG),(DMUS_PMSG**)&pPMSG);
  687. ZeroMemory(pPMSG,sizeof(DMUS_TIMESIG_PMSG));
  688. pPMSG->dwSize=sizeof(DMUS_TIMESIG_PMSG);
  689. pPMSG->mtTime=(MUSIC_TIME)mtTime;
  690. pPMSG->dwFlags=(DWORD)flags;
  691. pPMSG->dwType=DMUS_PMSGT_CURVE;
  692. pPMSG->dwPChannel =(DWORD)0;
  693. pPMSG->dwVirtualTrackID =(DWORD)0;
  694. pPMSG->dwGroupID=(DWORD)-1;
  695. if (!flags) pPMSG->dwFlags= DMUS_PMSGF_MUSICTIME;
  696. pPMSG->bBeatsPerMeasure =timesig->beatsPerMeasure;
  697. pPMSG->bBeat=timesig->beat;
  698. pPMSG->wGridsPerBeat=timesig->gridsPerBeat;
  699. hr=m__dxj_DirectMusicPerformance->SendPMsg((DMUS_PMSG*)pPMSG);
  700. return hr;
  701. }
  702. HRESULT C_dxj_DirectMusicPerformanceObject::getPortName(
  703. /* [in] */ long i,
  704. /* [retval][out] */ BSTR __RPC_FAR *name)
  705. {
  706. HRESULT hr;
  707. DMUS_PORTCAPS caps;
  708. if (!m_pDM) return CO_E_NOTINITIALIZED;
  709. if (i<=0) return E_INVALIDARG;
  710. if (!name) return E_INVALIDARG;
  711. ZeroMemory(&caps,sizeof(DMUS_PORTCAPS));
  712. caps.dwSize=sizeof(DMUS_PORTCAPS);
  713. hr=m_pDM->EnumPort( (DWORD) i-1, &caps );
  714. if (hr!=S_OK) return E_INVALIDARG; //happens when we are out of bounds
  715. //manbug23240
  716. if FAILED(hr) return hr; //for other resason ?
  717. *name=SysAllocString(caps.wszDescription);
  718. return S_OK;
  719. }
  720. HRESULT C_dxj_DirectMusicPerformanceObject::getPortCount(
  721. /* [retval][out] */ long __RPC_FAR *c)
  722. {
  723. HRESULT hr=S_OK;
  724. DMUS_PORTCAPS caps;
  725. DWORD i=0;
  726. if (!m_pDM) return CO_E_NOTINITIALIZED;
  727. if (!c) return E_INVALIDARG;
  728. while (hr==S_OK){
  729. caps.dwSize=sizeof(DMUS_PORTCAPS);
  730. hr=m_pDM->EnumPort( i++, &caps );
  731. if FAILED(hr) return hr;
  732. }
  733. *c=(long)i-1;
  734. return S_OK;
  735. }
  736. HRESULT C_dxj_DirectMusicPerformanceObject::getPortCaps( long i,
  737. /* [retval][out] */ DMUS_PORTCAPS_CDESC __RPC_FAR *c)
  738. {
  739. HRESULT hr;
  740. if (!c) return E_INVALIDARG;
  741. if (!m_pDM) return CO_E_NOTINITIALIZED;
  742. if (i<=0) return E_INVALIDARG;
  743. ZeroMemory(c,sizeof(DMUS_PORTCAPS));
  744. ((DMUS_PORTCAPS*)c)->dwSize=sizeof(DMUS_PORTCAPS);
  745. hr=m_pDM->EnumPort( (DWORD) i-1, (DMUS_PORTCAPS*)c );
  746. if (hr==S_FALSE) return E_INVALIDARG;
  747. return hr;
  748. }
  749. HRESULT C_dxj_DirectMusicPerformanceObject::setPort(
  750. /* [in] */ long portid,
  751. /* [in] */ long number_of_groups)
  752. {
  753. if (!m_pDM) return DMUS_E_NOT_INIT;
  754. HRESULT hr;
  755. DMUS_PORTPARAMS dmos;
  756. DMUS_PORTCAPS caps;
  757. GUID guidSink;
  758. // Initialize the performance. Have the performance create the
  759. // DirectMusic object by setting pDM to NULL. It is needed to
  760. // create the port.
  761. // Create the port.
  762. ZeroMemory( &dmos, sizeof(DMUS_PORTPARAMS) );
  763. dmos.dwSize = sizeof(DMUS_PORTPARAMS);
  764. dmos.dwChannelGroups = number_of_groups;
  765. dmos.dwEffectFlags = 0;
  766. dmos.dwValidParams = DMUS_PORTPARAMS_CHANNELGROUPS | DMUS_PORTPARAMS_EFFECTS;
  767. ZeroMemory(&caps,sizeof(DMUS_PORTCAPS));
  768. caps.dwSize=sizeof(DMUS_PORTCAPS);
  769. DWORD j=0;
  770. if (m_pPort){
  771. //j=m_pPort->AddRef();
  772. //j=m_pPort->Release();
  773. j=m_pPort->Release();
  774. hr= m__dxj_DirectMusicPerformance->RemovePort(m_pPort);
  775. if FAILED(hr) return hr;
  776. }
  777. if (portid<=0) {
  778. ZeroMemory( &guidSink, sizeof(GUID) );
  779. }
  780. else {
  781. hr=m_pDM->EnumPort( (DWORD) portid-1, &caps );
  782. if FAILED(hr) return hr;
  783. memcpy(&guidSink,&caps.guidPort,sizeof(GUID));
  784. }
  785. // Create the port
  786. hr = m_pDM->CreatePort( guidSink, &dmos, &m_pPort, NULL );
  787. if FAILED(hr) return hr;
  788. // Activate
  789. hr = m_pDM->Activate( TRUE );
  790. if FAILED(hr) return hr;
  791. //j=m_pPort->AddRef();
  792. //j=m_pPort->Release();
  793. // Add the port to the performance.
  794. // Succeeded in creating the port. Add the port to the
  795. // Performance with five groups of 16 midi channels.
  796. hr = m__dxj_DirectMusicPerformance->AddPort( m_pPort );
  797. if FAILED(hr) return hr;
  798. //j=m_pPort->AddRef();
  799. //j=m_pPort->Release();
  800. // Assign PChannel blocks for the number of groups we want.
  801. for( long i = 0; i < number_of_groups; i++ )
  802. {
  803. m__dxj_DirectMusicPerformance->AssignPChannelBlock( i, m_pPort, i+1 );
  804. }
  805. m_portid=portid;
  806. m_number_of_groups=number_of_groups;
  807. return S_OK;
  808. }
  809. //DEAD CODE left here for reference
  810. #if 0
  811. HRESULT C_dxj_DirectMusicPerformanceObject::addCommandParam(
  812. /* [in] */ long trackIndex,
  813. /* [in] */ long mtTime,
  814. /* [in] */ Byte command,
  815. /* [in] */ Byte grooveLevel)
  816. {
  817. HRESULT hr;
  818. DMUS_COMMAND_PARAM cmd;
  819. cmd.bCommand=(BYTE)command;
  820. cmd.bGrooveLevel=(BYTE)grooveLevel;
  821. cmd.bGrooveRange=0;
  822. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_CommandParam,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)mtTime,&cmd);
  823. return hr;
  824. }
  825. HRESULT C_dxj_DirectMusicPerformanceObject::addBandChange( /* [in] */ long trackIndex, /* [in] */ long mtTime, /* [in] */ I_dxj_DirectMusicBand __RPC_FAR *band)
  826. {
  827. if (!band) return E_INVALIDARG;
  828. DO_GETOBJECT_NOTNULL(IDirectMusicBand*,pBand,band);
  829. HRESULT hr;
  830. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_IDirectMusicBand,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)mtTime,pBand);
  831. return hr;
  832. }
  833. HRESULT C_dxj_DirectMusicPerformanceObject::addTempoChange(
  834. /* [in] */ long trackIndex,
  835. /* [in] */ long mtTime,
  836. /* [in] */ double tempo)
  837. {
  838. HRESULT hr;
  839. DMUS_TEMPO_PARAM tmp;
  840. tmp.dblTempo=tempo;
  841. tmp.mtTime=(MUSIC_TIME)mtTime;
  842. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_TempoParam,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)mtTime,&tmp);
  843. return hr;
  844. }
  845. HRESULT C_dxj_DirectMusicPerformanceObject::addTimeSigChange( /* [in] */ long trackIndex,/* [in] */ DMUS_TIMESIGNATURE_CDESC __RPC_FAR *timeSignature)
  846. {
  847. HRESULT hr;
  848. if (!timeSignature) return E_INVALIDARG;
  849. MUSIC_TIME mtTime=((DMUS_TIMESIGNATURE*)timeSignature)->mtTime;
  850. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_TimeSignature,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)mtTime,(DMUS_TIMESIGNATURE*)timeSignature);
  851. return hr;
  852. }
  853. HRESULT C_dxj_DirectMusicPerformanceObject::setAutoDownloadEnable( /* [in] */ long trackIndex, /* [retval][out] */ VARIANT_BOOL b)
  854. {
  855. HRESULT hr;
  856. if (b==VARIANT_FALSE){
  857. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_Disable_Auto_Download,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  858. }
  859. else {
  860. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_Enable_Auto_Download,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  861. }
  862. return hr;
  863. }
  864. HRESULT C_dxj_DirectMusicPerformanceObject::setTempoEnable( /* [in] */ long trackIndex,/* [retval][out] */ VARIANT_BOOL b)
  865. {
  866. HRESULT hr;
  867. if (b==VARIANT_FALSE){
  868. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_DisableTempo,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  869. }
  870. else {
  871. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_EnableTempo,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  872. }
  873. return hr;
  874. }
  875. HRESULT C_dxj_DirectMusicPerformanceObject::setTimeSigEnable( /* [in] */ long trackIndex,/* [retval][out] */ VARIANT_BOOL b)
  876. {
  877. HRESULT hr;
  878. if (b==VARIANT_FALSE){
  879. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_DisableTimeSig,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  880. }
  881. else {
  882. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_EnableTimeSig,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,NULL);
  883. }
  884. return hr;
  885. }
  886. HRESULT C_dxj_DirectMusicPerformanceObject::clearAllBands ()
  887. {
  888. HRESULT hr;
  889. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_Clear_All_Bands,0xFFFFFFFF,0,0,NULL);
  890. return hr;
  891. }
  892. HRESULT C_dxj_DirectMusicPerformanceObject::download( /* [in] */ long trackIndex, /* [in] */ I_dxj_DirectMusicPerformance __RPC_FAR *performance)
  893. {
  894. if (!performance) return E_INVALIDARG;
  895. DO_GETOBJECT_NOTNULL(IDirectMusicPerformance*,pPerformance,performance);
  896. HRESULT hr;
  897. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_Download,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,pPerformance);
  898. return hr;
  899. }
  900. HRESULT C_dxj_DirectMusicPerformanceObject::unload( /* [in] */ long trackIndex, /* [in] */ I_dxj_DirectMusicPerformance __RPC_FAR *performance)
  901. {
  902. if (!performance) return E_INVALIDARG;
  903. DO_GETOBJECT_NOTNULL(IDirectMusicPerformance*,pPerformance,performance);
  904. HRESULT hr;
  905. hr=m__dxj_DirectMusicPerformance->SetParam(GUID_Unload,0xFFFFFFFF,(DWORD)trackIndex,(MUSIC_TIME)0,pPerformance);
  906. return hr;
  907. }
  908. #endif