home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / windows / c / playwave / text.txt < prev    next >
Encoding:
Text File  |  1993-11-13  |  5.0 KB  |  132 lines

  1. PLAYWAVE is the Share Ware version of my full object oriented multi-media library.  
  2. This public domain library contained here in allows you to use sound wave files (*.WAV) 
  3. from disc directly, or as resource objects imbedded into an applications resource file.
  4. Included in this documentation are examples of how to use the PLAYWAVE libraries.  
  5. Also included along with this document in the zipped file are example usage of the library 
  6. contained in the SNDPLAY example.  These examples are used as the study aid in this 
  7. document.
  8. The file MMSYSTEM.DLL, (shipped with WINDOWS 3.1) is required in your 
  9. windows directory before these functions will operate.
  10.  
  11. PLAYWAVE.HPP
  12. #include <windows.h>
  13.  
  14. typedef BOOL (FAR PASCAL *_sndPlaySound_)(LPSTR,WORD);
  15.  
  16. class    PLAYWAVE
  17. {
  18.  private:
  19.   WORD wError;
  20.   _sndPlaySound_ sndPlaySound;
  21.   HANDLE hMemMMSYSTEM;
  22.   void Error(void);
  23.  public:
  24.   PLAYWAVE();
  25.   ~PLAYWAVE();
  26.   void Play(LPSTR,WORD);
  27.   void Resource(HANDLE,LPSTR);
  28. };
  29.  
  30. #define  SOUND_SYNC        0x0000         // play synchronously (default)
  31. #define  SOUND_ASYNC        0x0001         // play asynchronously
  32. #define  SOUND_NO_DEFAULT      0x0002         // don't use default sound
  33. #define  SOUND_MEMORY          0x0004         // lpszSoundName points to a memory file
  34. #define  SOUND_LOOP            0x0008         // loop the sound until next sndPlaySound
  35. #define  SOUND_NOSTOP          0x0010         // don't stop any currently playing sound
  36.  
  37.  
  38. #define     WAVE_ERROR_BAD_FORMAT    0x0020         // Wave format not supported
  39. #define WAVE_ERROR_PLAYING    0x0021         // Still something playing
  40. #define     WAVE_ERROR_NOT_READY    0x0022         // Header not ready
  41. #define WAVE_ERROR_SYNC_ONLY    0x0023         // Device is synchronous only
  42.  
  43. The above header file, PLAYWAVE.HPP, is a C++ header with function prototype 
  44. definitions and control constants defined.  This file is to be included in any applications 
  45. that you develop.
  46.  
  47.  
  48. PLAYWAVE.LIB
  49. PLAYWAVE.LIB is an object library containing the code to implement the PLAYWAVE 
  50. object.  This file must be linked to the application for the function to operate.  Please 
  51. remember that the functions that make up the object rely on MMSYSTEM.DLL to be 
  52. present in the WINDOWS directory.
  53.  
  54. SNDPLAY.CPP
  55. #include "playwave.hpp"
  56.  
  57. PLAYWAVE    PlayWave;
  58.  
  59. int PASCAL WinMain(HANDLE hInstance,
  60.            HANDLE hPrevInstance,
  61.            LPSTR lpstrCmdLine,
  62.            int nCmdShow)
  63. {
  64.   PlayWave.Resource(hInstance,"SOUND");
  65.   PlayWave.Play("SPOCKD.WAV",SOUND_SYNC);
  66. }
  67.  
  68. SNDPLAY.CPP is the example usage program listing.  This very simple and short 
  69. program demonstrates how easy it is to play wave files using this object.  Both disk file 
  70. and resource file methods are demonstrated.
  71. In line 1, the C++ header file, PLAYWAVE.HPP is included.  The format shown is 
  72. when the header file is located in the current directory.  Of course the < and > symbols 
  73. should enclose the file name if you build a separate \CPP\INCLnn and \CPP\LIBRnn 
  74. directories for your sound library.
  75. In line 3, an instance of the PLAYWAVE object is created.  Once this object 
  76. successfully creates an instance and initializes without error, sound capability is now 
  77. enabled.
  78. Lines 5 through 8 comprise the opening of the WinMain windows application entry 
  79. point.  Note the absence of a message loop.  One is not needed when you do not wish to 
  80. process window messages.
  81. Line 10 plays a sound resource imbedded inside the resource file.  The object looks for 
  82. objects of type ID_WAVE matching the name specified by the LPSTR parameter.  If no 
  83. matching sound resource is found, then the request is ignored.
  84. Line 11 plays a sound file (*.WAV) file from the disk.  Note the use of the 
  85. SOUND_SYNC directive.  Any of the directives listed in the PLAYWAVE.HPP header file 
  86. can be used.
  87. This simple program demonstrates the use of the object in it's entirety.  Please note the 
  88. syntax required, and that when a resource sound is used, a handle to the instance of the 
  89. application must be passed.  This can be obtained from the WinMain procedure 
  90. parameters.
  91.  
  92. SNDPLAY.RC
  93. WAV_WHISTLE    ID_WAVE    "WHISTLE.WAV"
  94. The above single line entry in the resource script file demonstrates how to insert a 
  95. wave file resource into the resource file.  The first string is the resource name identifying 
  96. the sound resource inside the resource file.  The second string identifies the type of 
  97. resource, in this case a wave file.  The third string (be sure to use the quotes) identifies the 
  98. full path to the wave file to be imbedded into the resource file.
  99.  
  100. DISCLAIMER
  101. The data contained here in is intended for educational purposes only.  Any loss or 
  102. damage from using these functions are the responsibility of the individual programmers or 
  103. hobbyist.  As with any software system, bugs do creep into the workings when least 
  104. expected, so use and enjoy.
  105.  
  106. PLAYWAVE
  107. Dynamic Software Solutions
  108. 5860 Picadilly Lane
  109. Beaumont, Tx. 77708
  110. BBS (409) 899-1709
  111. 2400,n,8,1
  112. USERNAME == PLAYWAVE
  113. PASSWORD == REGISTER
  114.  
  115.  
  116. PLAYWAVE
  117. Dynamic Software Solutions
  118. 5860 Picadilly Lane
  119. Beaumont, Tx. 77708
  120. BBS (409) 899-1709
  121. 2400,n,8,1
  122. USERNAME == PLAYWAVE
  123. PASSWORD == REGISTER
  124.  
  125.  
  126. Page 2
  127.  
  128. Page 3
  129.  
  130.  
  131.  
  132.