If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there any way to use pc-speaker in c/c++ ?
- reC
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
Thanks, it works fine but doesn't seem to work in win32...
Any ideas for use it in windows?
- reC
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
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