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 >
Wrap
C/C++ Source or Header
|
1992-07-16
|
5KB
|
149 lines
/* === NM-Timbre.c ===
*
* void Timbre()
*
*/
#include "NM.h"
void Timbre()
{
int i,k,p,sign,x,y;
more *WITH;
char STR1[256],Old_Name[13];
if ((timfile=fopen("Dir_Song/IM.tim","r"))==NULL)
{
for (i=0;i<100;i++)
{
tim[i]=(more *)malloc(sizeof(more));WITH=tim[i];*WITH->tool='\0';
for (j=0;j<20;j++) WITH->freq[j]=0;
}
Timbre_num=100;
}
_LA:Rub(0,0,1139,862,"MediumBlue");SetColor("green");x=138;Use_Font("12x24");
OutTextXY(500,50,"--- Timbre ---");SetColor("white");
DrawRectangle(100,155,1023,550);Rub(102,157,1020,547,"NavyBlue");
SetColor("gold");OutTextXY(16,126,"Height=");
OutTextXY(470,126,"No.(1..100)=");OutTextXY(30,739,"NF =");
for (i=1;i<=20;i++) Out_I_XY(i*50+79,739,i);sign=0;SetColor("white");
OutTextXY(80,840,"Esc--exit Return--Save four arrows--up down left right Home--fill A...Z--sound");
readat(620,126,3,&k);
if (k<1 || k>Timbre_num)
{
k=1;Rub(620,102,500,27,"MediumBlue");SetColor("magenta");
OutTextXY(620,126,"1");
}
SetColor("gold");OutTextXY(875,126,"Name=");SetColor("green");
_LB:
if (sign==0)
{
i=0;*Old_Name=*tim[k-1]->tool;*tim[k-1]->tool='\0';sign=1;
do {
ch=GetKey();
if (isalpha(ch))
{
sprintf(STR1,"%c",ch);OutTextXY(i*15+940,126,STR1);
i++;*tim[k-1]->tool=*strcat(tim[k-1]->tool,STR1);
}
} while (ch != '!' && i != 12);
if (i==0) { *tim[k-1]->tool=*Old_Name;OutTextXY(940,126,tim[k-1]->tool); }
tim_pt=*tim[k-1];
}
else
{
tim_pt=*tim[k-1];
Rub(116,102,100,27,"MediumBlue");SetColor("white");
Out_I_XY(116,126,tim[k-1]->freq[(x-138)/50]);
Rub(620,102,60,27,"MediumBlue");SetColor("magenta");Out_I_XY(620,126,k);
Rub(940,102,184,27,"MediumBlue");SetColor("green");
OutTextXY(940,126,tim[k-1]->tool);
}
Rub(102,157,1020,547,"NavyBlue");
for (i=0;i<20;i++)
{
if (tim_pt.freq[i]>0)
Rub(i*50+126,207+496-tim_pt.freq[i],25,tim_pt.freq[i],"LimeGreen");
}
y=671-tim_pt.freq[0];Rub(109,105,50,22,"MediumBlue");
SetColor("green");Out_I_XY(116,126,tim_pt.freq[0]);Cat(&x,&y,0,0,"NavyBlue");
do {
ch=GetKey();
if (ch=='?'||ch=='@'||ch=='#'||ch=='<'||ch=='>'||ch=='$'||ch=='^')
{
switch (ch)
{
case '?':if (y>184) /* Up */
{
Cat(&x,&y,0,-16,"NavyBlue");
Rub(x-12,y+30,25,18,"LimeGreen");
tim_pt.freq[(x-138)/50]=671-y;
}
break;
case '@':if (y<671) /* Down */
{
Rub(x-12,y+30,25,18,"NavyBlue");
Cat(&x,&y,0,16,"NavyBlue");
tim_pt.freq[(x-138)/50]=671-y;
}
break;
case '#':if (y<412) /* Home */
{
Rub(x-12,170,25,533,"NavyBlue");
Cat(&x,&y,0,671-y,"NavyBlue");
tim_pt.freq[(x-138)/50]=0;
}
else
{
Cat(&x,&y,0,175-y,"NavyBlue");
Rub(x-12,205,25,498,"LimeGreen");
tim_pt.freq[(x-138)/50]=496;
}
break;
case '<':if (x>140) /* Left */
Cat(&x,&y,-50,671-tim_pt.freq[(x-138)/50-1]-y,
"NavyBlue");
else Cat(&x,&y,1089-x,671-y-tim_pt.freq[19],"NavyBlue");
break;
case '>':if (x<1080) /* Right */
Cat(&x,&y,50,671-tim_pt.freq[(x-138)/50+1]-y,
"NavyBlue");
else Cat(&x,&y,138-x,671-y-tim_pt.freq[0],"NavyBlue");
break;
case '$':if (k>1) k--;else k=Timbre_num-1;goto _LB; /* Pgup */
break;
case '^':if (k<Timbre_num-1) k++;else k=1;goto _LB; /* Pgdown */
break;
}/*case*/
Rub(109,105,50,22,"MediumBlue");SetColor("green");
Out_I_XY(116,126,tim_pt.freq[(x-138)/50]);
}
else switch (ch)
{
case ' ':for (ch='F';ch<='N';ch++)
{
p=ch-'A';d=freq;for (i=1;i<=p;i++) d*=1.0594631;
Mixup();
/* for (j=1;j<=40;j++)
{ sound((int)floor(d*mix[j-1]+0.5));delay(3); }
nosound(); */
}
break;
default:if (isalpha(ch))
{
p=toupper(ch)-'A';d=freq;
for (i=1;i<= p;i++)d *=1.0594631;Mixup();
/* for (j=1;j<=40;j++)
{ sound((int)floor(d*mix[j-1]+0.5));delay(3); }
nosound(); */
}
break;
}
} while (ch != '&' && ch != '!');
if (ch != '!') return;*tim[k-1]=tim_pt;
timfile=fopen("Dir_Song/IM.tim","w");
if (timfile!=NULL) rewind(timfile);else timfile=tmpfile();
for (p=0;p<100;p++) fwrite(tim[p],sizeof(more),1,timfile);
if (timfile != NULL) fclose(timfile);timfile=NULL;goto _LA;
} /*timbre*/