/* beep_vv.c ************* Copyright 1988 by Vermont Creative Software ************** beep_vv() Generates a tone of the specified frequency for the specified duration Call #include void beep_vv(hsec, freq) int hsec; Length of tone in 1/100's of a second int freq; Frequency of tone in hertz hsec: Specify the number of hundredths of a second to sound the beep or one of the following predefined values: BPSHORT 3, signifying .03 second BPMEDIUM 10, signifying .10 second BPLONG 30, signifying .30 second BPBELL Use the operating system bell freq: Specify the number of hertz to sound the beep at or one of the following predefined values: BPLOW 100 Hz BPMIDDLE 500 Hz BPHIGH 1000 Hz BPBELL Use the operating system bell Returns None Description PCDOS and OS/2 Systems: beep_vv() generates a tone using the speaker in the IBM PC/XT/AT or PS/2 of the specified frequency and duration. If either the frequency or length of the tone is specified as BPBELL, the standard bell is sounded. UNIX and VMS Systems: If either (1) the frequency or length of the tone is BPBELL or (2) both the frequency and length are greater than zero, beep_vv() sends the terminal command string to ring the bell. Related Functions bell() Cautions PCDOS Systems: Any beep with the requested duration shorter than 0.05 sec will sound for approximately 0.03 sec, depending on the speed of the machine. */ #include #include #if ISC_UNIX /*----------------------------------------------------------------------------*/ /* Undefine some VV symbols that conflict with symbols defined in at_ansi.h */ /* and kd.h. */ /*----------------------------------------------------------------------------*/ #undef REVERSE #undef BLINK #undef UNDERLINE #undef UP #undef DOWN #undef bell #include #include #include #endif void FASTCALL beep_vv(hsec, freq) int hsec; int freq; { #ifndef NO_DEBUG_CODE UCHAR * fn = (UCHAR *) "beep_vv"; #endif INIT_MODULE(fn); #if ISC_UNIX if (_wnmemmap) { if (hsec == BPBELL || freq == BPBELL) ioctl(1, KDMKTONE, (300L << 16) | 1350L ); else { ULONG lfreq, lhsec; /* if either parameter is OFF, skip */ if (!(hsec == OFF || freq == OFF)) { lhsec = (ULONG) hsec * 10L; lfreq = (1190000L / (ULONG) freq) & 0x0000ffff; ioctl(1, KDMKTONE, (lhsec << 16) | lfreq); } } } else { /*do we really need to ring bell? */ if (hsec == BPBELL || freq == BPBELL || (hsec > 0 && freq > 0)) { if (_cur_att == BLK_GRAPH) /*make sure bell char will not be */ _vsatt_set(NORMAL); /*interpreted as character to display */ _puts_pad(_kbd_cmd[KBD_BELL], 1); _vv_flush(); /*flush output */ } } #else /*do we really need to ring bell? */ if (hsec == BPBELL || freq == BPBELL || (hsec > 0 && freq > 0)) { if (_cur_att == BLK_GRAPH) /*make sure bell char will not be */ _vsatt_set(NORMAL); /*interpreted as character to display */ _puts_pad(_kbd_cmd[KBD_BELL], 1); _vv_flush(); /*flush output */ } #endif EXIT_NOERRH(fn); return; }