home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / audio / midiplyr / smfi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-05  |  4.7 KB  |  174 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  4. //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
  5. //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR
  6. //  A PARTICULAR PURPOSE.
  7. //
  8. //  Copyright (C) 1993 - 1997 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11. #ifndef _SMFI_
  12. #define _SMFI_
  13.  
  14. /* Handle structure for HSMF
  15. */ 
  16.  
  17. #define SMF_TF_EOT          0x00000001L
  18. #define SMF_TF_INVALID      0x00000002L
  19.  
  20. typedef struct tag_tempomapentry
  21. {
  22.     TICKS           tkTempo;           
  23.     DWORD           msBase;            
  24.     DWORD           dwTempo;           
  25. }   TEMPOMAPENTRY,
  26.     *PTEMPOMAPENTRY;
  27.  
  28. typedef struct tag_smf *PSMF;
  29.  
  30. typedef struct tag_track
  31. {
  32.     PSMF            pSmf;
  33.  
  34.     DWORD           idxTrack;          
  35.     
  36.     TICKS           tkPosition;        
  37.     DWORD           cbLeft;            
  38.     HPBYTE          hpbImage;          
  39.     BYTE            bRunningStatus;    
  40.     
  41.     DWORD           fdwTrack;          
  42.  
  43.     struct
  44.     {
  45.         TICKS       tkLength;
  46.         DWORD       cbLength;
  47.     }
  48.     smti;                              
  49.  
  50. }   TRACK,
  51.     *PTRACK;
  52.  
  53. #define SMF_F_EOF               0x00000001L
  54. #define SMF_F_INSERTSYSEX       0x00000002L
  55.  
  56. #define C_TEMPO_MAP_CHK     16
  57. typedef struct tag_smf
  58. {
  59.     char            szName[128];
  60.     HPBYTE          hpbImage;
  61.     DWORD           cbImage;
  62.     HTASK           htask;
  63.  
  64.     TICKS           tkPosition;
  65.     TICKS           tkLength;
  66.     DWORD           dwFormat;
  67.     DWORD           dwTracks;
  68.     DWORD           dwTimeDivision;
  69.     DWORD           fdwSMF;
  70.  
  71.     DWORD           cTempoMap;
  72.     DWORD           cTempoMapAlloc;
  73.     HLOCAL          hTempoMap;
  74.     PTEMPOMAPENTRY  pTempoMap;
  75.  
  76.     DWORD           dwPendingUserEvent;
  77.     DWORD           cbPendingUserEvent;
  78.     HPBYTE          hpbPendingUserEvent;
  79.     
  80.     TRACK           rTracks[];
  81. }   SMF;
  82.  
  83. typedef struct tagEVENT
  84. {
  85.     TICKS           tkDelta;           
  86.     BYTE            abEvent[3];        
  87.                                        
  88.                                        
  89.                                        
  90.     DWORD           cbParm;            
  91.     HPBYTE          hpbParm;           
  92. }   EVENT,
  93.     BSTACK *SPEVENT;
  94.  
  95. #define EVENT_TYPE(event)       ((event).abEvent[0])
  96. #define EVENT_CH_B1(event)      ((event).abEvent[1])
  97. #define EVENT_CH_B2(event)      ((event).abEvent[2])
  98.  
  99. #define EVENT_META_TYPE(event)  ((event).abEvent[1])
  100.  
  101. SMFRESULT FNLOCAL smfBuildFileIndex(
  102.     PSMF BSTACK *       ppsmf);
  103.  
  104. DWORD FNLOCAL smfGetVDword(
  105.     HPBYTE              hpbImage,
  106.     DWORD               dwLeft,                                
  107.     DWORD BSTACK *      pdw);
  108.  
  109. SMFRESULT FNLOCAL smfGetNextEvent(
  110.     PSMF                psmf,
  111.     SPEVENT             pevent,
  112.     TICKS               tkMax);
  113.  
  114. /*
  115. ** Useful macros when dealing with hi-lo format integers
  116. */
  117. #define DWORDSWAP(dw) \
  118.     ((((dw)>>24)&0x000000FFL)|\
  119.     (((dw)>>8)&0x0000FF00L)|\
  120.     (((dw)<<8)&0x00FF0000L)|\
  121.     (((dw)<<24)&0xFF000000L))
  122.  
  123. #define WORDSWAP(w) \
  124.     ((((w)>>8)&0x00FF)|\
  125.     (((w)<<8)&0xFF00))
  126.  
  127. #define FOURCC_RMID     mmioFOURCC('R','M','I','D')
  128. #define FOURCC_data     mmioFOURCC('d','a','t','a')
  129. #define FOURCC_MThd     mmioFOURCC('M','T','h','d')
  130. #define FOURCC_MTrk     mmioFOURCC('M','T','r','k')
  131.  
  132. typedef struct tag_chunkhdr
  133. {
  134.     FOURCC  fourccType;
  135.     DWORD   dwLength;
  136. }   CHUNKHDR,
  137.     *PCHUNKHDR;
  138.  
  139. #pragma pack(1)    // override cl32 default packing, to match disk file.
  140. typedef struct tag_filehdr
  141. {
  142.     WORD    wFormat;
  143.     WORD    wTracks;
  144.     WORD    wDivision;
  145. }   FILEHDR,
  146.     *PFILEHDR;
  147. #pragma pack()
  148.  
  149. /* NOTE: This is arbitrary and only used if there is a tempo map but no
  150. ** entry at tick 0.
  151. */
  152. #define MIDI_DEFAULT_TEMPO      (500000L)
  153.  
  154. #define MIDI_MSG                ((BYTE)0x80)
  155. #define MIDI_NOTEOFF            ((BYTE)0x80)
  156. #define MIDI_NOTEON             ((BYTE)0x90)
  157. #define MIDI_POLYPRESSURE       ((BYTE)0xA0)
  158. #define MIDI_CONTROLCHANGE      ((BYTE)0xB0)
  159. #define MIDI_PROGRAMCHANGE      ((BYTE)0xC0)
  160. #define MIDI_CHANPRESSURE       ((BYTE)0xD0)
  161. #define MIDI_PITCHBEND          ((BYTE)0xE0)
  162. #define MIDI_META               ((BYTE)0xFF)
  163. #define MIDI_SYSEX              ((BYTE)0xF0)
  164. #define MIDI_SYSEXEND           ((BYTE)0xF7)
  165.  
  166. #define MIDI_META_TRACKNAME     ((BYTE)0x03)
  167. #define MIDI_META_EOT           ((BYTE)0x2F)
  168. #define MIDI_META_TEMPO         ((BYTE)0x51)
  169. #define MIDI_META_TIMESIG       ((BYTE)0x58)
  170. #define MIDI_META_KEYSIG        ((BYTE)0x59)
  171. #define MIDI_META_SEQSPECIFIC   ((BYTE)0x7F)
  172.  
  173. #endif
  174.