home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
C
/
SOUNDSYS
/
SOUNDS.C
next >
Wrap
Text File
|
1989-04-09
|
2KB
|
137 lines
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
#include <dos.h>
#include "sounds.h"
#include "soundsys.h"
#include "keyboard.h"
void GunSound(void)
{
int i,j;
for (j=0;j<5;j++)
for (i=40; i>=10; i--)
{
submit_sound((i*10),0);
submit_sound(0,0);
}
}
void ExplSound(void)
{
explode(400,300,0);
}
void explode(int freq, int iterations,int delayfactor)
{
int i;
for (i=1; i<iterations; i++)
{
submit_sound(random(freq),(delayfactor*5));
submit_sound(random(freq),(delayfactor*5));
}
}
int between(int low, int high)
{
if (high > low)
return (random(high - low + 1) + high);
else
{
if (high == low)
return high;
else
return (random(low-high+1) + 1);
}
}
void siren(int i, int j, int k)
{
while (i != j)
{
submit_sound(i,k);
if (i>j)
i-=5;
else
i+=5;
}
}
void whine(void)
{
int i,ii;
for (i=1; i<=8; i++)
{
ii = 100*i;
siren(1000-ii,1100-ii,1);
siren(1100-ii,900-ii,1);
}
nosound();
}
void fallsound(void)
{
siren(2000,500,1);
explode(400,200,0);
}
void DropSound(void)
{
siren(2000,500,1);
}
void JetEngineStart(void)
{
siren(40,5000,3);
submit_sound(5000,1000);
}
void JetEngineOff(void)
{
siren(5000,40,4);
}
void main(void)
{
int i;
clrscr();
printf("Background Sound System Demo - by J.Jimenez\n\n");
init_sound();
printf("Background noise on...\n");
frequency = 40;
back_sound = ON;
sleep(5);
printf("Explosion...\n");
ExplSound();
sleep(5);
printf("Machine Gun...\n");
for (i=0;i<3;i++) GunSound();
sleep(5);
printf("Whine??\n");
whine();
sleep(5);
printf("Drop bomb...\n");
DropSound();
sleep(5);
printf("Drop bomb w/explosion...\n");
fallsound();
sleep(5);
printf("Jet engine start...\n");
JetEngineStart();
sleep(10);
printf("Jet engine shutdown...\n");
JetEngineOff();
sleep(10);
printf("Background noise off...\n");
back_sound = OFF;
sleep(2);
printf("Done!\n");
restore_sound();
exit(0);
}