home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / ARPEGG.ZIP / ARPEGG.C next >
C/C++ Source or Header  |  1988-03-06  |  1KB  |  54 lines

  1. #include <doscalls.h>
  2. #include <math.h>
  3.  
  4. int notetime = 50;
  5. long resttime = 20l;
  6. double start = 100.0,stop = 3200.0,freq;
  7.  
  8. main()
  9. {
  10.     double hstep,tonic;
  11.  
  12.     printf("Audible Multitasking Indicator: ARPEGGIO \n");
  13.     printf("Copyright (c) 1987, PC TECH JOURNAL ");
  14.     printf("and Ziff Communications Co.\n");
  15.     printf("  Written by Ted Mirecki \n\n");
  16.  
  17.         /* half-step frequency ratio = twelfth root of two) */
  18.  
  19.     hstep = pow(2.0,(double)(1.0/12.0));
  20.     while(1)
  21.     {
  22.         for(tonic=start;tonic <= stop; tonic *= 2.0)
  23.         {
  24.             freq = tonic;
  25.             note();
  26.             freq *= hstep* hstep * hstep * hstep;
  27.             note();
  28.             freq *= hstep * hstep * hstep;
  29.             note();
  30.         }
  31.         for(;tonic > start; tonic /= 2.0)
  32.         {
  33.             freq = tonic;
  34.             note();
  35.             freq /= hstep * hstep * hstep;
  36.             note();
  37.             freq /= hstep * hstep * hstep * hstep;
  38.             note();
  39.         }
  40.     }
  41. }
  42.  
  43.         /* Isolate OS calls in separate function */
  44.  
  45. note()
  46. {
  47.     int ihertz;
  48.  
  49.     ihertz = (int)(freq + 0.5);
  50.     DOSBEEP(ihertz,notetime);
  51.     DOSSLEEP(resttime);
  52. }
  53.  
  54.