Web Toolbar by Wibiya

Pages

PLEASE,CLICK HERE TO SUPPORT US!! (ChetaN)

Sunday, 9 October 2011

* PLAY SOUND IN C-LANGUAGE


Copy this code. And enjoy how to play sound in C-editor.......

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include<time.h>
#include<dos.h>
void main()
{
clrscr();
printf("HELLO, SA RE GA MA PA DHA NI");
music(5);
getch();
}
music(type)
int type;
{
float oct[7]={130.81,146.83,164.81,174.61,196,220,246.94};
int n,i;
switch(type)
{
case 1:
for(i=0;i<7;i++)
{
n=random(1);
sound(oct[i]*5);
delay(300);
}
nosound();
break;
case 2:
for(i=0;i<7;i++)
{
n=random(7);
sound(oct[i]*4);
delay(200);
}
nosound();
break;
case 3:
for(i=0;i<7;i++)
{
n=random(7);
sound(oct[i]*5);
delay(200);
}
nosound();
break;
case 4:
for(i=0;i<7;i++)
{
n=random(7);
sound(oct[i]*7);
delay(200);
}
nosound();
break;
case 5:
for(i=0;i<7;i++)
{
n=random(7);
sound(oct[i]*10);
delay(200);
}
nosound();
break;
case 6:
for(i=0;i<7;i++)
{
n=random(7);
sound(oct[i]*15);
delay(200);
}
nosound();
break;
case 7:
for(i=0;i<7;i++)
{
n=random(7);
sound(oct[i]*20);
delay(200);
}
nosound();
break;
}
return(0);
}

3 comments: