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.

638 lines
23 KiB

  1. // DMStyle.h : Declaration of the CDMStyle
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // @doc EXTERNAL
  6. //
  7. //
  8. #ifndef __DMSTYLE_H_
  9. #define __DMSTYLE_H_
  10. #include "dmusici.h"
  11. #include "sjdefs.h"
  12. #include "iostru.h"
  13. #include "AARiff.h"
  14. #include "str.h"
  15. #include "tlist.h"
  16. #include "alist.h"
  17. #include "dmstylep.h"
  18. #include "filter.h"
  19. #include "..\shared\dmusicp.h"
  20. #include "timesig.h"
  21. #include "debug.h"
  22. // default scale is C Major
  23. const DWORD DEFAULT_SCALE_PATTERN = 0xab5ab5;
  24. // default chord is major 7
  25. const DWORD DEFAULT_CHORD_PATTERN = 0x891;
  26. const int MAX_VARIATION_LOCKS = 255; // max number of variation lock ids
  27. extern DirectMusicTimeSig DefaultTimeSig;
  28. struct CompositionFragment;
  29. struct StyleTrackState;
  30. #define EMB_NORMAL 0
  31. #define EMB_FILL 1
  32. #define EMB_BREAK 2
  33. #define EMB_INTRO 4
  34. #define EMB_END 8
  35. #define EMB_MOTIF 16
  36. // User-defined embellishments live in the high byte of the embellishment word
  37. #define EMB_USER_DEFINED 0xff00
  38. // #defines to replace need for dynamic casts
  39. #define DMUS_EVENT_NOTE 1
  40. #define DMUS_EVENT_CURVE 2
  41. #define DMUS_EVENT_MARKER 3
  42. #define DMUS_EVENT_ANTICIPATION 4
  43. // Curve flip flags
  44. #define CURVE_FLIPTIME 1
  45. #define CURVE_FLIPVALUE 2
  46. #define STYLEF_USING_DX8 1
  47. struct DirectMusicPart;
  48. struct DirectMusicPartRef;
  49. class CDMStyle;
  50. struct DMStyleStruct;
  51. struct CDirectMusicPattern;
  52. struct CDirectMusicEventItem : public AListItem
  53. {
  54. //friend class CDirectMusicPattern;
  55. //public:
  56. CDirectMusicEventItem* MergeSort(DirectMusicTimeSig& TimeSig);
  57. //protected:
  58. void Divide(CDirectMusicEventItem* &pHalf1, CDirectMusicEventItem* &pHalf2);
  59. CDirectMusicEventItem* Merge(CDirectMusicEventItem* pOtherList, DirectMusicTimeSig& TimeSig);
  60. CDirectMusicEventItem* GetNext() { return (CDirectMusicEventItem*) AListItem::GetNext(); }
  61. CDirectMusicEventItem* ReviseEvent(short nGrid,
  62. short nOffset,
  63. DWORD* pdwVariation = NULL,
  64. DWORD* pdwID = NULL,
  65. WORD* pwMusic = NULL,
  66. BYTE* pbPlaymode = NULL,
  67. BYTE* pbFlags = NULL);
  68. //protected:
  69. short m_nGridStart; // Grid position in track that this event belogs to.
  70. short m_nTimeOffset; // Offset, in music time, of event from designated grid position.
  71. DWORD m_dwVariation; // variation bits
  72. DWORD m_dwEventTag; // what type of event this is (note, curve, ...)
  73. };
  74. struct CDirectMusicEventList : public AList
  75. {
  76. //public:
  77. ~CDirectMusicEventList();
  78. CDirectMusicEventItem *GetHead() { return (CDirectMusicEventItem *)AList::GetHead();};
  79. CDirectMusicEventItem *RemoveHead() { return (CDirectMusicEventItem *)AList::RemoveHead();};
  80. void MergeSort(DirectMusicTimeSig& TimeSig); // Destructively mergeSorts the list
  81. };
  82. struct CDMStyleNote : public CDirectMusicEventItem
  83. {
  84. //friend class CDirectMusicPattern;
  85. //public:
  86. CDMStyleNote() : m_bPlayModeFlags(0), m_bFlags(0), m_dwFragmentID(0)
  87. {
  88. m_dwEventTag = DMUS_EVENT_NOTE;
  89. }
  90. CDirectMusicEventItem* ReviseEvent(short nGrid,
  91. short nOffset,
  92. DWORD* pdwVariation,
  93. DWORD* pdwID,
  94. WORD* pwMusic,
  95. BYTE* pbPlaymode,
  96. BYTE* pbFlags);
  97. //protected:
  98. MUSIC_TIME m_mtDuration; // how long this note lasts
  99. WORD m_wMusicValue; // Position in scale.
  100. BYTE m_bVelocity; // Note velocity.
  101. BYTE m_bTimeRange; // Range to randomize start time.
  102. BYTE m_bDurRange; // Range to randomize duration.
  103. BYTE m_bVelRange; // Range to randomize velocity.
  104. BYTE m_bInversionId; // Identifies inversion group to which this note belongs
  105. BYTE m_bPlayModeFlags; // can override part ref
  106. DWORD m_dwFragmentID; // for melody formulation, the fragment this note came from
  107. BYTE m_bFlags; // values from DMUS_NOTEF_FLAGS
  108. };
  109. struct CDMStyleCurve : public CDirectMusicEventItem
  110. {
  111. CDMStyleCurve()
  112. {
  113. m_dwEventTag = DMUS_EVENT_CURVE;
  114. }
  115. CDirectMusicEventItem* ReviseEvent(short nGrid, short nOffset);
  116. MUSIC_TIME m_mtDuration; // how long this curve lasts
  117. MUSIC_TIME m_mtResetDuration; // how long after the end of the curve to reset it
  118. short m_StartValue; // curve's start value
  119. short m_EndValue; // curve's end value
  120. short m_nResetValue; // curve's reset value
  121. BYTE m_bEventType; // type of curve
  122. BYTE m_bCurveShape; // shape of curve
  123. BYTE m_bCCData; // CC#
  124. BYTE m_bFlags; // flags. Bit 1=TRUE means to send the reset value. Other bits reserved.
  125. WORD m_wParamType; // RPN or NRPN parameter number.
  126. WORD m_wMergeIndex; // Allows multiple parameters to be merged (pitchbend, volume, and expression.)
  127. };
  128. struct CDMStyleMarker : public CDirectMusicEventItem
  129. {
  130. CDMStyleMarker()
  131. {
  132. m_dwEventTag = DMUS_EVENT_MARKER;
  133. }
  134. CDirectMusicEventItem* ReviseEvent(short nGrid);
  135. WORD m_wFlags; // flags for how to interpret this marker.
  136. };
  137. struct CDMStyleAnticipation : public CDirectMusicEventItem
  138. {
  139. CDMStyleAnticipation()
  140. {
  141. m_dwEventTag = DMUS_EVENT_ANTICIPATION;
  142. }
  143. CDirectMusicEventItem* ReviseEvent(short nGrid);
  144. BYTE m_bTimeRange; // Range to randomize start time.
  145. };
  146. struct Marker
  147. {
  148. MUSIC_TIME mtTime;
  149. WORD wFlags;
  150. };
  151. struct DirectMusicPart
  152. {
  153. DirectMusicPart(DirectMusicTimeSig *pTimeSig = NULL);
  154. ~DirectMusicPart() { }
  155. STDMETHODIMP_(ULONG) AddRef();
  156. STDMETHODIMP_(ULONG) Release();
  157. HRESULT DM_LoadPart(
  158. IAARIFFStream* pIRiffStream, MMCKINFO* pckMain, DMStyleStruct* pStyle );
  159. HRESULT DM_SavePart( IAARIFFStream* pIRiffStream );
  160. HRESULT DM_SaveNoteList( IAARIFFStream* pIRiffStream );
  161. HRESULT DM_SaveCurveList( IAARIFFStream* pIRiffStream );
  162. HRESULT DM_SaveMarkerList( IAARIFFStream* pIRiffStream );
  163. HRESULT DM_SaveAnticipationList( IAARIFFStream* pIRiffStream );
  164. HRESULT DM_SaveResolutionList( IAARIFFStream* pIRiffStream );
  165. HRESULT MergeMarkerEvents( DMStyleStruct* pStyle, CDirectMusicPattern* pPattern );
  166. HRESULT GetClosestTime(int nVariation, MUSIC_TIME mtTime, DWORD dwFlags, bool fChord, MUSIC_TIME& rmtResult);
  167. bool IsMarkerAtTime(int nVariation, MUSIC_TIME mtTime, DWORD dwFlags, bool fChord);
  168. DirectMusicTimeSig& TimeSignature( DMStyleStruct* pStyle, CDirectMusicPattern* pPattern );
  169. long m_cRef;
  170. GUID m_guidPartID;
  171. DirectMusicTimeSig m_timeSig; // can override pattern's
  172. WORD m_wNumMeasures; // length of the Part
  173. DWORD m_dwVariationChoices[32]; // MOAW choices bitfield
  174. BYTE m_bPlayModeFlags; // see PLAYMODE flags (in ioDMStyle.h)
  175. BYTE m_bInvertUpper; // inversion upper limit
  176. BYTE m_bInvertLower; // inversion lower limit
  177. DWORD m_dwFlags; // various flags
  178. CDirectMusicEventList EventList; // list of events (notes, curves, etc.)
  179. TList<Marker> m_StartTimes[32]; // Array of start time lists (1 per variation)
  180. TList<DMUS_IO_STYLERESOLUTION> m_ResolutionList; // list of variation resolutions
  181. };
  182. struct InversionGroup
  183. {
  184. // Inversion groups are used for keeping track of groups of notes to be played
  185. // without inversion
  186. WORD m_wGroupID; // Group this represents.
  187. WORD m_wCount; // How many are in the group, still waiting to be played.
  188. short m_nOffset; // Number to add to all notes for offsetting.
  189. };
  190. const short INVERSIONGROUPLIMIT = 16;
  191. short FindGroup(InversionGroup aGroup[], WORD wID);
  192. short AddGroup(InversionGroup aGroup[], WORD wID, WORD wCount, short m_nOffset);
  193. struct PatternTrackState;
  194. struct DirectMusicPartRef
  195. {
  196. DirectMusicPartRef() :
  197. m_bPriority(100),
  198. m_pDMPart(NULL),
  199. m_bVariationLockID(0),
  200. //m_wLogicalPartID(LOGICAL_PART_PIANO),
  201. m_bSubChordLevel(SUBCHORD_STANDARD_CHORD)
  202. { }
  203. ~DirectMusicPartRef() { if (m_pDMPart) m_pDMPart->Release(); }
  204. HRESULT DM_LoadPartRef( IAARIFFStream* pIRiffStream, MMCKINFO* pckMain, DMStyleStruct* pStyle);
  205. HRESULT DM_SavePartRef( IAARIFFStream* pIRiffStream );
  206. void SetPart( DirectMusicPart* pPart );
  207. HRESULT ConvertMusicValue(CDMStyleNote* pNoteEvent,
  208. DMUS_CHORD_PARAM& rCurrentChord,
  209. BYTE bPlaymode,
  210. BOOL fPlayAsIs,
  211. InversionGroup aInversionGroups[],
  212. IDirectMusicPerformance* pPerformance,
  213. BYTE& rbMidiValue,
  214. short& rnMidiOffset);
  215. HRESULT ConvertMIDIValue(BYTE bMIDI,
  216. DMUS_CHORD_PARAM& rCurrentChord,
  217. BYTE bPlayModeFlags,
  218. IDirectMusicPerformance* pPerformance,
  219. WORD& rwMusicValue);
  220. DirectMusicPart* m_pDMPart; // the Part to which this refers
  221. DWORD m_dwLogicalPartID; // corresponds to port/device/midi channel
  222. BYTE m_bVariationLockID; // parts with the same ID lock variations.
  223. // high bit is used to identify master Part
  224. BYTE m_bSubChordLevel; // tells which sub chord level this part wants
  225. BYTE m_bPriority; // Priority levels. Parts with lower priority
  226. // aren't played first when a device runs out of
  227. // notes
  228. BYTE m_bRandomVariation; // Determines order in which variations are played.
  229. };
  230. #define COMPUTE_VARIATIONSF_USE_MASK 0x1
  231. #define COMPUTE_VARIATIONSF_NEW_PATTERN 0x2
  232. #define COMPUTE_VARIATIONSF_CHORD_ALIGN 0x4
  233. #define COMPUTE_VARIATIONSF_MARKER 0x8
  234. #define COMPUTE_VARIATIONSF_START 0x10
  235. #define COMPUTE_VARIATIONSF_DX8 0x20
  236. #define COMPUTE_VARIATIONSF_CHANGED 0x40
  237. struct CDirectMusicPattern
  238. {
  239. friend class CDMStyle;
  240. //public:
  241. CDirectMusicPattern( DirectMusicTimeSig* pTimeSig = NULL, BOOL fMotif = FALSE );
  242. ~CDirectMusicPattern() { CleanUp(); }
  243. STDMETHODIMP_(ULONG) AddRef();
  244. STDMETHODIMP_(ULONG) Release();
  245. CDirectMusicPattern* Clone(MUSIC_TIME mtStart, MUSIC_TIME mtEnd, BOOL fMotif);
  246. void CleanUp();
  247. HRESULT DM_LoadPattern(
  248. IAARIFFStream* pIRiffStream, MMCKINFO* pckMain, DMStyleStruct* pStyle );
  249. HRESULT LoadPattern(
  250. IAARIFFStream* pRIFF,
  251. MMCKINFO* pckMain,
  252. TList<DirectMusicPart*> &partList,
  253. DMStyleStruct& rStyleStruct
  254. );
  255. HRESULT AllocPartRef(TListItem<DirectMusicPartRef>*& rpPartRefItem);
  256. void DeletePartRef(TListItem<DirectMusicPartRef>* pPartRefItem);
  257. void DMusMoawFlags(MUSIC_TIME mtTime,
  258. MUSIC_TIME mtNextChord,
  259. DMUS_CHORD_PARAM& rCurrentChord,
  260. DMUS_CHORD_PARAM& rNextChord,
  261. bool fIsDX8,
  262. DWORD& dwNaturals,
  263. DWORD& dwSharps,
  264. DWORD& dwFlats);
  265. DWORD IMA25MoawFlags(MUSIC_TIME mtTime,
  266. MUSIC_TIME mtNextChord,
  267. DMUS_CHORD_PARAM& rCurrentChord,
  268. DMUS_CHORD_PARAM& rNextChord);
  269. HRESULT ComputeVariations(DWORD dwFlags,
  270. DMUS_CHORD_PARAM& rCurrentChord,
  271. DMUS_CHORD_PARAM& rNextChord,
  272. BYTE abVariationGroups[],
  273. DWORD adwVariationMask[],
  274. DWORD adwRemoveVariations[],
  275. BYTE abVariation[],
  276. MUSIC_TIME mtTime,
  277. MUSIC_TIME mtNextChord,
  278. PatternTrackState* pState = NULL);
  279. HRESULT ComputeVariationGroup(DirectMusicPartRef& rPartRef,
  280. int nPartIndex,
  281. DWORD dwFlags,
  282. DMUS_CHORD_PARAM& rCurrentChord,
  283. DMUS_CHORD_PARAM& rNextChord,
  284. BYTE abVariationGroups[],
  285. DWORD adwVariationMask[],
  286. DWORD adwRemoveVariations[],
  287. BYTE abVariation[],
  288. MUSIC_TIME mtTime,
  289. MUSIC_TIME mtNextChord,
  290. PatternTrackState* pState);
  291. HRESULT ComputeVariation(DirectMusicPartRef& rPartRef,
  292. int nPartIndex,
  293. DWORD dwFlags,
  294. DMUS_CHORD_PARAM& rCurrentChord,
  295. DMUS_CHORD_PARAM& rNextChord,
  296. BYTE abVariationGroups[],
  297. DWORD adwVariationMask[],
  298. DWORD adwRemoveVariations[],
  299. BYTE abVariation[],
  300. MUSIC_TIME mtTime,
  301. MUSIC_TIME mtNextChord,
  302. PatternTrackState* pState);
  303. BOOL MatchCommand(DMUS_COMMAND_PARAM_2 pCommands[], short nLength);
  304. void MatchRhythm(DWORD pRhythms[], short nPatternLength, short& nBits);
  305. BOOL MatchGrooveLevel(DMUS_COMMAND_PARAM_2& rCommand);
  306. BOOL MatchEmbellishment(DMUS_COMMAND_PARAM_2& rCommand);
  307. BOOL MatchNextCommand(DMUS_COMMAND_PARAM_2& rNextCommand);
  308. HRESULT LoadEvents(IAARIFFStream* pRIFF, MMCKINFO* pckMain);
  309. HRESULT LoadNoteList(LPSTREAM pStream, MMCKINFO* pckMain, short nClickTime);
  310. HRESULT LoadCurveList(LPSTREAM pStream, MMCKINFO* pckMain, short nClickTime);
  311. DirectMusicPart* FindPart(BYTE bChannelID);
  312. TListItem<DirectMusicPartRef>* FindPartRefByPChannel(DWORD dwPChannel);
  313. TListItem<DirectMusicPartRef>* CreatePart( DirectMusicPartRef& rPartRef, BYTE bPlaymode, WORD wMeasures = 1 );
  314. HRESULT Save( IStream* pIStream );
  315. HRESULT DM_SaveSinglePattern( IAARIFFStream* pIRiffStream );
  316. HRESULT DM_SavePatternChunk( IAARIFFStream* pIRiffStream );
  317. HRESULT DM_SavePatternRhythm( IAARIFFStream* pIRiffStream );
  318. HRESULT DM_SavePatternInfoList( IAARIFFStream* pIRiffStream );
  319. HRESULT MergeMarkerEvents( DMStyleStruct* pStyle );
  320. DirectMusicTimeSig& TimeSignature( DMStyleStruct* pStyle );
  321. long m_cRef;
  322. String m_strName; // pattern name
  323. DirectMusicTimeSig m_timeSig; // Patterns can override the Style's Time sig.
  324. WORD m_wID; // ID to identify for pattern playback (instead of name)
  325. BYTE m_bGrooveBottom; // bottom of groove range
  326. BYTE m_bGrooveTop; // top of groove range
  327. BYTE m_bDestGrooveBottom; // bottom of groove range for next pattern
  328. BYTE m_bDestGrooveTop; // top of groove range for next pattern
  329. WORD m_wEmbellishment; // Fill, Break, Intro, End, Normal, Motif
  330. WORD m_wNumMeasures; // length in measures
  331. DWORD* m_pRhythmMap; // variable array of rhythms for chord matching
  332. TList<DirectMusicPartRef> m_PartRefList; // list of part references
  333. //////// motif settings:
  334. BOOL m_fSettings; // Have these been set?
  335. DWORD m_dwRepeats; // Number of repeats. By default, 0.
  336. MUSIC_TIME m_mtPlayStart; // Start of playback. By default, 0.
  337. MUSIC_TIME m_mtLoopStart; // Start of looping portion. By default, 0.
  338. MUSIC_TIME m_mtLoopEnd; // End of loop. Must be greater than dwPlayStart. By default equal to length of motif.
  339. DWORD m_dwResolution; // Default resolution.
  340. //////// motif band:
  341. IDirectMusicBand* m_pMotifBand;
  342. TList<MUSIC_TIME> m_StartTimeList; // list of valid start times for this pattern
  343. DWORD m_dwFlags; // various flags
  344. };
  345. HRESULT AdjoinPChannel(TList<DWORD>& rPChannelList, DWORD dwPChannel);
  346. struct DMStyleStruct
  347. {
  348. DirectMusicPart* AllocPart( );
  349. void DeletePart( DirectMusicPart* pPart );
  350. HRESULT GetCommand(
  351. MUSIC_TIME mtTime,
  352. MUSIC_TIME mtOffset,
  353. IDirectMusicPerformance* pPerformance,
  354. IDirectMusicSegment* pSegment,
  355. DWORD dwGroupID,
  356. DMUS_COMMAND_PARAM_2* pCommand,
  357. BYTE& rbActualCommand);
  358. DirectMusicPart* FindPartByGUID( GUID guidPartID );
  359. DirectMusicTimeSig& TimeSignature() { return m_TimeSignature; }
  360. bool UsingDX8() { return (m_dwFlags & STYLEF_USING_DX8) ? true : false; }
  361. CDirectMusicPattern* SelectPattern(bool fNewMode,
  362. DMUS_COMMAND_PARAM_2* pCommands,
  363. StyleTrackState* StyleTrackState,
  364. PatternDispatcher& rDispatcher);
  365. HRESULT GetPattern(
  366. bool fNewMode,
  367. MUSIC_TIME mtNow,
  368. MUSIC_TIME mtOffset,
  369. StyleTrackState* pStyleTrackState,
  370. IDirectMusicPerformance* pPerformance,
  371. IDirectMusicSegment* pSegment,
  372. CDirectMusicPattern*& rpTargetPattern,
  373. MUSIC_TIME& rmtMeasureTime,
  374. MUSIC_TIME& rmtNextCommand);
  375. bool m_fLoaded; // is the style loaded in memory?
  376. GUID m_guid; // the style's GUID
  377. String m_strCategory; // Describes musical category of style
  378. String m_strName; // style name
  379. DWORD m_dwVersionMS; // Version # high-order 32 bits
  380. DWORD m_dwVersionLS; // Version # low-order 32 bits
  381. DirectMusicTimeSig m_TimeSignature; // The style's time signature
  382. double m_dblTempo; // The style's tempo
  383. TList<DirectMusicPart*> m_PartList; // Parts used by the style
  384. TList<CDirectMusicPattern*> m_PatternList; // Patterns used by the style
  385. TList<CDirectMusicPattern*> m_MotifList; // Motifs used by the style
  386. TList<IDirectMusicBand *> m_BandList; // Bands used by the style
  387. IDirectMusicBand* m_pDefaultBand; // Default band for style
  388. TList<IDirectMusicChordMap *> m_PersList; // Personalities used by the style
  389. IDirectMusicChordMap* m_pDefaultPers; // Default Personality for style
  390. TList<DWORD> m_PChannelList; // PChannels used by the style
  391. DWORD m_dwFlags; // various flags
  392. //TList<MUSIC_TIME> m_StartTimeList; // list of valid start times for this style
  393. };
  394. /*
  395. @interface IDirectMusicStyle |
  396. The <i IDirectMusicStyle> interface provides access to a Style object.
  397. The Style provides the Interactive Music Engine with the information it needs to perform
  398. a style of music (hence the name.)
  399. The application can also access information about the style, including the name,
  400. time signature, and recommended tempo.
  401. Since styles usually include sets of Personalities, Bands, and Motifs, the <i IDirectMusicStyle> interface
  402. also provides functions for accessing them.
  403. It also supports the <i IPersistStream> and <i IDirectMusicObject> interfaces for loading
  404. its data.
  405. @base public | IUnknown
  406. @meth HRESULT | EnumMotif | Returns the name of a motif, by location, from a Style's list of motifs.
  407. @meth HRESULT | GetMotif | Returns a motif, by name, from a Style's list of motifs.
  408. @meth HRESULT | EnumBand | Returns the name of a band, by location, from a Style's list of bands.
  409. @meth HRESULT | GetBand | Returns a band, by name, from a Style's list of bands.
  410. @meth HRESULT | GetDefaultBand | Returns a Style's default band.
  411. @meth HRESULT | EnumChordMap | Returns the name of a ChordMap, by location, from a Style's list of personalities.
  412. @meth HRESULT | GetChordMap | Returns a ChordMap, by name, from a Style's list of personalities.
  413. @meth HRESULT | GetDefaultChordMap | Returns a Style's default ChordMap.
  414. @meth HRESULT | GetTimeSignature | Returns the time signature of a Style.
  415. @meth HRESULT | GetEmbellishmentLength | Determines the length of a particular embellishment
  416. in a Style.
  417. @meth HRESULT | GetTempo | Returns the recommended tempo of a Style.
  418. */
  419. /////////////////////////////////////////////////////////////////////////////
  420. // CDMStyle
  421. class CDMStyle :
  422. public IDMStyle,
  423. public IDirectMusicStyle8,
  424. public IDirectMusicStyle8P,
  425. public IDirectMusicObject,
  426. public IPersistStream
  427. {
  428. public:
  429. CDMStyle();
  430. ~CDMStyle();
  431. HRESULT CreateMotifSegment(CDirectMusicPattern* pPattern, IUnknown * * ppSegment,
  432. DWORD dwRepeats);
  433. // IDMStyle
  434. public:
  435. // IUnknown
  436. //
  437. virtual STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  438. virtual STDMETHODIMP_(ULONG) AddRef();
  439. virtual STDMETHODIMP_(ULONG) Release();
  440. // IDirectMusicStyle methods
  441. // Returns: S_OK if the index refers to a motif; S_FALSE if it doesn't
  442. HRESULT STDMETHODCALLTYPE EnumMotif(
  443. /*in*/ DWORD dwIndex, // index into the motif list
  444. /*out*/ WCHAR *pwszName // name of the indexed motif
  445. );
  446. HRESULT STDMETHODCALLTYPE GetMotif(
  447. /*in*/ WCHAR* pwszName, // name of the motif for a secondary segment
  448. /*out*/ IDirectMusicSegment** ppSegment
  449. );
  450. HRESULT STDMETHODCALLTYPE GetBand(
  451. /*in*/ WCHAR* pwszName,
  452. /*out*/ IDirectMusicBand **ppBand
  453. );
  454. HRESULT STDMETHODCALLTYPE EnumBand(
  455. /*in*/ DWORD dwIndex,
  456. /*out*/ WCHAR *pwszName
  457. );
  458. HRESULT STDMETHODCALLTYPE GetDefaultBand(
  459. /*out*/ IDirectMusicBand **ppBand
  460. );
  461. HRESULT STDMETHODCALLTYPE GetChordMap(
  462. /*in*/ WCHAR* pwszName,
  463. /*out*/ IDirectMusicChordMap** ppChordMap
  464. );
  465. HRESULT STDMETHODCALLTYPE EnumChordMap(
  466. /*in*/ DWORD dwIndex,
  467. /*out*/ WCHAR *pwszName
  468. );
  469. HRESULT STDMETHODCALLTYPE GetDefaultChordMap(
  470. /*out*/ IDirectMusicChordMap **ppChordMap
  471. );
  472. HRESULT STDMETHODCALLTYPE GetTimeSignature(
  473. /*out*/ DMUS_TIMESIGNATURE* pTimeSig
  474. );
  475. HRESULT STDMETHODCALLTYPE GetEmbellishmentLength(
  476. /*in*/ DWORD dwType,
  477. /*in*/ DWORD dwLevel,
  478. /*out*/ DWORD* pdwMin,
  479. /*out*/ DWORD* pdwMax
  480. );
  481. HRESULT STDMETHODCALLTYPE GetTempo(double* pTempo);
  482. // IDirectMusicStyle8 methods
  483. HRESULT STDMETHODCALLTYPE ComposeMelodyFromTemplate(
  484. IDirectMusicStyle* pStyle,
  485. IDirectMusicSegment* pTempSeg,
  486. IDirectMusicSegment** ppSeqSeg
  487. );
  488. HRESULT STDMETHODCALLTYPE EnumPattern(
  489. /*in*/ DWORD dwIndex, // index into the motif list
  490. /*in*/ DWORD dwPatternType, // type of pattern
  491. /*out*/ WCHAR *wszName // name of the indexed motif
  492. );
  493. // IDirectMusicObject methods
  494. HRESULT STDMETHODCALLTYPE GetDescriptor(LPDMUS_OBJECTDESC pDesc) ;
  495. HRESULT STDMETHODCALLTYPE SetDescriptor(LPDMUS_OBJECTDESC pDesc) ;
  496. HRESULT STDMETHODCALLTYPE ParseDescriptor(LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) ;
  497. /* IPersist methods */
  498. // Retrieves the Style's Class ID.
  499. STDMETHOD(GetClassID)(THIS_ LPCLSID pclsid);
  500. /* IPersistStream methods */
  501. // Determines if the Style has been modified by simply checking the Style's m_fDirty flag. This flag is cleared
  502. // when a Style is saved or has just been created.
  503. STDMETHOD(IsDirty)(THIS);
  504. // Loads a Style from a stream.
  505. STDMETHOD(Load)(THIS_ LPSTREAM pStream);
  506. // Saves a Style to a stream in RIFF format.
  507. STDMETHOD(Save)(THIS_ LPSTREAM pStream, BOOL fClearDirty);
  508. STDMETHOD(GetSizeMax)(THIS_ ULARGE_INTEGER FAR* pcbSize);
  509. // IDMStyle
  510. HRESULT STDMETHODCALLTYPE GetPatternStream(WCHAR* wszName, DWORD dwPatternType, IStream** ppStream);
  511. HRESULT STDMETHODCALLTYPE GetStyleInfo(void **pData);
  512. HRESULT STDMETHODCALLTYPE IsDX8();
  513. HRESULT STDMETHODCALLTYPE CritSec(bool fEnter);
  514. HRESULT STDMETHODCALLTYPE EnumPartGuid(
  515. DWORD dwIndex, WCHAR* wszName, DWORD dwPatternType, GUID& rGuid);
  516. HRESULT STDMETHODCALLTYPE GenerateTrack(//IDirectMusicTrack* pChordTrack,
  517. IDirectMusicSegment* pTempSeg,
  518. IDirectMusicSong* pSong,
  519. DWORD dwTrackGroup,
  520. IDirectMusicStyle* pStyle,
  521. IDirectMusicTrack* pMelGenTrack,
  522. MUSIC_TIME mtLength,
  523. IDirectMusicTrack*& pNewTrack);
  524. protected: /* methods */
  525. void CleanUp();
  526. HRESULT DM_ParseDescriptor( IAARIFFStream* pIRiffStream, MMCKINFO* pckMain, LPDMUS_OBJECTDESC pDesc );
  527. HRESULT IMA25_LoadPersonalityReference( IStream* pStream, MMCKINFO* pck );
  528. HRESULT IMA25_LoadStyle( IAARIFFStream* pRIFF, MMCKINFO* pckMain );
  529. HRESULT DM_LoadPersonalityReference( IAARIFFStream* pIRiffStream, MMCKINFO* pckParent);
  530. HRESULT LoadReference(IStream *pStream,
  531. IAARIFFStream *pIRiffStream,
  532. MMCKINFO& ckParent,
  533. BOOL fDefault);
  534. HRESULT IncorporatePersonality( IDirectMusicChordMap* pPers, String strName, BOOL fDefault );
  535. HRESULT DM_LoadStyle( IAARIFFStream* pRIFF, MMCKINFO* pckMain );
  536. HRESULT GetStyle(IDirectMusicSegment* pFromSeg, MUSIC_TIME mt, DWORD dwTrackGroup, IDirectMusicStyle*& rpStyle);
  537. HRESULT CopySegment(IDirectMusicSegment* pTempSeg,
  538. IDirectMusicStyle* pStyle,
  539. IDirectMusicTrack* pSequenceTrack,
  540. DWORD dwTrackGroup,
  541. IDirectMusicSegment** ppSectionSeg);
  542. HRESULT CreateSequenceTrack(TList<CompositionFragment>& rlistFragments,
  543. IDirectMusicTrack*& pSequenceTrack);
  544. HRESULT CreatePatternTrack(TList<CompositionFragment>& rlistFragments,
  545. DirectMusicTimeSig& rTimeSig,
  546. double dblTempo,
  547. MUSIC_TIME mtLength,
  548. BYTE bPlaymode,
  549. IDirectMusicTrack*& pPatternTrack);
  550. HRESULT STDMETHODCALLTYPE EnumRegularPattern(
  551. /*in*/ DWORD dwIndex, // index into the motif list
  552. /*out*/ WCHAR *pwszName // name of the indexed motif
  553. );
  554. HRESULT STDMETHODCALLTYPE EnumStartTime(DWORD dwIndex, DMUS_COMMAND_PARAM* pCommand, MUSIC_TIME* pmtStartTime);
  555. protected: /* attributes */
  556. long m_cRef;
  557. BOOL m_fDirty; // has the style been modified?
  558. CRITICAL_SECTION m_CriticalSection; // for i/o
  559. BOOL m_fCSInitialized;
  560. DMStyleStruct m_StyleInfo; // The details of the style
  561. InversionGroup m_aInversionGroups[INVERSIONGROUPLIMIT]; // Inversion Groups for composing melodies
  562. };
  563. #endif //__DMSTYLE_H_