Category : C Source Code
Archive   : SUPER_C.ZIP
Filename : NOISE.C

 
Output of file : NOISE.C contained in archive : SUPER_C.ZIP
/* Noise Maker Main Program
*/

#define FALSE 0
#define TRUE 1

/* main()

Function: Produce sound-effect. Repeatedly ask the user what
sound to make, and then make it.

Algorithm: Loop, asking the user for which sound and how many
times to make it. Then repeat the sound generation code the
number of times requested. To generate the sound, switch on the
type of sound to generate. Each sound is generated by sweeping
through a set of frequencies in a particular order at a particular
rate.
*/

main()

{
int snd; /* Which sound to produce. */
int cnt; /* Number of times to repeat sound. */
int note; /* Current note, when sweeping frequencies. */

while (TRUE) {
/* Make sure any previous sounds are turned off. */
sndOff();
/* Ask the user for which type of sound. */
printf("1-siren; 2-overload; 3-whoop; 4-phaser; 0-exit: ");
/* Read the answer. */
scanf("%d",&snd);
/* If the answer is to exit, do so. */
if (snd == 0) break;
/* Ask how many times to repeat the sound. */
printf("Number of times: ");
/* Get the answer. */
scanf("%d",&cnt);
/* Repeat the sound the number of time specified. */
while (cnt--) {
/* Switch 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(200);
};
/* Sweep down. */
for (; note < 1000; note += 10) {
sound(note); delay(200);
};
break;
case 2:
/* Do an overload: sweep up. */
for (note = 4000; note > 10;
note -= 10) {
sound(note); delay(700);
};
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 again. */
printf("Invalid entry; try again.\n");
break;
};
};
};
}

/* delay(cnt)

Function: Delay for an amount of time proportional to cnt.

Algorithm: Just waste time in a for loop.
*/

delay(cnt)

{
int i;

/* Loop to burn time... */
for (i = 0; i < cnt; i++);
}



  3 Responses to “Category : C Source Code
Archive   : SUPER_C.ZIP
Filename : NOISE.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/