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

  1. /****************************************************************************
  2. *
  3. *                   Digital Sound Interface Kit (DSIK)
  4. *                            Version 2.00
  5. *
  6. *                           by Carlos Hasan
  7. *
  8. * Filename:     example2.c
  9. * Version:      Revision 1.0
  10. *
  11. * Language:     WATCOM C
  12. * Environment:  IBM PC (DOS/4GW)
  13. *
  14. * Description:  Play a sample file.
  15. *
  16. ****************************************************************************/
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <conio.h>
  21. #include <ctype.h>
  22. #include "audio.h"
  23. #include "import.h"
  24.  
  25. #define SMPPATH "SAMPLE.WAV"
  26. #define SMPFORM FORM_WAV
  27.  
  28.  
  29. int main(void)
  30. {
  31.     SoundCard SC;
  32.     Sample *S;
  33.  
  34.     dRegisterDrivers();
  35.     if (dLoadSetup(&SC,"SETUP.CFG")) {
  36.         printf("Please run SETUP.EXE to configure.\n");
  37.         exit(EXIT_FAILURE);
  38.     }
  39.     if (dInit(&SC)) {
  40.         printf("Error initializing the sound system.\n");
  41.         exit(EXIT_FAILURE);
  42.     }
  43.     atexit((void(*)(void))dDone);
  44.     if (!(S = dImportSample(SMPPATH,SMPFORM))) {
  45.         printf("Error (%03d) loading %s sample file: %s.\n",
  46.             dError, SMPPATH, dErrorMsg[dError]);
  47.         exit(EXIT_FAILURE);
  48.     }
  49.     dSetupVoices(1,255);
  50.     dPlayVoice(0,S);
  51.     printf("Playing sample file at %d hertz. Press any key to exit.\n", S->Rate);
  52.     while (!kbhit() && dGetVoiceStatus(0) == PS_PLAYING) {
  53.         printf("(pos=%8ld)\r", dGetVoicePos(0));
  54.         dPoll();
  55.     }
  56.     if (kbhit()) getch();
  57.     dFreeSample(S);
  58.     return 0;
  59. }
  60.