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.

272 lines
8.0 KiB

  1. //
  2. // dmbandp.h
  3. //
  4. // Copyright (c) 1997-2000 Microsoft Corporation
  5. //
  6. //
  7. #ifndef DMBANDP_H
  8. #define DMBANDP_H
  9. #include "dmusici.h"
  10. #include "dmusicf.h"
  11. #include "bandinst.h"
  12. #include "dmbndtrk.h"
  13. #include "..\shared\validate.h"
  14. #include "PChMap.h"
  15. #include "..\shared\dmusicp.h"
  16. class CRiffParser;
  17. #define REF_PER_MIL 10000 // For converting from reference time to mils
  18. #define DM_LEGACY_BAND_COLLECTION_NAME_LEN (32)
  19. #define MIDI_PROGRAM_CHANGE 0xc0
  20. #define MIDI_CONTROL_CHANGE 0xb0
  21. #define MIDI_CC_BS_MSB 0x00
  22. #define MIDI_CC_BS_LSB 0x20
  23. #define MIDI_CC_VOLUME 0x07
  24. #define MIDI_CC_PAN 0x0a
  25. // registered parameter numbers
  26. #define RPN_PITCHBEND 0x00
  27. #define FOURCC_BAND_FORM mmioFOURCC('A','A','B','N')
  28. #define FOURCC_BAND mmioFOURCC('b','a','n','d')
  29. // This structure is the format used by band files created with SuperJam and
  30. // earlier versions of Jazz. It was taken from band.h found in the Band Editor
  31. // subdirectory of the Jazz project tree.
  32. #pragma pack(2)
  33. typedef struct ioBandLegacy
  34. {
  35. wchar_t wstrName[20]; // Band name
  36. BYTE abPatch[16]; // GM
  37. BYTE abVolume[16];
  38. BYTE abPan[16];
  39. signed char achOctave[16];
  40. char fDefault; // This band is the style's default band
  41. char chPad;
  42. WORD awDLSBank[16]; // if GM bit set use abPatch
  43. // if GS bit set, use this plus abDLSPatch
  44. // else use both as a DLS
  45. BYTE abDLSPatch[16];
  46. GUID guidCollection;
  47. // wchar_t wstrCollection[16];
  48. char szCollection[32]; // this only needs to be single-wide chars
  49. } ioBandLegacy;
  50. #pragma pack()
  51. #define DMB_LOADED (1 << 0) /* Set when band has been loaded */
  52. #define DMB_DEFAULT (1 << 1) /* Set when band is default band for a style */
  53. class CBandInstrument;
  54. class CBandTrkStateData;
  55. //////////////////////////////////////////////////////////////////////
  56. // Class CBand
  57. class CBand :
  58. public IDirectMusicBand,
  59. public IDirectMusicBandP,
  60. public IDirectMusicBandPrivate,
  61. public IPersistStream,
  62. public IDirectMusicObject,
  63. public AListItem
  64. {
  65. friend class CBandTrk;
  66. public:
  67. enum {DMBAND_NUM_LEGACY_INSTRUMENTS = 16};
  68. // IUnknown
  69. virtual STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  70. virtual STDMETHODIMP_(ULONG) AddRef();
  71. virtual STDMETHODIMP_(ULONG) Release();
  72. // IPersist functions
  73. STDMETHODIMP GetClassID(CLSID* pClassID) {return E_NOTIMPL;}
  74. // IPersistStream functions
  75. STDMETHODIMP IsDirty() {return S_FALSE;}
  76. STDMETHODIMP Load(IStream* pStream);
  77. STDMETHODIMP Save(IStream* pStream, BOOL fClearDirty) {return E_NOTIMPL;}
  78. STDMETHODIMP GetSizeMax(ULARGE_INTEGER* pcbSize) {return E_NOTIMPL;}
  79. // IDirectMusicObject
  80. STDMETHODIMP GetDescriptor(LPDMUS_OBJECTDESC pDesc);
  81. STDMETHODIMP SetDescriptor(LPDMUS_OBJECTDESC pDesc);
  82. STDMETHODIMP ParseDescriptor(LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc);
  83. // IDirectMusicBand
  84. STDMETHODIMP CreateSegment(IDirectMusicSegment** ppSegment);
  85. STDMETHODIMP Download(IDirectMusicPerformance* pPerformance);
  86. STDMETHODIMP Unload(IDirectMusicPerformance* pPerformance);
  87. /* IDirectMusicBand8 */
  88. STDMETHODIMP DownloadEx( IUnknown *pAudioPath) ;
  89. STDMETHODIMP UnloadEx( IUnknown *pAudioPath) ;
  90. // IDirectMusicBandPrivate
  91. STDMETHODIMP GetFlags(DWORD* dwFlags)
  92. {
  93. V_INAME(CBand::GetFlags);
  94. // Make sure we have a valid pointer
  95. V_PTR_WRITE(dwFlags, DWORD);
  96. *dwFlags = m_dwFlags;
  97. return S_OK;
  98. }
  99. STDMETHODIMP SetGMGSXGMode(DWORD dwMidiMode)
  100. {
  101. m_dwMidiMode = dwMidiMode;
  102. return S_OK;
  103. }
  104. // Class
  105. CBand();
  106. ~CBand();
  107. private:
  108. CBand* GetNext(){return(CBand*)AListItem::GetNext();}
  109. HRESULT ParseLegacyDescriptor(CRiffParser *pParser, LPDMUS_OBJECTDESC pDesc);
  110. HRESULT ParseDirectMusicDescriptor(CRiffParser *pParser, LPDMUS_OBJECTDESC pDesc);
  111. HRESULT LoadDirectMusicBand(CRiffParser *pParser, IDirectMusicLoader *pIDMLoader);
  112. HRESULT LoadLegacyBand(CRiffParser *pParser, IDirectMusicLoader *pIDMLoader);
  113. HRESULT BuildLegacyInstrumentList(const ioBandLegacy& iob,
  114. IDirectMusicLoader* pIDMLoader);
  115. HRESULT ExtractBandInstrument(CRiffParser *pParser,
  116. IDirectMusicLoader* pIDMLoader);
  117. HRESULT GetCollectionRefAndLoad(CRiffParser *pParser,
  118. IDirectMusicLoader *pIDMLoader,
  119. CBandInstrument *pBandInstrument);
  120. HRESULT Load(DMUS_IO_PATCH_ITEM& rPatchEvent); // Assumes event come from a MIDI file
  121. HRESULT Load(CBandInstrument* pInstrument); // Assumes Instrument come from a band during cloning
  122. HRESULT SendMessages(CBandTrkStateData* pBTStateData,
  123. MUSIC_TIME mtOffset,
  124. REFERENCE_TIME rtOffset,
  125. bool fClockTime);
  126. HRESULT AllocPMsgFromGenericTemplate(
  127. DWORD dwType,
  128. IDirectMusicPerformance *pPerformance,
  129. DMUS_PMSG **ppMsg,
  130. ULONG cb,
  131. DMUS_PMSG *pMsgGenericFields);
  132. HRESULT StampSendFreePMsg(
  133. IDirectMusicPerformance *pPerformance,
  134. IDirectMusicGraph *pGraph,
  135. DMUS_PMSG *pMsg);
  136. HRESULT SendInstrumentAtTime(CBandInstrument* pInstrument,
  137. CBandTrkStateData* pBTStateData,
  138. MUSIC_TIME mtTimeToPlay,
  139. MUSIC_TIME mtOffset,
  140. REFERENCE_TIME rtOffset,
  141. bool fClockTime);
  142. HRESULT LoadCollection(IDirectMusicCollection** ppIDMCollection,
  143. char* szCollection,
  144. IDirectMusicLoader* pIDMLoader);
  145. DWORD GetPChannelCount();
  146. HRESULT GetPChannels(DWORD *pdwPChannels, DWORD *pdwNumWritten);
  147. bool IsGS(DMUS_IO_PATCH_ITEM& rPatchEvent);
  148. bool XGInHardware(
  149. IDirectMusicPerformance *pPerformance,
  150. IDirectMusicSegmentState *pSegState,
  151. DWORD dwPChannel);
  152. HRESULT ConnectToDLSCollection(IDirectMusicCollection *pCollection);
  153. HRESULT MakeGMOnly();
  154. private:
  155. CRITICAL_SECTION m_CriticalSection;
  156. BOOL m_fCSInitialized;
  157. CBandInstrumentList m_BandInstrumentList;
  158. MUSIC_TIME m_lTimeLogical;
  159. MUSIC_TIME m_lTimePhysical;
  160. DWORD m_dwFlags;
  161. long m_cRef;
  162. CPChMap m_PChMap;
  163. DWORD m_dwGroupBits;
  164. DWORD m_dwMidiMode; // midi mode message
  165. // IDirectMusicObject variables
  166. DWORD m_dwValidData;
  167. GUID m_guidObject;
  168. FILETIME m_ftDate; /* Last edited date of object. */
  169. DMUS_VERSION m_vVersion; /* Version. */
  170. WCHAR m_wszName[DMUS_MAX_NAME]; /* Name of object. */
  171. WCHAR m_wszCategory[DMUS_MAX_CATEGORY]; /* Category for object */
  172. WCHAR m_wszFileName[DMUS_MAX_FILENAME]; /* File path. */
  173. };
  174. //////////////////////////////////////////////////////////////////////
  175. // Class CBandList
  176. class CBandList : public AList
  177. {
  178. public:
  179. CBandList(){}
  180. ~CBandList()
  181. {
  182. while(!IsEmpty())
  183. {
  184. CBand* pBand = RemoveHead();
  185. delete pBand;
  186. }
  187. }
  188. CBand* GetHead(){return(CBand *)AList::GetHead();}
  189. CBand* GetItem(LONG lIndex){return(CBand*)AList::GetItem(lIndex);}
  190. CBand* RemoveHead(){return(CBand *)AList::RemoveHead();}
  191. void Remove(CBand* pBand){AList::Remove((AListItem *)pBand);}
  192. void AddTail(CBand* pBand){AList::AddTail((AListItem *)pBand);}
  193. };
  194. class CClassFactory : public IClassFactory
  195. {
  196. public:
  197. // IUnknown
  198. //
  199. STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  200. STDMETHODIMP_(ULONG) AddRef();
  201. STDMETHODIMP_(ULONG) Release();
  202. // Interface IClassFactory
  203. //
  204. STDMETHODIMP CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv);
  205. STDMETHODIMP LockServer(BOOL bLock);
  206. // Constructor
  207. //
  208. CClassFactory(DWORD dwToolType);
  209. // Destructor
  210. ~CClassFactory();
  211. private:
  212. long m_cRef;
  213. DWORD m_dwClassType;
  214. };
  215. // We use one class factory to create all classes. We need an identifier for each
  216. // type so the class factory knows what it is creating.
  217. #define CLASS_BAND 1
  218. #define CLASS_BANDTRACK 2
  219. #endif // #ifndef DMBANDP_H