home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / 06user / sweep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  539 b   |  34 lines

  1. /*
  2.  *    sweep -- produce a sound that sweeps from
  3.  *    a low to a high frequency repeatedly until a
  4.  *    key is pressed
  5.  */
  6.  
  7. #include <conio.h>
  8. #include <local\sound.h>
  9.  
  10. main()
  11. {
  12.     unsigned int f;
  13.     int d, n;
  14.     extern void setfreq(unsigned int);
  15.  
  16.     SPKR_ON;
  17.     while (1) {
  18.         /* give user a way out */
  19.         if (kbhit())
  20.             break;
  21.         n = 10;
  22.         for (f = 100; f <= 5000; f += n) {
  23.             setfreq(f);
  24.             d = 1000;
  25.             /* fake a short delay (machine dependednt) */
  26.             while (d-- > 0)
  27.                 ;
  28.             n += 10;
  29.         }
  30.     }
  31.     SPKR_OFF;
  32.     exit(0);
  33. }
  34.