/*SIDDHESH DEODHAR*/
/*siddhesh.deodhar@gmail.com*/
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
void simple(void);
void complex(void);
void play(void);
void main()
{
char m;
textcolor(RED);
textbackground(WHITE);
while(1)
{
clrscr();
printf(" MUSICMANTRA nn");
cprintf(" ");
printf("YOU CAN DO THIS");
cprintf(" ");
printf("nn JUST PLAY---------------------pn");
printf("n PLAY COMPOSE AND SAVE---------on");
printf("n OPEN & PLAY EXISTING FILE-----in");
printf("n EXIT--------------------------enn");
cprintf(" ");
m=getch();
switch(m)
{
case 'p':
{
simple();
break;
}
case 'o':
{
complex();
break;
}
case 'i':
{
play();
break;
}
case 'e':
{
exit(0);
}
default :
{
printf("ABE GADHE PADHNA NAHI AATA KYA ,BARABAR CHOICE DALL");
break;
}
}
}
}
void simple()
{
int i,d,t,w;
char c;
clrscr();
textcolor(4);
textbackground(6);
printf("n");
printf("n1)PRESS Tab TO <- TO PLAY IN UPPER TUNE MODE nn");
printf(" & 1 TO <- FOR LOWER TUNE MODE n");
printf("n2)PRESS a TO QUIT nn");
printf("3)Enter the delay nn");
printf("---->Enter 1 or 2 for piano modenn");
printf("---->Enter between 3 to 8 to generate melodiesnnn");
cprintf("4)WARNING--- dont enter delay above 10nn");
printf("");
scanf("%d",&d);
do
{
c=getche();
i=(int)c;
switch(i)
{
case 9:
{
sound(174.61);
delay(100*d);
nosound();
break;
}
case 113:
{
sound(196);
delay(100*d);
nosound();
break;
}
case 119:
{
sound(220);
delay(200);
nosound();
break;
}
case 101:
{
sound(246.94);
delay(100*d);
nosound();
break;
}
case 114:
{
sound(261.63);
delay(100*d);
nosound();
break;
}
case 116:
{
sound(293.66);
delay(100*d);
nosound();
break;
}
case 121:
{
sound(329.63);
delay(100*d);
nosound();
break;
}
case 117:
{
sound(349.23);
delay(100*d);
nosound();
break;
}
case 105:
{
sound(392);
delay(100*d);
nosound();
break;
}
case 111:
{
sound(440);
delay(100*d);
nosound();
break;
}
case 112:
{
sound(493.88);
delay(100*d);
nosound();
break;
}
case 91:
{
sound(523.25);
delay(100*d);
nosound();
break;
}
case 93:
{
sound(589.33);
delay(100*d);
nosound();
break;
}
case 8:
{
sound(651.25);
delay(100*d);
nosound();
break;
}
case 49:
{
sound(185);
delay(100*d);
nosound();
break;
}
case 50:
{
sound(207.65);
delay(100*d);
nosound();
break;
}
case 51:
{
sound(233);
delay(100*d);
nosound();
break;
}
case 53:
{
sound(277.18);
delay(100*d);
nosound();
break;
}
case 54:
{
sound(311.13);
delay(100*d);
nosound();
break;
}
case 56:
{
sound(370);
delay(100*d);
nosound();
break;
}
case 57:
{
sound(415.30);
delay(100*d);
nosound();
break;
}
case 48:
{
sound(466.16);
delay(100*d);
nosound();
break;
}
case 61:
{
sound(554.37);
delay(100*d);
nosound();
break;
}
case 92:
{
sound(622.25);
delay(100*d);
nosound();
break;
}
}
}
while(i!=97);
}
void complex()
{
char name[10];
FILE *fp;
char c,s[4];
int j=0,m;
int i,d,t,w,flag=0;
printf("nENTER THE DELAY TO PLAY THE TUNE BETWEEN 1-10n ");
scanf("%d",&d);
printf("n ENTER THE FILE NAME THAT U WANT TO CREATE TO SAVE UR TUNE n");
printf("n TO SAVE AND QUIT TYPE ----> BAND n");
gets(name);
fp=fopen(name,"w");
do
{
c=getche();
i=(int)c;
switch(i)
{
case 9:
{
sound(174.61);
delay(100*d);
nosound();
break;
}
case 113:
{
sound(196);
delay(100*d);
nosound();
break;
}
case 119:
{
sound(220);
delay(200);
nosound();
break;
}
case 101:
{
sound(246.94);
delay(100*d);
nosound();
break;
}
case 114:
{
sound(261.63);
delay(100*d);
nosound();
break;
}
case 116:
{
sound(293.66);
delay(100*d);
nosound();
break;
}
case 121:
{
sound(329.63);
delay(100*d);
nosound();
break;
}
case 117:
{
sound(349.23);
delay(100*d);
nosound();
break;
}
case 105:
{
sound(392);
delay(100*d);
nosound();
break;
}
case 111:
{
sound(440);
delay(100*d);
nosound();
break;
}
case 112:
{
sound(493.88);
delay(100*d);
nosound();
break;
}
case 91:
{
sound(523.25);
delay(100*d);
nosound();
break;
}
case 93:
{
sound(589.33);
delay(100*d);
nosound();
break;
}
case 8:
{
sound(651.25);
delay(100*d);
nosound();
break;
}
case 49:
{
sound(185);
delay(100*d);
nosound();
break;
}
case 50:
{
sound(207.65);
delay(100*d);
nosound();
break;
}
case 51:
{
sound(233);
delay(100*d);
nosound();
break;
}
case 53:
{
sound(277.18);
delay(100*d);
nosound();
break;
}
case 54:
{
sound(311.13);
delay(100*d);
nosound();
break;
}
case 56:
{
sound(370);
delay(100*d);
nosound();
break;
}
case 57:
{
sound(415.30);
delay(100*d);
nosound();
break;
}
case 48:
{
sound(466.16);
delay(100*d);
nosound();
break;
}
case 61:
{
sound(554.37);
delay(100*d);
nosound();
break;
}
case 92:
{
sound(622.25);
delay(100*d);
nosound();
break;
}
}
for(j=1;j<=3;j++)
{
s[j-1]=s[j];
}
s[3]=c;
if((s[0]=='b')&&(s[1]=='a')&&(s[2]=='n')&&(s[3]=='d'))
{
flag=1;
}
fputc(c,fp);
}
while(flag==0);
fclose(fp);
}
void play()
{
FILE *fp;
char c,nav[8];
int j,m;
int i,d,t,w;
printf("n ENTER THE NAME OF THE FILE THAT U WANT TO OPEN n");
gets(nav);
fp=fopen(nav,"r");
printf("ENTER THE DELAY AT ? U WANT TP PLAY THE TUNE FRM THE FILE BETWEEN 1 TO 10 n");
scanf("%d",&d);
do
{
c=fgetc(fp);
i=(int)c;
switch(i)
{
case 9:
{
sound(174.61);
delay(100*d);
nosound();
break;
}
case 113:
{
sound(196);
delay(100*d);
nosound();
break;
}
case 119:
{
sound(220);
delay(200);
nosound();
break;
}
case 101:
{
sound(246.94);
delay(100*d);
nosound();
break;
}
case 114:
{
sound(261.63);
delay(100*d);
nosound();
break;
}
case 116:
{
sound(293.66);
delay(100*d);
nosound();
break;
}
case 121:
{
sound(329.63);
delay(100*d);
nosound();
break;
}
case 117:
{
sound(349.23);
delay(100*d);
nosound();
break;
}
case 105:
{
sound(392);
delay(100*d);
nosound();
break;
}
case 111:
{
sound(440);
delay(100*d);
nosound();
break;
}
case 112:
{
sound(493.88);
delay(100*d);
nosound();
break;
}
case 91:
{
sound(523.25);
delay(100*d);
nosound();
break;
}
case 93:
{
sound(589.33);
delay(100*d);
nosound();
break;
}
case 8:
{
sound(651.25);
delay(100*d);
nosound();
break;
}
case 49:
{
sound(185);
delay(100*d);
nosound();
break;
}
case 50:
{
sound(207.65);
delay(100*d);
nosound();
break;
}
case 51:
{
sound(233);
delay(100*d);
nosound();
break;
}
case 53:
{
sound(277.18);
delay(100*d);
nosound();
break;
}
case 54:
{
sound(311.13);
delay(100*d);
nosound();
break;
}
case 56:
{
sound(370);
delay(100*d);
nosound();
break;
}
case 57:
{
sound(415.30);
delay(100*d);
nosound();
break;
}
case 48:
{
sound(466.16);
delay(100*d);
nosound();
break;
}
case 61:
{
sound(554.37);
delay(100*d);
nosound();
break;
}
case 92:
{
sound(622.25);
delay(100*d);
nosound();
break;
}
}
}
while(!feof(fp));
fclose(fp);
}