home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / c / dmkit / flat / test16.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-03  |  3.5 KB  |  135 lines

  1. /*** TEST16.C                  Demonstrate all DIGPAK capable play modes.      ***/
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <malloc.h>
  5.  
  6. #include "loader.h"
  7. #include "support.h"
  8. #include "digplay.h"    // Include DIGPLAY header.
  9. #include "doscalls.h"   // Include DOS tools header.
  10. #include "t16.h"
  11.  
  12. void main(void)
  13. {
  14.     int cap;
  15.     SNDSTRUC *snd;
  16.     long int siz;
  17.     char *sound;
  18.     char *workspace;
  19.  
  20.     if ( !LoadDigPak("SOUNDRV.COM") )
  21.     {
  22.         printf("Unable to load SOUNDRV.COM\n");
  23.         exit(1);
  24.     }
  25.     if ( !InitDigPak() )
  26.     {
  27.         UnLoadDigPak();
  28.         printf("Unable to initialize digitized sound hardware.\n");
  29.         exit(1);
  30.     }
  31.  
  32.     snd = realalloc(sizeof(SNDSTRUC));
  33.  
  34.     sound = floadlow("TEST.SND", &siz);
  35.     if ( sound )
  36.     {
  37.         cap = AudioCapabilities();
  38.         workspace = realalloc(64000); //allocate lots of memory for workspace.
  39.         if ( siz*4 > 64000L ) siz = 64000/4;
  40.         printf("Press a key to play test sound effect in 8 bit mono mode.\n");
  41.         printf("Press ESC to go to next step in the test suite.\n");
  42.  
  43.         memorymove(workspace,sound,siz);
  44.         snd->sound = RealPtr(workspace);
  45.         snd->frequency = 11000;
  46.         snd->sndlen = siz;
  47.         MassageAudio(snd);
  48.  
  49.         do
  50.         {
  51.             DigPlay2(snd);
  52.         } while ( getkey() != 27 );
  53.         if ( cap & STEREOPLAY )
  54.         {
  55.             printf("Press a key to play test sound effect in 8 bit stereo mode.\n");
  56.             printf("JUST out of the LEFT speaker.\n");
  57.             printf("Press ESC to go to next step in the test suite.\n");
  58.             Left8(sound,workspace,siz);
  59.             snd->sound = RealPtr(workspace);
  60.             snd->frequency = 11000;
  61.             snd->sndlen = siz*2;
  62.  
  63.             SetPlayMode(PCM_8_STEREO);
  64.             MassageAudio(snd);
  65.             do
  66.             {
  67.                 DigPlay2(snd);
  68.             } while ( getkey() != 27 );
  69.  
  70.             printf("Press a key to play test sound effect in 8 bit stereo mode.\n");
  71.             printf("JUST out of the RIGHT speaker.\n");
  72.             printf("Press ESC to go to next step in the test suite.\n");
  73.             Right8(sound,workspace,siz);
  74.             snd->sound = RealPtr(workspace);
  75.             snd->frequency = 11000;
  76.             snd->sndlen = siz*2;
  77.             SetPlayMode(PCM_8_STEREO);
  78.             MassageAudio(snd);
  79.             do
  80.             {
  81.                 DigPlay2(snd);
  82.             } while ( getkey() != 27 );
  83.         }
  84.         if ( cap&PCM16 )
  85.         {
  86.             printf("Press a key to play test sound effect in 16 bit MONO mode.\n");
  87.             printf("Press ESC to go to next step in the test suite.\n");
  88.             Mono16(sound,workspace,siz);
  89.             snd->sound = RealPtr(workspace);
  90.             snd->frequency = 11000;
  91.             snd->sndlen = siz*2;
  92.             SetPlayMode(PCM_16_MONO);
  93.             do
  94.             {
  95.                 DigPlay2(snd);
  96.             } while ( getkey() != 27 );
  97.         }
  98.  
  99.  
  100.         if ( cap&PCM16STEREO )
  101.         {
  102.             printf("Press a key to play test sound effect in 16 bit STEREO mode.\n");
  103.             printf("Will play 16 bit sound effect, just out of LEFT channel.\n");
  104.             printf("Press ESC to go to next step in the test suite.\n");
  105.             Left16(sound,workspace,siz);
  106.             snd->sound = RealPtr(workspace);
  107.             snd->frequency = 11000;
  108.             snd->sndlen = siz*4;
  109.             SetPlayMode(PCM_16_STEREO);
  110.             do
  111.             {
  112.                 DigPlay2(snd);
  113.             } while ( getkey() != 27 );
  114.  
  115.             printf("Press a key to play test sound effect in 16 bit STEREO mode.\n");
  116.             printf("Will play 16 bit sound effect, just out of RIGHT channel.\n");
  117.             printf("Press ESC to go to next step in the test suite.\n");
  118.             Right16(sound,workspace,siz);
  119.             snd->sound = RealPtr(workspace);
  120.             snd->frequency = 11000;
  121.             snd->sndlen = siz*4;
  122.             SetPlayMode(PCM_16_STEREO);
  123.             do
  124.             {
  125.                 DigPlay2(snd);
  126.             } while ( getkey() != 27 );
  127.         }
  128.         SetPlayMode(PCM_8_MONO);
  129.     }
  130.     else
  131.         printf("Unable to load test sound effect 'TEST.SND'.\n");
  132.  
  133.     UnLoadDigPak();
  134. }
  135.