• Advertisement

Archived

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

How can i make the pc speaker beep?

This topic is 5035 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
quote:
Original post by 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.




Nobody would ever call the current win32 api pretty. Its also going to become outdated the second that Longhorn is released. I wouldn''t suggest anybody learn it right now.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You have a point, but the OP is limiting himself by sticking to DOS. And anyway, it''ll be some time before Longhorn arrives.

Share this post


Link to post
Share on other sites
quote:
Original post by haro
quote:
Original post by 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.




Nobody would ever call the current win32 api pretty. Its also going to become outdated the second that Longhorn is released. I wouldn''t suggest anybody learn it right now.



DOS on the other hand is already outdated and isn''t exactly pretty either.

Share this post


Link to post
Share on other sites
quote:
Original post by haro
quote:
Original post by 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.




Nobody would ever call the current win32 api pretty. Its also going to become outdated the second that Longhorn is released. I wouldn''t suggest anybody learn it right now.


Yeah, it''s always best to plan for things 2+ years in advance that have yet to be proven in the mass market. And besides, it never pays to understand the foundation and history of advancing technology.

Share this post


Link to post
Share on other sites
quote:
Original post by Chozo
quote:

Nobody would ever call the current win32 api pretty. Its also going to become outdated the second that Longhorn is released. I wouldn''t suggest anybody learn it right now.


Yeah, it''s always best to plan for things 2+ years in advance that have yet to be proven in the mass market. And besides, it never pays to understand the foundation and history of advancing technology.


Win32 will not be the foundation of Longhorn by any means, thank god. .NET is already being rapidly proven, Longhorn will be simply symbolic of it becoming the defacto standard for Windows development.

Also it is generally very wise to plan for what you think is likely to be the future. If you think .NET will just turn out to be an overhyped ''thing'' that will disappear in a few months then feel free to ignore it. If you think its going to revolutionize development then you better start learning now. Picking it up and learning from absolute scratch would be painfully time consuming.

The point in not learning Win32 is that it just plain sucks and will not serve any practical use in the future. Its disorganized, not always well documented, often superflous, etc.. x86 asm is definitely a nasty little toy, but it ( or derivitives ) are most likely here to stay for a while. This makes it worth learning.

Share this post


Link to post
Share on other sites
Meanwhile, Win32 API (and MFC, et al.) apps are still being made and will continue to be made by any developer that chooses a wide user base (ie, larger market) over marketing hype and projection statistics (the .com boom comes to mind here, with its grand promises of the future and technology).

I guess if one were to seriously consider limiting themselves to technology that has no place for at least two years (and is in constant flux until that time), then that same person might also already have work putting food on the table. Given someone who just wants to get a decent app at the door (for work or pleasure), I think it's safe to say the wait is not the ideal situation.

[edited by - Chozo on May 11, 2004 3:34:15 PM]

Share this post


Link to post
Share on other sites
Yes, we all know that the .NET framework and .NET languages such as C# are all just figments of my imagination. I better go rehash on my MFC knowledge, these make believe Windows forms are going nowhere.

Share this post


Link to post
Share on other sites
Nah, I think you're safe ignoring that they have a foundation (and recommending the same to others). It's not like anyone benefits from learning ASM when they already know C. Ignorance is bliss, I always say.

[edited by - Chozo on May 11, 2004 3:56:18 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by haro
Nobody would ever call the current win32 api pretty. Its also going to become outdated the second that Longhorn is released. I wouldn''t suggest anybody learn it right now.

...

Also it is generally very wise to plan for what you think is likely to be the future.



I guess I better forget everything I know about how to drive a car, and start preparing for getting my brain directly wired to the car. Cause I figure in another 20+ years, that should happen. And I don''t want to have fallen behind when that time comes.

Share this post


Link to post
Share on other sites
quote:
Original post by Chozo
Nah, I think you''re safe ignoring that they have a foundation (and recommending the same to others). It''s not like anyone benefits from learning ASM when they already know C. Ignorance is bliss, I always say.

[edited by - Chozo on May 11, 2004 3:56:18 PM]


Wow, you didn''t even bother reading my messages before writing more random bs did you? I actually mentioned assembly as a worthwhile pursuit and explained why Win32 was not. Go away, troll.

Share this post


Link to post
Share on other sites
So you''re a hypocrite then? Best you look in the mirror before you resort to name calling. It''s okay to be wrong. Be a man and own up to it.

Share this post


Link to post
Share on other sites
quote:
Original post by Chozo
So you''re a hypocrite then? Best you look in the mirror before you resort to name calling. It''s okay to be wrong. Be a man and own up to it.


LOL

moron.

sorry, that just came out.

Seriously, learning ASM can help many better understand what the hell their computer is doing behind their back.

It also has applications in compiler design/creation which is very handy for inventing new languages, as well as hacking away at kernel level projects (such as some of linux''s basecode). This isn''t even going into polymorphic code, useful for virus writers, and those interested in artificial life.

If ignorance is bliss, you should unlearn how to read so we can all be rid of you.

Share this post


Link to post
Share on other sites
Unterstanding the Win32 API speeds up things even more when working with .NET, you know what or where you need to look for certain functions/abilities.

Share this post


Link to post
Share on other sites

  • Advertisement