Menu

PC-speaker

2003-01-23
2012-09-26
  • Nobody/Anonymous

    Is there any way to use pc-speaker in c/c++ ?

    - reC

     
    • Anonymous

      Anonymous - 2003-01-23

      The simplest way is to send and ASCII ALERT(BELL) character to stdout.

      Examples:

      putchar( '\a' ) ;         // C stdio
      std::cout << '\a' ;     // C++ iostream

      This is simple and crude, (fixed tone, fixed length). Not sure if it works in GUI apps though.

      Other that that, because accessing the PC speaker required hardware I/O access, you will need a driver. There are port access drivers available to allow hardware access without a specific driver. The speaker is driven from the PC timer chip, you set the frequency an let it go.

      There is a speaker driver from Microsoft that apparently works in Win9x although I think that it is a Win3.1 16 bit driver. It allows WAV files to be played (with varying results)!
      http://www.cyberwalker.net/columns/jun00/300600c.html

       
    • Nobody/Anonymous

      Thanks, it works fine but doesn't seem to work in win32...
      Any ideas for use it in windows?

      - reC

       
    • Nobody/Anonymous

      which win32 are you using?
      I think under NT/XP/2K you're pretty much out of luck with the pc speaker, unless there's a driver to do it out there somewhere.
      I know there's an API call, MessageBeep if I recall correctly, that is supposed to beep through the sound card if there is one, if not then it uses the pc speaker..

      blackadder

       
    • Nobody/Anonymous

      Yeah, MessageBeep() just beeps the speaker like \a if you don't have a sound card. Otherwise you pass it MB_ICONERROR, MB_ICONINFORMATION, etc and it makes the appropriate noise.

      Kip

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.