home *** CD-ROM | disk | FTP | other *** search
/ NEXT Generation 27 / NEXT27.iso / pc / demos / emperor / dx3.exe / SDK / SAMPLES / ROCKEM / MIDI.CPP < prev    next >
C/C++ Source or Header  |  1996-08-28  |  3KB  |  130 lines

  1. /*==========================================================================
  2.  *
  3.  *  Copyright (C) 1995, 1996 Microsoft Corporation. All Rights Reserved.
  4.  *
  5.  *  File: midi.cpp
  6.  *
  7.  ***************************************************************************/
  8.  
  9. // Includes....
  10. #include "windows.h"
  11. #include "midi.h"
  12. #include "stdio.h"
  13.  
  14. // Externals....
  15. extern HWND     g_hWnd;
  16.  
  17. //------------------------------------------------------------------
  18. // 
  19. // Function     : PlayMidi()
  20. //
  21. // Purpose      : Plays a midi file
  22. //
  23. //------------------------------------------------------------------
  24.  
  25. BOOL PlayMidi(char *sFileName)
  26. {
  27.     char buf[256];
  28.  
  29.     sprintf(buf, "open %s type sequencer alias MUSIC", sFileName);
  30.     
  31.     if (mciSendString("close all", NULL, 0, NULL) != 0)
  32.     {
  33.         return(FALSE);
  34.     }
  35.  
  36.     if (mciSendString(buf, NULL, 0, NULL) != 0)
  37.     {
  38.         return(FALSE);
  39.     }
  40.  
  41.     if (mciSendString("play MUSIC from 0", NULL, 0, g_hWnd) != 0)
  42.     {
  43.         return(FALSE);
  44.     }
  45.     
  46.     // Yahoo!
  47.     return TRUE;
  48. }
  49.  
  50. //------------------------------------------------------------------
  51. // 
  52. // Function     : PauseMidi()
  53. //
  54. // Purpose      : Pauses midi file
  55. //
  56. //------------------------------------------------------------------
  57.  
  58. BOOL PauseMidi()
  59. {
  60.     // Pause if we're not already paused...
  61.     if (mciSendString("stop MUSIC", NULL, 0, NULL) != 0)
  62.     {
  63.         return(FALSE);
  64.     }
  65.  
  66.     
  67.     // Yahoo!
  68.     return TRUE;
  69. }
  70.  
  71. //------------------------------------------------------------------
  72. // 
  73. // Function     : ResumeMidi()
  74. //
  75. // Purpose      : Resumes playing of a midi file
  76. //
  77. //------------------------------------------------------------------
  78.  
  79. BOOL ResumeMidi()
  80. {       
  81.     // Resume midi
  82.     if (mciSendString("play MUSIC notify", NULL, 0, g_hWnd) != 0)
  83.     {
  84.         return(FALSE);
  85.     }
  86.  
  87.     // Yahoo!
  88.     return TRUE;
  89. }
  90.  
  91. //------------------------------------------------------------------
  92. // 
  93. // Function     : StopMidi
  94. //
  95. // Purpose      : Stops a midi file playing
  96. //
  97. //------------------------------------------------------------------
  98.  
  99. BOOL StopMidi()
  100. {
  101.     if (mciSendString("close all", NULL, 0, NULL) != 0)
  102.     {
  103.         return(FALSE);
  104.     }   
  105.  
  106.     // Yahoo!
  107.     return TRUE;
  108. }
  109.  
  110. //------------------------------------------------------------------
  111. // 
  112. // Function     : ReplayMidi()
  113. //
  114. // Purpose      : Replays a midi file
  115. //
  116. //------------------------------------------------------------------
  117.  
  118. BOOL ReplayMidi()
  119. {
  120.     // Replay midi
  121.     if (mciSendString("play MUSIC from 0 notify", NULL, 0, g_hWnd) != 0)
  122.     {
  123.         return(FALSE);
  124.     }
  125.  
  126.     // Yahoo!
  127.     return TRUE;
  128. }
  129.  
  130.