|
#include <conio.h>
#include <dos.h>
#include <stdio.h>
#include <bios.h>
#include <stdlib.h>
#include <time.h>
main()
{
int handle,key,intrpt,freq;
textmode(C40);
textattr(10);
cprintf("This programm
produces a random stream\r\nof bits and play it.\r\nTo change frequency
use UP and DOWN\r\narrows.\r\nTo set a delay between the
generating\r\nbits use RIGHT and LEFT arrows.\r\n\nPress any key to
start.\r\n\n");
getch();
cprintf("Initializing
generator of random\r\ndigits...");
randomize();
cprintf("DONE\n\n\r\aSetting
values of variables...\r\n");
key=1;
intrpt=0;
freq=1000;
cprintf("delay=%dms\r\nfrequency=%dHz\r\nDONE\r\n\n\agenerating
bits>>>\r\n\nPress ESC to stop>>>\r\n\nStatus: in progress...\r\n",intrpt,freq);
while (key!=283)
//повторять
до нажатия ESC
{
if (bioskey(1)!=0)
{
key=bioskey(0);
switch (key)
//изменение
звука
{
case 18432: freq+=100;
//изменение частоты
cprintf("\r
\rfrequency set to %d Hz",freq);
break;
case 20480: if (freq>=100)
freq-=100;
cprintf("\r
\rfrequency set to %d Hz",freq);
break;
case 19712:
intrpt+=1;
//изменение задержки
cprintf("\r
\rdelay set to %d ms",intrpt);
break;
case 19200: if (intrpt>=1)
intrpt-=1;
cprintf("\r
\rdelay set to %d ms",intrpt);
break;
case 283:
cprintf("\r \rEXIT\a");
//выход
break;
default: cprintf("\nWrong
entry");
}
}
handle=random(2);
if (handle==0)
//не
писщать
{
nosound();
delay(intrpt);
//cprintf("0");
}
if (handle!=0)
//писщать
{
sound(freq);
delay(intrpt);
//cprintf("1");
}
}
nosound();
return 1;
} |