How do I make my program beep.

Dan KoGai dankg at tornado.Berkeley.EDU
Sat Jun 9 03:06:57 AEST 1990


In article <43605 at ism780c.isc.com> marv at ism780.UUCP (Marvin Rubenstein) writes:
>>(2) #define mybeep putchar('\7')
>>    has a fairly serious defect:  output to stdout is often buffered or
>>    line-buffered, and '\7' is not a complete record.  You need
>>	#define mybeep (putchar('\7'), fflush(stdout))
>>
>
>putchar('\7') has an even more serious defect.  The reason for beeping is
>to notify the user of the program of something while the program is
>*running*. There is no guarantee that sending a '\7' to stdout will cause an
>beep.  Stdout may well be a diskfile.  The output must be directed to a
>device that will make a noise that the user can hear.  I know of no portable
>way to do this.

	You are absolutely right:  Even using fputc(stderr, '\7'), some shells
can still put stderr to files without prob.  fputc(/dev/tty, '\7') ? maybe.
	Still it's not very good idea to beeb via ascii beep:  Such machines
as Macintosh have very extensive sound package and maybe other program is using
sound port alread (Mac has 4 channels though).  Suppose you are plaing Loud
music with CD-ROM driver and you want to beep.  What you you do?  Find unused
soundport and beep on the background which might be ignored due to other sound?
or you halt other programs, stop other sound and beep?  There are many
possibilities.
	IMHO, warning by ascii beep is obsolete technique, with machines with
far more complex and capability of handling sound.

----------------
____  __  __    + Dan The "beep("Don't Beep, man!")" Man
    ||__||__|   + E-mail:	dankg at ocf.berkeley.edu
____| ______ 	+ Voice:	+1 415-549-6111
|     |__|__|	+ USnail:	1730 Laloma Berkeley, CA 94709 U.S.A
|___  |__|__|	+	
    |____|____	+ "What's the biggest U.S. export to Japan?" 	
  \_|    |      + "Bullshit.  It makes the best fertilizer for their rice"



More information about the Comp.lang.c mailing list