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.

220 lines
8.4 KiB

  1. /*******************************Module*Header*********************************
  2. * Module Name: mmsys.h
  3. *
  4. * MultiMedia Systems MIDI Sequencer DLL Internal prototypes and data struct's
  5. * (contains constants, data types, and prototypes common to mci and seq
  6. * sections of mciseq.drv)
  7. *
  8. * Created: 4/10/90
  9. * Author: GREGSI
  10. *
  11. * History:
  12. *
  13. * Copyright (c) 1985-1998 Microsoft Corporation
  14. *
  15. \****************************************************************************/
  16. #include <port1632.h>
  17. /* Set up NT style debugging */
  18. #ifdef WIN32
  19. #if DBG
  20. #define DEBUG
  21. #endif
  22. #endif
  23. #define PUBLIC extern /* Public label. */
  24. #define PRIVATE static /* Private label. */
  25. #define EXPORT FAR _LOADDS /* Export function. */
  26. #define WAIT_FOREVER ((DWORD)(-1))
  27. #define GETMOTWORD(lpb) ((((WORD)*(LPBYTE)(lpb)) << (8 * sizeof(BYTE))) + *((LPBYTE)(lpb) + sizeof(BYTE)))
  28. typedef HANDLE HMIDISEQ;
  29. typedef HMIDISEQ FAR *LPHMIDISEQ;
  30. /****************************************************************************
  31. Sequencer error return values
  32. ****************************************************************************/
  33. #define MIDISEQERR_BASE 96
  34. #define MIDISEQERR_NOERROR 0 // no error
  35. #define MIDISEQERR_ERROR (MIDISEQERR_BASE+1) // unspecified error
  36. #define MIDISEQERR_NOSEQUENCER (MIDISEQERR_BASE+2) // no sequencer present
  37. #define MIDISEQERR_INVALSEQHANDLE (MIDISEQERR_BASE+3) // given sequence handle is invalid
  38. #define MIDISEQERR_NOMEM (MIDISEQERR_BASE+4) // memory allocation error
  39. #define MIDISEQERR_ALLOCATED (MIDISEQERR_BASE+5) // sequencer already allocated
  40. #define MIDISEQERR_BADERRNUM (MIDISEQERR_BASE+6) // error number out of range
  41. #define MIDISEQERR_INTERNALERROR (MIDISEQERR_BASE+7) // internal error - see mmddk.h
  42. #define MIDISEQERR_INVALMIDIHANDLE (MIDISEQERR_BASE+8) // specified MIDI output handle invalid
  43. #define MIDISEQERR_INVALMSG (MIDISEQERR_BASE+9) // specified msg was invalid
  44. #define MIDISEQERR_INVALPARM (MIDISEQERR_BASE+10) // msg parameter bad
  45. #define MIDISEQERR_TIMER (MIDISEQERR_BASE+11) // timer failed
  46. /****************************************************************************
  47. Sequencer callback
  48. ****************************************************************************/
  49. typedef DRVCALLBACK MIDISEQCALLBACK;
  50. typedef MIDISEQCALLBACK FAR *LPMIDISEQCALLBACK;
  51. // callback messages
  52. #define MIDISEQ_DONE 0
  53. #define MIDISEQ_RESET 1
  54. #define MIDISEQ_DONEPLAY 2
  55. /****************************************************************************
  56. Sequencer data block header
  57. ****************************************************************************/
  58. typedef struct midiseqhdr_tag {
  59. LPSTR lpData; // pointer to locked data block
  60. DWORD dwLength; // length of data in data block
  61. WORD wFlags; // assorted flags (see defines)
  62. WORD wTrack; // track number
  63. struct midiseqhdr_tag far *lpNext; // reserved for sequencer
  64. DWORD reserved; // reserved for sequencer
  65. } MIDISEQHDR;
  66. typedef MIDISEQHDR FAR *LPMIDISEQHDR;
  67. // defines for MIDISEQOUTHDR flag bits
  68. #define MIDISEQHDR_DONE 0x0001 // done bit
  69. #define MIDISEQHDR_BOT 0x0002 // beginning of track
  70. #define MIDISEQHDR_EOT 0x0004 // end of track
  71. /****************************************************************************
  72. Sequencer support structures
  73. ****************************************************************************/
  74. /* Struct used for the seqinfo message. */
  75. typedef struct midiseqinfo_tag {
  76. WORD wDivType; // division type of file
  77. WORD wResolution; // resolution of file
  78. DWORD dwLength; // length of sequence in ticks
  79. BOOL bPlaying; // whether file is playing
  80. BOOL bSeeking; // whether seek is in progress
  81. BOOL bReadyToPlay; // if all is set to play
  82. DWORD dwCurrentTick; // current position in terms of file's ticks
  83. DWORD dwPlayTo;
  84. DWORD dwTempo; // tempo of file in microseconds per tick
  85. // BYTE bTSNum; // numerator of time signature
  86. // BYTE bTSDenom; // denominator of time signature
  87. // WORD wNumTracks; // number of tracks in the file
  88. // HANDLE hPort; // MIDI port handle
  89. BOOL bTempoFromFile; // whether file's tempo events are to be used
  90. MMTIME mmSmpteOffset; // offset into file if in smpte format
  91. WORD wInSync; // in (slave) sync mode
  92. WORD wOutSync; // out (master) sync mode
  93. BYTE tempoMapExists;
  94. BYTE bLegalFile;
  95. } MIDISEQINFO;
  96. typedef MIDISEQINFO FAR *LPMIDISEQINFO;
  97. /****************************************************************************
  98. Sequencer synchronization constants
  99. ****************************************************************************/
  100. #define SEQ_SYNC_NOTHING 0
  101. #define SEQ_SYNC_FILE 1
  102. #define SEQ_SYNC_MIDI 2
  103. #define SEQ_SYNC_SMPTE 3
  104. #define SEQ_SYNC_OFFSET 4
  105. #define SEQ_SYNC_OFFSET_NOEFFECT 0xFFFFFFFF
  106. /****************************************************************************
  107. Sequencer file division-type constants
  108. ****************************************************************************/
  109. #define SEQ_DIV_PPQN 0
  110. #define SEQ_DIV_SMPTE_24 24
  111. #define SEQ_DIV_SMPTE_25 25
  112. #define SEQ_DIV_SMPTE_30DROP 29
  113. #define SEQ_DIV_SMPTE_30 30
  114. /****************************************************************************
  115. midiSeqMessage constants
  116. ****************************************************************************/
  117. #define SEQ_PLAY 3
  118. #define SEQ_RESET 4
  119. #define SEQ_SETTEMPO 6
  120. #define SEQ_SETSONGPTR 7
  121. #define SEQ_SETUPTOPLAY 8
  122. #define SEQ_STOP 9
  123. #define SEQ_TRACKDATA 10
  124. #define SEQ_GETINFO 11
  125. #define SEQ_SETPORT 12
  126. #define SEQ_SETPORTOFF 13
  127. #define SEQ_MSTOTICKS 14
  128. #define SEQ_TICKSTOMS 15
  129. #define SEQ_SEEKTICKS 16
  130. #define SEQ_SYNCSEEKTICKS 17
  131. #define SEQ_SETSYNCSLAVE 18
  132. #define SEQ_SETSYNCMASTER 19
  133. #define SEQ_QUERYGENMIDI 20
  134. #define SEQ_QUERYHMIDI 21
  135. /***************** "play to" code for seq_play ***************************/
  136. #define PLAYTOEND ((DWORD)-1)
  137. /****************************************************************************
  138. sequencer support
  139. ****************************************************************************/
  140. // opening info -- needed for MIDISEQOPEN message
  141. typedef struct midiseqopendesc_tag {
  142. DWORD_PTR dwCallback; // callback
  143. DWORD_PTR dwInstance; // app's private instance information
  144. HANDLE hStream; // handle to stream
  145. LPBYTE lpMIDIFileHdr;
  146. DWORD dwLen; // length of midi file header
  147. } MIDISEQOPENDESC;
  148. typedef MIDISEQOPENDESC FAR *LPMIDISEQOPENDESC;
  149. /****************************************************************************
  150. MIDISeqMessage() messages
  151. ****************************************************************************/
  152. #define SEQ_OPEN 1
  153. #define SEQ_CLOSE 2
  154. // microseconds per minute -- a handy thing to have around
  155. #define USecPerMinute 60000000
  156. #define USecPerSecond 1000000
  157. #define USecPerMinute 60000000
  158. #define DefaultTempo 120
  159. /********************** COMMON SYSTEM PROTOTYPES ************************/
  160. PUBLIC DWORD_PTR FAR PASCAL midiSeqMessage(HMIDISEQ hMIDISeq, UINT msg,
  161. DWORD_PTR lParam1, DWORD_PTR lParam2);
  162. /*** math support ****/
  163. #ifdef WIN16
  164. PUBLIC LONG FAR PASCAL muldiv32(long, long, long);
  165. #else
  166. #define muldiv32 MulDiv
  167. #endif // WIN16
  168. #define WTM_DONEPLAY (WM_USER+0)
  169. #define WTM_QUITTASK (WM_USER+1)
  170. #define WTM_FILLBUFFER (WM_USER+2)
  171. PUBLIC UINT FAR PASCAL TaskBlock(void);
  172. PUBLIC BOOL FAR PASCAL TaskSignal(DWORD dwThreadId, UINT wMsg);
  173. PUBLIC VOID FAR PASCAL TaskWaitComplete(HANDLE htask);
  174. #ifdef WIN32
  175. #undef Yield
  176. #define Yield() { LeaveSeq(); EnterSeq(); } /* Should there be a Sleep call ? */
  177. VOID InitCrit(VOID);
  178. VOID DeleteCrit(VOID);
  179. DWORD midiSeqMessageInternal(HMIDISEQ, UINT, DWORD, DWORD);
  180. VOID EnterSeq(VOID);
  181. VOID LeaveSeq(VOID);
  182. #else
  183. #define EnterSeq()
  184. #define LeaveSeq()
  185. #endif // WIN32