home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / src_cpp / src / dacdma.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-25  |  1.4 KB  |  52 lines

  1. // Copyright 1993, Mark T. Pflaging
  2. // This is the test suite for all of the other routines.
  3. // It plays sounds through the Sound Blaster Digital to
  4. // Analog converter, directly from Expanded memory using
  5. // DMA (direct memory access) for "background" operation.
  6. // The program preloads sounds into Expanded memory and
  7. // assigns them names.  Then it plays the sounds back
  8. // directly from EMM based on the name they have been given.
  9. #include "sb.hpp"
  10. #include "sndfile.hpp"
  11.  
  12. #include <conio.h>
  13.  
  14. void SndPlaySnd(SoundBlaster & sb, SB_SoundFile & test)
  15. {
  16.     test.Play(sb);
  17.  
  18.     while(!kbhit() && !(sb.DMA_Complete()))
  19.         ;
  20.     if(!(sb.DMA_Complete())) {
  21.         sb.Halt_DMA();
  22.         getch();
  23.     }
  24. }
  25.  
  26. #pragma argsused
  27. void main(int argc, char *argv[])
  28. {
  29.     SoundBlaster sb;
  30.  
  31.     cout << "Playing sample" << endl;
  32.  
  33.     sb.Init_Voice_DMA();   // Use default interrupt handler
  34.  
  35.     SB_SoundFile test1("Organ", "test1.wav");
  36.     SB_SoundFile test2("Hit", "test2.wav");
  37.     SB_SoundFile test3("Brass", "test3.wav");
  38.     SB_SoundFile test4("Music", "test4.wav");
  39.  
  40.     SndPlaySnd(sb, *SB_SoundFile::Find("Organ"));
  41.     SndPlaySnd(sb, *SB_SoundFile::Find("Hit"));
  42.     SndPlaySnd(sb, *SB_SoundFile::Find("Music"));
  43.     SndPlaySnd(sb, *SB_SoundFile::Find("Brass"));
  44.     SndPlaySnd(sb, *SB_SoundFile::Find("Organ"));
  45.     SndPlaySnd(sb, *SB_SoundFile::Find("Brass"));
  46.     SndPlaySnd(sb, *SB_SoundFile::Find("Music"));
  47.  
  48.     sb.DeInit_Voice_DMA();
  49.  
  50.     cout << "Done." << endl;
  51. }
  52.