home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / sphinx / examples / gus / gus.c__ < prev    next >
Encoding:
Text File  |  1994-02-08  |  2.4 KB  |  93 lines

  1. /*
  2.     NAME:  GUS.C--
  3.     DESCRIPTION:  This program demonstates the some of C-- procedures that
  4.                   take advantange of the YEA_GUS driver to play 8 and 16 bit
  5.                   sound samples on the Gravis Ultra Sound.  By the way, I
  6.                   think the GUS is a very good card for its price, so if you
  7.                   need a sound card, get one.
  8.     WARNING:  This program must be spawned by the YEA_GUS driver.
  9.  
  10.               To run from the DOS prompt, type:
  11.  
  12.                        YEA_GUS GUS GUS.COM
  13.  
  14.               To run from the Work Bench, set the Run File to:
  15.  
  16.                        YEA_GUS.EXE
  17.  
  18.               and set the Run Parameters to:
  19.  
  20.                        GUS GUS.COM
  21.  
  22.     The YEA_GUS driver is not restricted to C--, and can be called from any
  23.     language that supports interrupt calls.  The person who wrote it was nice
  24.     enough to make it free for all human use.  Run YEA_GUS.EXE with no
  25.     parameters to find out more about it.  If anyone finds a more resent
  26.     version of YEA_GUS.EXE tell me, I might need it.
  27. */
  28.  
  29.  
  30. ?include "WRITE.H--"
  31. ?include "KEYCODES.H--"
  32. ?include "GUS.H--"
  33.  
  34. byte sound[40000] = FROM "DOITNOW.SND";  // the 8 bit sound sample
  35.  
  36.  
  37. ?define ACTIVE_VOICES  14
  38.  
  39. void main ()
  40. word dram;
  41. {
  42. GUSRESET(ACTIVE_VOICES);
  43. GUSload(GUS_2_COMP, GUS_8_BIT,40000, DS,#sound, 0,0);
  44.  
  45. doit();
  46.  
  47. GUSrampvolume(1,GUS_LOOP_NONE,500,0,0,4000);
  48. do {
  49.     } while( GUSGETVOLUME(1) > 64000 ); // wait till volume is reasonably low
  50. }
  51.  
  52.  
  53. void doit ()
  54. word key;
  55. word voice;
  56. {
  57. WRITESTR("\nPress <1> through <5> to start a voice playing.\n");
  58. WRITESTR("Press <ESC> to quit.\n\n");
  59. voice = 0;
  60. do {
  61.     key = BIOSREADKEY();
  62.     IF( key == k_1 )
  63.         startup_voice(voice,44100);
  64.     ELSE IF( key == k_2 )
  65.         startup_voice(voice,35000);
  66.     ELSE IF( key == k_3 )
  67.         startup_voice(voice,30000);
  68.     ELSE IF( key == k_4 )
  69.         startup_voice(voice,25000);
  70.     ELSE IF( key == k_5 )
  71.         startup_voice(voice,20000);
  72.     voice++;
  73.     IF( voice >= ACTIVE_VOICES )
  74.         voice = 0;
  75.     } while(key != k_esc );
  76. }
  77.  
  78.  
  79. void startup_voice (word voice,frequency)
  80. {
  81. WRITESTR("STARTING voice:");
  82. WRITEWORD(voice);
  83. WRITESTR("  freq:");
  84. WRITEWORD(frequency);
  85. WRITELN();
  86. GUSsetvolume(voice,300);
  87. GUSsetfrequency(voice,frequency);
  88. GUSsetbalance(voice,7);
  89. GUSplay(voice, GUS_8_BIT,GUS_LOOP_NONE, 0,1, 0,1, 0,33465);
  90. }
  91.  
  92.  
  93. /* end of GUS.C-- */