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.

139 lines
4.8 KiB

  1. // Copyright (c) 1999 Microsoft Corporation. All rights reserved.
  2. //
  3. // Declaration of CParamControlTrack.
  4. //
  5. // This track holds curve information for automation (like automating sliders on a mixing board -- not OLE automation)
  6. // of effects and tools in the audio path.
  7. #pragma once
  8. #include "trackhelp.h"
  9. //#include "imediaobjectparams.h"
  10. //#include "mediaobj.h" // �� need to get this from public\sdk\inc
  11. #include "medparam.h"
  12. #include "dmusicf.h"
  13. // {827F0437-9ED6-4107-8494-49976FF5B642}
  14. DEFINE_GUID(IID_CParamControlTrack, 0x827f0437, 0x9ed6, 0x4107, 0x84, 0x94, 0x49, 0x97, 0x6f, 0xf5, 0xb6, 0x42);
  15. class CParamControlTrack
  16. : public CBasicTrack
  17. {
  18. // types for track data...
  19. struct ParamInfo
  20. {
  21. ParamInfo() : curves(NULL), curvesEnd(NULL), fAlreadyTracedPlaybackError(false) { Zero(&header); }
  22. ~ParamInfo() { delete[] curves; }
  23. DMUS_IO_PARAMCONTROLTRACK_PARAMHEADER header;
  24. DMUS_IO_PARAMCONTROLTRACK_CURVEINFO *curves; // pointer to first curve
  25. DMUS_IO_PARAMCONTROLTRACK_CURVEINFO *curvesEnd; // pointer one past last curve
  26. bool fAlreadyTracedPlaybackError;
  27. };
  28. struct ObjectInfo
  29. {
  30. ObjectInfo() : fAlreadyTracedPlaybackError(false) { Zero(&header); }
  31. DMUS_IO_PARAMCONTROLTRACK_OBJECTHEADER header;
  32. TList<ParamInfo> listParams;
  33. bool fAlreadyTracedPlaybackError;
  34. };
  35. struct ParamState // the state data we need to keep track of for each parameter we're controlling
  36. {
  37. ParamState() : pCurrentCurve(NULL), fLast(false), rtStartPointOfLastCurve(0) {}
  38. DMUS_IO_PARAMCONTROLTRACK_CURVEINFO *pCurrentCurve; // current seek pointer in the array of control points
  39. bool fLast; // true if the last envelope was sent successfully
  40. REFERENCE_TIME rtStartPointOfLastCurve; // time (in the object's time) of the start point of the last envelope we sent
  41. TList<REFERENCE_TIME> listStartTimes; // start times of all envelopes that have been sent
  42. };
  43. struct StateData
  44. {
  45. StateData() : prgpIMediaParams(NULL), prgParam(NULL), fFlushInAbort(false) {}
  46. IMediaParams **prgpIMediaParams; // Array of size m_cObjects.
  47. ParamState *prgParam; // Array of size m_cParams.
  48. DWORD dwValidate;
  49. bool fFlushInAbort;
  50. };
  51. public:
  52. CParamControlTrack(HRESULT *pHr) : m_dwValidate(0), m_cObjects(0), m_cParams(0), CBasicTrack(&g_cComponent, CLSID_DirectMusicParamControlTrack) {}
  53. STDMETHOD(QueryInterface)(const IID &iid, void **ppv);
  54. STDMETHOD(Init)(IDirectMusicSegment *pSegment);
  55. STDMETHOD(Load)(IStream* pIStream);
  56. STDMETHOD(InitPlay)(
  57. IDirectMusicSegmentState *pSegmentState,
  58. IDirectMusicPerformance *pPerformance,
  59. void **ppStateData,
  60. DWORD dwTrackID,
  61. DWORD dwFlags);
  62. STDMETHOD(EndPlay)(void *pStateData);
  63. STDMETHOD(Clone)(MUSIC_TIME mtStart,MUSIC_TIME mtEnd,IDirectMusicTrack** ppTrack);
  64. virtual HRESULT PlayMusicOrClock(
  65. void *pStateData,
  66. MUSIC_TIME mtStart,
  67. MUSIC_TIME mtEnd,
  68. MUSIC_TIME mtOffset,
  69. REFERENCE_TIME rtOffset,
  70. DWORD dwFlags,
  71. IDirectMusicPerformance* pPerf,
  72. IDirectMusicSegmentState* pSegSt,
  73. DWORD dwVirtualID,
  74. bool fClockTime);
  75. virtual HRESULT OnSegmentEnd(REFERENCE_TIME rtEnd, void *pStateData);
  76. private:
  77. HRESULT LoadObject(SmartRef::RiffIter ri);
  78. HRESULT LoadParam(SmartRef::RiffIter ri, TList<ParamInfo> &listParams);
  79. HRESULT TrackToObjectTime(
  80. MUSIC_TIME mtOffset,
  81. REFERENCE_TIME rtOffset,
  82. IDirectMusicPerformance* pPerf,
  83. bool fTrkClockTime,
  84. bool fObjClockTime,
  85. MUSIC_TIME mt,
  86. REFERENCE_TIME *rt);
  87. HRESULT PlayEnvelope(
  88. IMediaParams *pIMediaParams,
  89. MP_ENVELOPE_SEGMENT *pEnv,
  90. DMUS_IO_PARAMCONTROLTRACK_CURVEINFO *pPt,
  91. const ObjectInfo &obj,
  92. const ParamInfo &param,
  93. ParamState &paramstate,
  94. MUSIC_TIME mtOffset,
  95. REFERENCE_TIME rtOffset,
  96. IDirectMusicPerformance* pPerf,
  97. bool fTrkClockTime,
  98. bool fObjClockTime);
  99. HRESULT PlayTruncatedEnvelope(
  100. MUSIC_TIME mtTruncStart,
  101. IMediaParams *pIMediaParams,
  102. MP_ENVELOPE_SEGMENT *pEnv,
  103. DMUS_IO_PARAMCONTROLTRACK_CURVEINFO *pPt,
  104. const ObjectInfo &obj,
  105. const ParamInfo &param,
  106. ParamState &paramstate,
  107. MUSIC_TIME mtOffset,
  108. REFERENCE_TIME rtOffset,
  109. IDirectMusicPerformance* pPerf,
  110. bool fTrkClockTime,
  111. bool fObjClockTime,
  112. DWORD dwFlags);
  113. HRESULT InitStateData(
  114. StateData *pStateData,
  115. IDirectMusicSegmentState *pSegmentState);
  116. DWORD m_dwValidate; // Increment this counter in Load, causing the state data to synchonize with the new events
  117. TList<ObjectInfo> m_listObjects;
  118. int m_cObjects;
  119. int m_cParams;
  120. };