/*   APRIL 2 1991 midnight  *   */ 
/*  chaosky_c 
       music ?  see Algorithm March 1991 p.10 
**  */ 

#include <stdio_h> 

int i, j, t[3], x[3], fr[3], fs[3], a[3], p[46];  
char str[16];  
main()   { 

   *x = atof("2");  
   printf("x = %s\n",ftoa(x,str));  
   printf("value for a ?\n");  
   gets(str);  
   *a = atof(str);  
   printf("a = %s\n",ftoa(a,str));  
   *fr = float(4);  
   *fs = float(46);  
   loadpitc();  
   printf("any key to begin\n");  
   getchar();  
   for( i= 0; i<200; i++)  { 
       *t = fsub(a,x);  
       *t = fmult(t,x);  
       fmove(x,t);  
       printf("i = %4u  x = %10s  ",i,ftoa(x,str));  
       *t = fmult(x,fs);  
       *t = fdiv(t,fr);  
       *t = fmult(t,x);  
       *t = fdiv(t,fr);  
       j = int(t);  
       printf("j = %2u , p[45-j] = %3u \n",j,p[45-j]);  
       beep(420*(45-j),p[45-j]);  
   } 
} 

loadpitc()  { 
   p[0] = 165;  
   p[1] = 153;  
   p[2] = 143;  
   p[3] = 134;  
   p[4] = 127;  
   p[5] = 119;  
   p[6] = 110;  
   p[7] = 104;  
   p[8] = 97;  
   p[9] = 91;  
   p[10] = 86;  
   p[11] = 81;  
   p[12] = 77;  
   p[13] = 72;  
   p[14] = 67;  
   p[15] = 62;  
   p[16] = 58;  
   p[17] = 54;  
   p[18] = 51;  
   p[19] = 47;  
   p[20] = 44;  
   p[21] = 41;  
   p[22] = 38;  
   p[23] = 35;  
   p[24] = 32;  
   p[25] = 30;  
   p[26] = 28;  
   p[27] = 26;  
   p[28] = 24;  
   p[29] = 22;  
   p[30] = 20;  
   p[31] = 18;  
   p[32] = 17;  
   p[33] = 15;  
   p[34] = 14;  
   p[35] = 12;  
   p[36] = 11;  
   p[37] = 10;  
   p[38] = 9;  
   p[39] = 8;  
   p[40] = 7;  
   p[41] = 6;  
   p[42] = 5;  
   p[43] = 4;  
   p[44] = 3;  
   p[45] = 2;  
}
 
