home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / dos / prg / dsik205 / dsik.dat / EXAMPLES / EXAMP08.C < prev    next >
C/C++ Source or Header  |  1995-04-10  |  3KB  |  99 lines

  1. /****************************************************************************
  2. *
  3. *                   Digital Sound Interface Kit (DSIK)
  4. *                            Version 2.00
  5. *
  6. *                           by Carlos Hasan
  7. *
  8. * Filename:     example8.c
  9. * Version:      Revision 1.0
  10. *
  11. * Language:     WATCOM C
  12. * Environment:  IBM PC (DOS/4GW)
  13. *
  14. * Description:  Play a module file using dynamic link audio drivers
  15. *               loaded from disk (EXPERIMENTAL).
  16. *
  17. * IMPORTANT:    To build all the dynamic link audio drivers required
  18. *               type at the DOS prompt: MKDRV SB PAS WSS GUS.
  19. *
  20. ****************************************************************************/
  21.  
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <conio.h>
  25. #include "audio.h"
  26. #include "import.h"
  27. #include "pe.h"
  28.  
  29. #define MODPATH "SONG.DSM"
  30. #define MODFORM FORM_DSM
  31.  
  32. int main(void)
  33. {
  34.     SoundCard SC;
  35.     Driver *Drv;
  36.     DSM *M;
  37.  
  38.     /* The sound system supports static and dynamic link audio drivers.
  39.        If you want to use static-link drivers you must register the
  40.        drivers using dRegisterDrivers. For example,
  41.  
  42.             dRegisterDrivers();
  43.             dLoadSetup(&SC,"SETUP.CFG");
  44.             dInit(&SC);
  45.  
  46.        If you want to use dynamic-link audio drivers you must use the
  47.        dLoadDriver and dRegisterDriver to load and register the driver
  48.        you will use. Also, you should NOT referece the static-link
  49.        audio driver variables (ie. SBDriver, GUSDriver, etc). If you
  50.        reference any of these driver variables, the static-link drivers
  51.        will be automatically linked to your code.
  52.        Here is an example about how to use dynamic-link drivers:
  53.  
  54.             dLoadSetup(&SC,"SETUP.CFG");
  55.             dRegisterDriver(dLoadDriver(&SC));
  56.             dInit(&SC);
  57.  
  58.        The dynamic-link audio drivers can be created running MKDRV.BAT
  59.        at the DOS prompt. For example,
  60.  
  61.             C:>MKDRV SB PAS WSS GUS
  62.  
  63.        The above line will build SB.DRV, PAS.DRV, WSS.DRV and GUS.DRV
  64.        dynamic-link audio driver files. The file format used for the
  65.        audio drivers is the Portable Executable (PE) file format.
  66.        However, the current implementation of the PE DLL loader does
  67.        not support all the features availables for this format, so do
  68.        not try to load PE files others than the DSIK audio drivers.
  69.      */
  70.  
  71.     if (dLoadSetup(&SC,"SETUP.CFG")) {
  72.         printf("Please run SETUP.EXE to configure.\n");
  73.         exit(EXIT_FAILURE);
  74.     }
  75.     if (!(Drv = dLoadDriver(&SC))) {
  76.         printf("Error loading %s audio driver.\n", SC.DriverName);
  77.         exit(EXIT_FAILURE);
  78.     }
  79.     dRegisterDriver(Drv);
  80.  
  81.     if (dInit(&SC)) {
  82.         printf("Error initializing the sound system.\n");
  83.         exit(EXIT_FAILURE);
  84.     }
  85.     atexit((void(*)(void))dDone);
  86.     if (!(M = dImportModule(MODPATH,MODFORM))) {
  87.         printf("Error (%03d) loading %s module file: %s.\n",
  88.             dError, MODPATH, dErrorMsg[dError]);
  89.         exit(EXIT_FAILURE);
  90.     }
  91.     dSetupVoices(M->Header.NumTracks,M->Header.MasterVolume);
  92.     dPlayMusic(M);
  93.     printf("Playing module. Press any key to continue.\n");
  94.     while (!kbhit()) dPoll();
  95.     dStopMusic();
  96.     dFreeModule(M);
  97.     return 0;
  98. }
  99.