⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sound.c

📁 这是用C语言编写的声音算法
💻 C
字号:
#define FALSE 0
#define TRUE 1
#include<dos.h>
main()
{
int snd;    /*  which sound to produce  */
int cnt;    /* number of times to repeat sound */
int note;   /* Current note, when sweeping frequencies  */
while (TRUE) {
/* Male Sure any previous sounds ave turned off.  */
   nosound();
/* Ask the user for which type of sounf*/
printf ("1-siren;2-overload;3-whoop;4-phaser; 0-exit");
/* read the answer */
   scanf ("%d",&snd);
/* if the  answer it to exit ,do so. */
   if (snd==0)
   break;
/* Ask how many times to repast the sound. */
printf ("Nunger of times:");
/* get the answer */
scanf("%d",&cnt);
/* repeat the sound the number of time specifed */
while(cnt--){
/* swich on type of sound to produce*/
switch (snd)
{case 1:
  /* do a siren:sweep up */
for (note=1000;note>150;note-=10)
{
sound(note);
delay(20);
}
/* Sweep down */
for (;note<1000;note+=10)
{
sound(note);
  delay(20);
}
break;
case 2:  /* do an overload. sweep up */
		for (note=4000;note>10;note-=10)
{
sound(note);
delay(70);
}
break;
case 3:
	   /* do a whoop: Sweep up*/
	   for (note=1000;note>10;note-=10)
		 {
		 sound (note);
delay (200);
}
break;
case 4:
	  /* do a phaser: sweep down */
	  for (note=60; note<2000;note+=10 )
{
sound (note);
delay(100);
}
break;
default:
		   /* unknown,ask a gain */
		   printf ( "Invalid entry;try again \n");
		   break;
}
}
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -