home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / dir_nm20.zip / Dir_NM_2.0 / NM-Timbre.c < prev    next >
C/C++ Source or Header  |  1992-07-16  |  5KB  |  149 lines

  1. /*                           ===  NM-Timbre.c  ===
  2.  *
  3.  * void Timbre()
  4.  * 
  5.  */
  6.  
  7. #include "NM.h"
  8.  
  9. void Timbre()
  10. {
  11.   int i,k,p,sign,x,y;
  12.   more *WITH;
  13.   char STR1[256],Old_Name[13];
  14.  
  15.   if ((timfile=fopen("Dir_Song/IM.tim","r"))==NULL) 
  16.     {
  17.       for (i=0;i<100;i++) 
  18.     {
  19.       tim[i]=(more *)malloc(sizeof(more));WITH=tim[i];*WITH->tool='\0';
  20.       for (j=0;j<20;j++) WITH->freq[j]=0;
  21.     }
  22.       Timbre_num=100;
  23.     }
  24. _LA:Rub(0,0,1139,862,"MediumBlue");SetColor("green");x=138;Use_Font("12x24");
  25.   OutTextXY(500,50,"--- Timbre ---");SetColor("white");
  26.   DrawRectangle(100,155,1023,550);Rub(102,157,1020,547,"NavyBlue");
  27.   SetColor("gold");OutTextXY(16,126,"Height=");
  28.   OutTextXY(470,126,"No.(1..100)=");OutTextXY(30,739,"NF =");
  29.   for (i=1;i<=20;i++) Out_I_XY(i*50+79,739,i);sign=0;SetColor("white");
  30.   OutTextXY(80,840,"Esc--exit   Return--Save   four arrows--up down left right   Home--fill   A...Z--sound");
  31.   readat(620,126,3,&k);
  32.   if (k<1 || k>Timbre_num)
  33.     { 
  34.       k=1;Rub(620,102,500,27,"MediumBlue");SetColor("magenta");
  35.       OutTextXY(620,126,"1");
  36.     }
  37.   SetColor("gold");OutTextXY(875,126,"Name=");SetColor("green");
  38. _LB:
  39.   if (sign==0) 
  40.     {
  41.       i=0;*Old_Name=*tim[k-1]->tool;*tim[k-1]->tool='\0';sign=1;
  42.       do {
  43.        ch=GetKey();
  44.        if (isalpha(ch)) 
  45.          {
  46.            sprintf(STR1,"%c",ch);OutTextXY(i*15+940,126,STR1);
  47.            i++;*tim[k-1]->tool=*strcat(tim[k-1]->tool,STR1);
  48.          }
  49.      } while (ch != '!' && i != 12);
  50.       if (i==0) { *tim[k-1]->tool=*Old_Name;OutTextXY(940,126,tim[k-1]->tool); }
  51.       tim_pt=*tim[k-1];
  52.     } 
  53.   else 
  54.     {
  55.       tim_pt=*tim[k-1];
  56.       Rub(116,102,100,27,"MediumBlue");SetColor("white");
  57.       Out_I_XY(116,126,tim[k-1]->freq[(x-138)/50]);
  58.       Rub(620,102,60,27,"MediumBlue");SetColor("magenta");Out_I_XY(620,126,k);
  59.       Rub(940,102,184,27,"MediumBlue");SetColor("green");
  60.       OutTextXY(940,126,tim[k-1]->tool);
  61.     }
  62.   Rub(102,157,1020,547,"NavyBlue");
  63.   for (i=0;i<20;i++) 
  64.     { 
  65.       if (tim_pt.freq[i]>0) 
  66.     Rub(i*50+126,207+496-tim_pt.freq[i],25,tim_pt.freq[i],"LimeGreen");
  67.     }
  68.   y=671-tim_pt.freq[0];Rub(109,105,50,22,"MediumBlue");
  69.   SetColor("green");Out_I_XY(116,126,tim_pt.freq[0]);Cat(&x,&y,0,0,"NavyBlue");
  70.   do {
  71.        ch=GetKey();
  72.        if (ch=='?'||ch=='@'||ch=='#'||ch=='<'||ch=='>'||ch=='$'||ch=='^') 
  73.      {
  74.        switch (ch) 
  75.          {
  76.            case '?':if (y>184)      /*  Up  */
  77.                       {
  78.                 Cat(&x,&y,0,-16,"NavyBlue");
  79.                 Rub(x-12,y+30,25,18,"LimeGreen");
  80.                 tim_pt.freq[(x-138)/50]=671-y;
  81.               }
  82.          break;
  83.            case '@':if (y<671)      /* Down */
  84.                   {
  85.                     Rub(x-12,y+30,25,18,"NavyBlue");
  86.                 Cat(&x,&y,0,16,"NavyBlue");
  87.                             tim_pt.freq[(x-138)/50]=671-y;
  88.               }
  89.              break;
  90.            case '#':if (y<412)      /* Home */
  91.                       {
  92.                 Rub(x-12,170,25,533,"NavyBlue");
  93.                 Cat(&x,&y,0,671-y,"NavyBlue");
  94.                 tim_pt.freq[(x-138)/50]=0;
  95.               }
  96.                     else 
  97.               {
  98.                 Cat(&x,&y,0,175-y,"NavyBlue");
  99.                 Rub(x-12,205,25,498,"LimeGreen");
  100.                 tim_pt.freq[(x-138)/50]=496;
  101.               }
  102.              break;
  103.            case '<':if (x>140)      /* Left */
  104.                   Cat(&x,&y,-50,671-tim_pt.freq[(x-138)/50-1]-y,
  105.                   "NavyBlue");
  106.                     else Cat(&x,&y,1089-x,671-y-tim_pt.freq[19],"NavyBlue");
  107.          break;
  108.            case '>':if (x<1080)      /* Right */
  109.                           Cat(&x,&y,50,671-tim_pt.freq[(x-138)/50+1]-y,
  110.                   "NavyBlue");
  111.                     else Cat(&x,&y,138-x,671-y-tim_pt.freq[0],"NavyBlue");
  112.          break;
  113.            case '$':if (k>1) k--;else k=Timbre_num-1;goto _LB;  /* Pgup */
  114.          break;
  115.            case '^':if (k<Timbre_num-1) k++;else k=1;goto _LB;  /* Pgdown */
  116.          break;
  117.          }/*case*/
  118.        Rub(109,105,50,22,"MediumBlue");SetColor("green");
  119.        Out_I_XY(116,126,tim_pt.freq[(x-138)/50]);
  120.      } 
  121.        else  switch (ch) 
  122.            {
  123.              case ' ':for (ch='F';ch<='N';ch++) 
  124.                     {
  125.                   p=ch-'A';d=freq;for (i=1;i<=p;i++) d*=1.0594631;
  126.                   Mixup();
  127.                   /*  for (j=1;j<=40;j++) 
  128.                     { sound((int)floor(d*mix[j-1]+0.5));delay(3); }
  129.                   nosound(); */
  130.                 }
  131.            break;
  132.              default:if (isalpha(ch)) 
  133.                    {
  134.                  p=toupper(ch)-'A';d=freq;
  135.                  for (i=1;i<= p;i++)d *=1.0594631;Mixup();
  136.                 /*   for (j=1;j<=40;j++) 
  137.                    { sound((int)floor(d*mix[j-1]+0.5));delay(3); }
  138.                  nosound(); */
  139.                }
  140.            break;
  141.            }
  142.      } while (ch != '&' && ch != '!');
  143.   if (ch != '!') return;*tim[k-1]=tim_pt;
  144.   timfile=fopen("Dir_Song/IM.tim","w");
  145.   if (timfile!=NULL) rewind(timfile);else timfile=tmpfile();
  146.   for (p=0;p<100;p++) fwrite(tim[p],sizeof(more),1,timfile);
  147.   if (timfile != NULL) fclose(timfile);timfile=NULL;goto _LA;
  148. }  /*timbre*/
  149.