Re: example c program that does beep

2009-12-26 Thread Anton Shterenlikht
On Fri, Dec 25, 2009 at 08:49:14PM +0100, Polytropon wrote:
 On Fri, 25 Dec 2009 18:58:26 +, Anton Shterenlikht me...@bristol.ac.uk 
 wrote:
  How can I get a beep from c?
  I looked at curses and syscons.c, but
  still not clear.
 
 If you want to use NCURSES / CURSES, it's a bit complicated.
 
 Otherwise, just output %c (the character) 0x07, BEL, which
 generates an audible bell, or beep.
 
 
 *** text/plain attachement has been stripped *** RETRY ***
 
 /* beepflash.c
  * ---
  * cc -Wall -lcurses -o beepflash beepflash.c
  *
  */
 
 #include stdio.h
 #include ncurses.h
 
 int main(int argc, char *argv[])
 {
   initscr();
   cbreak();
   noecho();
   nonl();
   intrflush(stdscr, FALSE);
   keypad(stdscr, TRUE);
   start_color();
 
   printf(beep: %d\n, beep());
   fflush(stdout);
 
   printf(flash: %d\n, flash());
   fflush(stdout);
 
   return 0;
 }

Instead of a beep and a flash I get:

beep: 0./beepflash
   flash: 0
   HAMOR

on the console.

Hamor is a tcsh prompt.

Maybe something is wrong with my installation?
Or maybe I'm too stupid and missed something
obvious?

thank you

-- 
Anton Shterenlikht
Room 2.6, Queen's Building
Mech Eng Dept
Bristol University
University Walk, Bristol BS8 1TR, UK
Tel: +44 (0)117 331 5944
Fax: +44 (0)117 929 4423
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: example c program that does beep

2009-12-26 Thread Anton Shterenlikht
On Fri, Dec 25, 2009 at 02:02:19PM -0500, Joe Marcus Clarke wrote:
 On Fri, 2009-12-25 at 18:58 +, Anton Shterenlikht wrote:
  How can I get a beep from c?
  I looked at curses and syscons.c, but
  still not clear.
  Could somebody send me an example.
  I'd be soo grateful.
 
 #include stdio.h
 
 int
 main(int argc, char **argv) {
 printf(%c, 7);
 return(0);
 }

Doesn't seem to do anything. Maybe 
there's something wrong with my sound?
But mp3 player seems to come out ok.
Or maybe I missed something obvious..

thanks a lot
anton

-- 
Anton Shterenlikht
Room 2.6, Queen's Building
Mech Eng Dept
Bristol University
University Walk, Bristol BS8 1TR, UK
Tel: +44 (0)117 331 5944
Fax: +44 (0)117 929 4423
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: example c program that does beep

2009-12-26 Thread Thomas Dickey
On Sat, Dec 26, 2009 at 03:33:27PM +, Anton Shterenlikht wrote:
 On Fri, Dec 25, 2009 at 08:49:14PM +0100, Polytropon wrote:
  On Fri, 25 Dec 2009 18:58:26 +, Anton Shterenlikht 
  me...@bristol.ac.uk wrote:
   How can I get a beep from c?
   I looked at curses and syscons.c, but
   still not clear.
  
  If you want to use NCURSES / CURSES, it's a bit complicated.
  
  Otherwise, just output %c (the character) 0x07, BEL, which
  generates an audible bell, or beep.
  
  
  *** text/plain attachement has been stripped *** RETRY ***
  
  /* beepflash.c
   * ---
   * cc -Wall -lcurses -o beepflash beepflash.c
   *
   */
  
  #include stdio.h
  #include ncurses.h
  
  int main(int argc, char *argv[])
  {
  initscr();
  cbreak();
  noecho();
  nonl();
  intrflush(stdscr, FALSE);
  keypad(stdscr, TRUE);
  start_color();
  
  printf(beep: %d\n, beep());
  fflush(stdout);
  
  printf(flash: %d\n, flash());
  fflush(stdout);
  
  return 0;
  }
 
 Instead of a beep and a flash I get:
 
 beep: 0./beepflash
flash: 0
HAMOR

That sounds about right, given the code shown above.
If you'd used just
beep();
refresh();

instead of the printf/fflush, it would clear the screen and beep - if the
terminal description says it can do the beep.

In the ncurses sources, progs/clear.c is a simple program which sets
up the terminal and calls the tputs function - something like what you're
trying to do.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net


pgpJ5yl6kbLCZ.pgp
Description: PGP signature


Re: example c program that does beep

2009-12-26 Thread Anton Shterenlikht
On Sat, Dec 26, 2009 at 11:50:06AM -0500, Thomas Dickey wrote:
 
 instead of the printf/fflush, it would clear the screen and beep - if the
 terminal description says it can do the beep.

I have 

 echo $TERM
xterm


xterm can do beep, can't it?

But I can't get it to beep on anything.
I probably don't get some basic idea..

many thanks
anton


-- 
Anton Shterenlikht
Room 2.6, Queen's Building
Mech Eng Dept
Bristol University
University Walk, Bristol BS8 1TR, UK
Tel: +44 (0)117 331 5944
Fax: +44 (0)117 929 4423
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: example c program that does beep

2009-12-26 Thread Polytropon
On Sat, 26 Dec 2009 17:16:23 +, Anton Shterenlikht me...@bristol.ac.uk 
wrote:
 On Sat, Dec 26, 2009 at 11:50:06AM -0500, Thomas Dickey wrote:
  
  instead of the printf/fflush, it would clear the screen and beep - if the
  terminal description says it can do the beep.

The exanple I posted displays the return code of the functions,
which is of (int) type. Of course, the common way to use them
is to just call beep(); and it should beep if the terminal can
do it.



 I have 
 
  echo $TERM
 xterm
 
 
 xterm can do beep, can't it?

It can. I've just checked from within the xterm terminal
emulator. Are you possibly using Konsole or the Gnome
terminal program, or rxvt? In fact, it shouldn't matter.



 But I can't get it to beep on anything.
 I probably don't get some basic idea..

You're sure that yu haven't turned beeping completely off
with some xset call?

As far as I remember, for simple beeping, the speaker
device (device SPEAKER or speaker_load=YES) isn't
required.

Maybe some wild mixer-settings?




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: example c program that does beep

2009-12-26 Thread Anton Shterenlikht
On Sat, Dec 26, 2009 at 08:08:52PM +0100, Polytropon wrote:
 On Sat, 26 Dec 2009 17:16:23 +, Anton Shterenlikht me...@bristol.ac.uk 
 wrote:
  On Sat, Dec 26, 2009 at 11:50:06AM -0500, Thomas Dickey wrote:
   
   instead of the printf/fflush, it would clear the screen and beep - if the
   terminal description says it can do the beep.
 
 The exanple I posted displays the return code of the functions,
 which is of (int) type. Of course, the common way to use them
 is to just call beep(); and it should beep if the terminal can
 do it.
 
 
 
  I have 
  
   echo $TERM
  xterm
  
  
  xterm can do beep, can't it?
 
 It can. I've just checked from within the xterm terminal
 emulator. Are you possibly using Konsole or the Gnome
 terminal program, or rxvt? In fact, it shouldn't matter.

it's on a text terminal, without X

looks like it's sparc issue, I do get beeps with this
code on ia386.

many thanks
anton

-- 
Anton Shterenlikht
Room 2.6, Queen's Building
Mech Eng Dept
Bristol University
University Walk, Bristol BS8 1TR, UK
Tel: +44 (0)117 331 5944
Fax: +44 (0)117 929 4423
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: example c program that does beep

2009-12-26 Thread Thomas Dickey
On Sat, Dec 26, 2009 at 05:16:23PM +, Anton Shterenlikht wrote:
 On Sat, Dec 26, 2009 at 11:50:06AM -0500, Thomas Dickey wrote:
  
  instead of the printf/fflush, it would clear the screen and beep - if the
  terminal description says it can do the beep.
 
 I have 
 
  echo $TERM
 xterm
 
 
 xterm can do beep, can't it?

usually.  I broke it (and fixed it) last spring.
There's a workaround by setting a resource value, noted in the change
comment:

http://invisible-island.net/xterm/xterm.log.html#xterm_243

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net


pgpNznqBird5K.pgp
Description: PGP signature


example c program that does beep

2009-12-25 Thread Anton Shterenlikht
How can I get a beep from c?
I looked at curses and syscons.c, but
still not clear.
Could somebody send me an example.
I'd be soo grateful.

many thanks
anton

-- 
Anton Shterenlikht
Room 2.6, Queen's Building
Mech Eng Dept
Bristol University
University Walk, Bristol BS8 1TR, UK
Tel: +44 (0)117 331 5944
Fax: +44 (0)117 929 4423
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: example c program that does beep

2009-12-25 Thread Aryeh Friedman
printf(\007); /* assumes that your using a console/terminal that
will beep on ctl-g */

On Fri, Dec 25, 2009 at 1:58 PM, Anton Shterenlikht me...@bristol.ac.uk wrote:
 How can I get a beep from c?
 I looked at curses and syscons.c, but
 still not clear.
 Could somebody send me an example.
 I'd be soo grateful.

 many thanks
 anton

 --
 Anton Shterenlikht
 Room 2.6, Queen's Building
 Mech Eng Dept
 Bristol University
 University Walk, Bristol BS8 1TR, UK
 Tel: +44 (0)117 331 5944
 Fax: +44 (0)117 929 4423
 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: example c program that does beep

2009-12-25 Thread Joe Marcus Clarke
On Fri, 2009-12-25 at 18:58 +, Anton Shterenlikht wrote:
 How can I get a beep from c?
 I looked at curses and syscons.c, but
 still not clear.
 Could somebody send me an example.
 I'd be soo grateful.

#include stdio.h

int
main(int argc, char **argv) {
printf(%c, 7);
return(0);
}

Joe

-- 
PGP Key : http://www.marcuscom.com/pgp.asc


signature.asc
Description: This is a digitally signed message part


Re: example c program that does beep

2009-12-25 Thread Polytropon
On Fri, 25 Dec 2009 18:58:26 +, Anton Shterenlikht me...@bristol.ac.uk 
wrote:
 How can I get a beep from c?
 I looked at curses and syscons.c, but
 still not clear.

If you want to use NCURSES / CURSES, it's a bit complicated.

Otherwise, just output %c (the character) 0x07, BEL, which
generates an audible bell, or beep.



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org

Re: example c program that does beep

2009-12-25 Thread Polytropon
On Fri, 25 Dec 2009 18:58:26 +, Anton Shterenlikht me...@bristol.ac.uk 
wrote:
 How can I get a beep from c?
 I looked at curses and syscons.c, but
 still not clear.

If you want to use NCURSES / CURSES, it's a bit complicated.

Otherwise, just output %c (the character) 0x07, BEL, which
generates an audible bell, or beep.


*** text/plain attachement has been stripped *** RETRY ***

/* beepflash.c
 * ---
 * cc -Wall -lcurses -o beepflash beepflash.c
 *
 */

#include stdio.h
#include ncurses.h

int main(int argc, char *argv[])
{
initscr();
cbreak();
noecho();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
start_color();

printf(beep: %d\n, beep());
fflush(stdout);

printf(flash: %d\n, flash());
fflush(stdout);

return 0;
}





-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: example c program that does beep

2009-12-25 Thread Thomas Dickey
On Fri, Dec 25, 2009 at 08:34:39PM +0100, Polytropon wrote:
 On Fri, 25 Dec 2009 18:58:26 +, Anton Shterenlikht me...@bristol.ac.uk 
 wrote:
  How can I get a beep from c?
  I looked at curses and syscons.c, but
  still not clear.
 
 If you want to use NCURSES / CURSES, it's a bit complicated.

tput bel

(that's part of ncurses - though your configuration iirc doesn't have
a fully-functional tput).

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net


pgpxYrymOFAfs.pgp
Description: PGP signature