Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Durkane

How can i make the pc speaker beep?

This topic is 5249 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to know the code, header files, functions or what ever to be able to make the pc speaker beep. I want to do this just in a simple dos program, since I don''t know the windows api. I''m using borland c++ if that helps.

Share this post


Link to post
Share on other sites
Advertisement
this won''t help you then but the windows api has a function called Beep. i''m sure however that the crt has an equivalent. no, i won''t browse the crt headers for you... go for the msdn

Share this post


Link to post
Share on other sites
if you are doing this in a simple consol application this would do the trick, not sure how you would do it in a Win32API though..


#include <iostream>
using namespace std;

int main(void)
{
cout << ''\a''; // see bellow
return 0;
}


when backslach (\) is used there is a escapechar.. e.g:
\a (inserts an ''alarm''), \t (inserts a tab), \n (inserts a newline)... and so on, this is C style and i don''t know if there is a "good" way of doing this without a consol.. maby it would work in a Win32API window as well? have not tried it.

hope it answers youre question

//Qrikko


"All it takes is for the rendered image to look right" -Jim Blinn

Share this post


Link to post
Share on other sites
Actually, I think that makes the computer loudspeaker beep, so you don''t even need external speakers.

Share this post


Link to post
Share on other sites
thanks qrikko, that was exactly what I was looking for. It''s actually quite a bit easier than I expected.

Share this post


Link to post
Share on other sites
Np

yes, all stuffes is easy when you know how to do it
but even when it''s as easy as this (one line) it''s damn hard when you don''t know how to do it!

thats why I love this site, there is always someone that have the knowledge that one need!

//Qrikko

"All it takes is for the rendered image to look right" -Jim Blinn

Share this post


Link to post
Share on other sites
An even more reliable method that will always work is to know that ASCII code 0x07 is the code for the ''BEEP'' signal. As long as this is true you can always rest assured that printing a beep signal will make a beep sound.

printf("%c", 7) works.

Using old dos interrupts:
mov ah,2
mov dl,7
int 21

also works.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Durkane
I want to do this just in a simple dos program, since I don''t know the windows api .


Then perhaps it''s about time that you learn.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!