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.

177 lines
5.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (c) 1998-1999 Microsoft Corporation
  6. //
  7. // File: dmsect.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // DMSection.h : Declaration of the CDMSection
  11. #ifndef __DMSECTION_H_
  12. #define __DMSECTION_H_
  13. #include "dmusici.h"
  14. #include "dmusicf.h"
  15. #include "sjdefs.h"
  16. #include "iostru.h"
  17. #include "AARiff.h"
  18. #include "str.h"
  19. #include "tlist.h"
  20. #include "timesig.h"
  21. #include "dmstylep.h"
  22. #define TRACK_COMMAND 0
  23. #define TRACK_CHORD 1
  24. #define TRACK_RHYTHM 2
  25. #define TRACK_REPEATS 3
  26. #define TRACK_START 4
  27. #define MAJOR_PATTERN 0x91 // 10010001
  28. #define MINOR_PATTERN 0x89 // 10001001
  29. struct DMSubChord
  30. {
  31. HRESULT Save( IAARIFFStream* pRIFF );
  32. DMSubChord() : m_dwChordPattern(0), m_dwScalePattern(0), m_dwInversionPoints(0),
  33. m_bChordRoot(0), m_bScaleRoot(0), m_dwLevels(1 << SUBCHORD_STANDARD_CHORD)
  34. {}
  35. DMSubChord(DMUS_SUBCHORD& DMSC)
  36. {
  37. m_dwChordPattern = DMSC.dwChordPattern;
  38. m_dwScalePattern = DMSC.dwScalePattern;
  39. m_dwInversionPoints = DMSC.dwInversionPoints;
  40. m_dwLevels = DMSC.dwLevels;
  41. m_bChordRoot = DMSC.bChordRoot;
  42. m_bScaleRoot = DMSC.bScaleRoot;
  43. }
  44. operator DMUS_SUBCHORD()
  45. {
  46. DMUS_SUBCHORD result;
  47. result.dwChordPattern = m_dwChordPattern;
  48. result.dwScalePattern = m_dwScalePattern;
  49. result.dwInversionPoints = m_dwInversionPoints;
  50. result.dwLevels = m_dwLevels;
  51. result.bChordRoot = m_bChordRoot;
  52. result.bScaleRoot = m_bScaleRoot;
  53. return result;
  54. }
  55. DWORD m_dwChordPattern; // Notes in the subchord
  56. DWORD m_dwScalePattern; // Notes in the scale
  57. DWORD m_dwInversionPoints; // Where inversions can occur
  58. DWORD m_dwLevels; // Which levels are supported by this subchord
  59. BYTE m_bChordRoot; // Root of the subchord
  60. BYTE m_bScaleRoot; // Root of the scale
  61. };
  62. struct DMChord
  63. {
  64. HRESULT Save( IAARIFFStream* pRIFF );
  65. DMChord() : m_strName(""), m_mtTime(0), m_wMeasure(0), m_bBeat(0), m_fSilent(false) {}
  66. DMChord(DMUS_CHORD_PARAM& DMC);
  67. DMChord(DMChord& DMC);
  68. operator DMUS_CHORD_PARAM();
  69. DMChord& operator= (const DMChord& rDMC);
  70. String m_strName; // Name of the chord
  71. MUSIC_TIME m_mtTime; // Time, in clocks
  72. WORD m_wMeasure; // Measure this falls on
  73. BYTE m_bBeat; // Beat this falls on
  74. BYTE m_bKey; // Underlying key
  75. DWORD m_dwScale; // Underlying scale
  76. bool m_fSilent; // Is this chord silent?
  77. TList<DMSubChord> m_SubChordList; // List of sub chords
  78. };
  79. struct DMCommand
  80. {
  81. MUSIC_TIME m_mtTime; // Time, in clocks
  82. WORD m_wMeasure; // Measure this falls on
  83. BYTE m_bBeat; // Beat this falls on
  84. BYTE m_bCommand; // Command type
  85. BYTE m_bGrooveLevel; // Groove level
  86. BYTE m_bGrooveRange; // Groove range
  87. BYTE m_bRepeatMode; // Repeat mode
  88. };
  89. struct MuteMapping
  90. {
  91. MUSIC_TIME m_mtTime;
  92. DWORD m_dwPChannelMap;
  93. BOOL m_fMute;
  94. };
  95. /////////////////////////////////////////////////////////////////////////////
  96. // CDMSection
  97. class CDMSection :
  98. public IDMSection,
  99. public IDirectMusicObject,
  100. public IPersistStream
  101. {
  102. public:
  103. CDMSection();
  104. ~CDMSection();
  105. void CleanUp(BOOL fStop = FALSE);
  106. HRESULT LoadSection(IAARIFFStream* pRIFF, MMCKINFO* pckMain);
  107. HRESULT LoadStyleReference( LPSTREAM pStream, MMCKINFO* pck );
  108. HRESULT LoadChordList(LPSTREAM pStream, MMCKINFO* pckMain, TList<DMChord>& ChordList);
  109. HRESULT LoadCommandList(LPSTREAM pStream, MMCKINFO* pckMain, TList<DMCommand>& CommandList);
  110. HRESULT SaveChordList( IAARIFFStream* pRIFF );
  111. HRESULT SaveCommandList( IAARIFFStream* pRIFF );
  112. // IUnknown
  113. //
  114. virtual STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  115. virtual STDMETHODIMP_(ULONG) AddRef();
  116. virtual STDMETHODIMP_(ULONG) Release();
  117. /* IPersist methods */
  118. // Retrieves the Style's Class ID.
  119. STDMETHOD(GetClassID)(THIS_ LPCLSID pclsid);
  120. /* IPersistStream methods */
  121. // Determines if the Style has been modified by simply checking the Style's m_fDirty flag. This flag is cleared
  122. // when a Style is saved or has just been created.
  123. STDMETHOD(IsDirty)(THIS);
  124. // Loads a Style from a stream.
  125. STDMETHOD(Load)(THIS_ LPSTREAM pStream);
  126. // Saves a Style to a stream in RIFF format.
  127. STDMETHOD(Save)(THIS_ LPSTREAM pStream, BOOL fClearDirty);
  128. STDMETHOD(GetSizeMax)(THIS_ ULARGE_INTEGER FAR* pcbSize);
  129. protected:
  130. long m_cRef;
  131. String m_strName; // Name of section
  132. String m_strStyleName; // Name of associated style file
  133. IDirectMusicStyle* m_pStyle; // Pointer to the style interface
  134. DWORD m_dwTime; // Time in clocks
  135. DWORD m_dwFlags; // ?
  136. WORD m_wTempo; // Tempo
  137. WORD m_wRepeats; // Repeats
  138. WORD m_wMeasureLength; // Number of measures
  139. DWORD m_dwClockLength; // Total number of clocks
  140. WORD m_wClocksPerMeasure; // Clocks per measure
  141. WORD m_wClocksPerBeat; // Clocks per beat
  142. WORD m_wTempoFract; // ?
  143. BYTE m_bRoot; // Root key of section
  144. TList<DMChord> m_ChordList; // List of chords
  145. TList<DMCommand> m_CommandList; // List of commands
  146. // style reference
  147. IDirectMusicBand* m_pIDMBand; // Section's band
  148. public:
  149. // IDMSection
  150. public:
  151. STDMETHOD(CreateSegment)(IDirectMusicSegment* pSegment);
  152. STDMETHOD(GetStyle)(IUnknown** ppStyle);
  153. // IDirectMusicStyle methods
  154. HRESULT STDMETHODCALLTYPE GetDescriptor(LPDMUS_OBJECTDESC pDesc) ;
  155. HRESULT STDMETHODCALLTYPE SetDescriptor(LPDMUS_OBJECTDESC pDesc) ;
  156. HRESULT STDMETHODCALLTYPE ParseDescriptor(LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc) ;
  157. };
  158. #endif //__DMSECTION_H_